story-summary: facts UI split + relationships from facts
This commit is contained in:
@@ -76,6 +76,27 @@ export function isRelationFact(f) {
|
||||
return /^对.+的/.test(f.p);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
// 从 facts 提取关系(供关系图 UI 使用)
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
export function extractRelationshipsFromFacts(facts) {
|
||||
return (facts || [])
|
||||
.filter(f => !f.retracted && isRelationFact(f))
|
||||
.map(f => {
|
||||
const match = f.p.match(/^对(.+)的/);
|
||||
const to = match ? match[1] : '';
|
||||
if (!to) return null;
|
||||
return {
|
||||
from: f.s,
|
||||
to,
|
||||
label: f.o,
|
||||
trend: f.trend || '陌生',
|
||||
};
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 fact 的唯一键(s + p)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user