Refine diffusion graph channels and drop legacy who compatibility
This commit is contained in:
@@ -128,12 +128,12 @@ function normalize(s) {
|
||||
|
||||
/**
|
||||
* 收集 L0 的实体集合(用于背景证据实体过滤)
|
||||
* 支持新结构 who/edges,也兼容旧结构 subject/object。
|
||||
* 使用 edges.s/edges.t。
|
||||
* @param {object} l0
|
||||
* @returns {Set<string>}
|
||||
*/
|
||||
function collectL0Entities(l0) {
|
||||
const atom = l0?.atom || l0?._atom || {};
|
||||
const atom = l0?.atom || {};
|
||||
const set = new Set();
|
||||
|
||||
const add = (v) => {
|
||||
@@ -141,16 +141,11 @@ function collectL0Entities(l0) {
|
||||
if (n) set.add(n);
|
||||
};
|
||||
|
||||
for (const w of (atom.who || [])) add(w);
|
||||
for (const e of (atom.edges || [])) {
|
||||
add(e?.s);
|
||||
add(e?.t);
|
||||
}
|
||||
|
||||
// 兼容旧数据
|
||||
add(atom.subject);
|
||||
add(atom.object);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
@@ -159,8 +154,7 @@ function collectL0Entities(l0) {
|
||||
* 规则:
|
||||
* 1) 无焦点实体:保留
|
||||
* 2) similarity >= 0.70:保留(旁通)
|
||||
* 3) who/edges 命中焦点实体:保留
|
||||
* 4) 兼容旧数据:semantic 文本包含焦点实体:保留
|
||||
* 3) edges 命中焦点实体:保留
|
||||
* 否则过滤。
|
||||
* @param {object} l0
|
||||
* @param {Set<string>} focusSet
|
||||
@@ -175,11 +169,6 @@ function shouldKeepEvidenceL0(l0, focusSet) {
|
||||
if (entities.has(f)) return true;
|
||||
}
|
||||
|
||||
// 旧数据兜底:从 semantic 文本里做包含匹配
|
||||
const textNorm = normalize(l0?.atom?.semantic || l0?.text || '');
|
||||
for (const f of focusSet) {
|
||||
if (f && textNorm.includes(f)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user