story-summary: facts UI split + relationships from facts

This commit is contained in:
2026-02-02 22:48:07 +08:00
parent fb8ed8037c
commit 1128d1494e
5 changed files with 67 additions and 75 deletions

View File

@@ -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
*/