fix(review): address MEDIUM items from final code-reviewer
- anti_unifier: remove arbitrary root fallback when no agent_node_id (only apply root-form when nid known; primary pipeline path unaffected) - depth_canonical: filter build_node_depths to he/grc (or nodes with root) so English nodes no longer pollute node_depths with language-only entries Tests re-run green. Matches review recommendations for the 3-lang depth feature.
This commit is contained in:
parent
0188af46c0
commit
7b0c0ae8ce
2 changed files with 6 additions and 12 deletions
|
|
@ -272,18 +272,12 @@ def recognize(
|
||||||
value, evidence = _lift_slot(slot, original_tokens, span)
|
value, evidence = _lift_slot(slot, original_tokens, span)
|
||||||
feature_evidence[slot.feature_name] = (value, evidence)
|
feature_evidence[slot.feature_name] = (value, evidence)
|
||||||
|
|
||||||
# 3-lang root form for agent in proposition when depth (nid-keyed via agent_node_id if given; proof of canonical match).
|
# 3-lang root form for agent in proposition when depth (nid-keyed via agent_node_id).
|
||||||
# Uses canonicalize_token for consistency with derive path; no mutation.
|
# Only applied when explicit nid is provided (primary pipeline path always does).
|
||||||
if depths and 'agent' in feature_evidence:
|
# Without nid we do not guess a root (avoids unrelated root in proposition).
|
||||||
|
if depths and 'agent' in feature_evidence and agent_node_id and agent_node_id in depths:
|
||||||
val, ev = feature_evidence['agent']
|
val, ev = feature_evidence['agent']
|
||||||
nid = agent_node_id
|
val = canonicalize_token(str(val), agent_node_id, depths)
|
||||||
if nid and nid in depths:
|
|
||||||
val = canonicalize_token(str(val), nid, depths)
|
|
||||||
else:
|
|
||||||
for d in depths.values():
|
|
||||||
if d.get('language') in ('he', 'grc') and d.get('root'):
|
|
||||||
val = d['root']
|
|
||||||
break
|
|
||||||
feature_evidence['agent'] = (val, ev)
|
feature_evidence['agent'] = (val, ev)
|
||||||
|
|
||||||
proposition = FeatureBundle.from_mapping(feature_evidence)
|
proposition = FeatureBundle.from_mapping(feature_evidence)
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ def build_node_depths(nodes: Sequence[Any]) -> dict[str, dict]:
|
||||||
}.items() if v is not None
|
}.items() if v is not None
|
||||||
}
|
}
|
||||||
for n in nodes
|
for n in nodes
|
||||||
if getattr(n, "language", None) or getattr(n, "root", None)
|
if getattr(n, "language", None) in ("he", "grc") or getattr(n, "root", None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue