src.dackar.RCA.ner.hybrid_ner.compatibility¶
Classes¶
Output of compatibility application: |
|
Applies label-group compatibility and conditional rules from group-schema.json. |
Module Contents¶
- class src.dackar.RCA.ner.hybrid_ner.compatibility.CompatibilityResult[source]¶
- Output of compatibility application:
updated_candidates: candidates with group annotations on hypotheses
decisions: decisions per candidate (accept/reject/defer/split)
relation_proposals: optional (v0.3 mostly empty)
- updated_candidates: List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan][source]¶
- decisions: List[src.dackar.RCA.ner.hybrid_ner.models.Decision][source]¶
- relation_proposals: List[src.dackar.RCA.ner.hybrid_ner.models.RelationProposal][source]¶
- class src.dackar.RCA.ner.hybrid_ner.compatibility.CompatibilityEngine(context_left=80, context_right=80)[source]¶
Applies label-group compatibility and conditional rules from group-schema.json.
- Upgrades:
- Conditional triggers:
cue_phrases_any / event_cues_any searched in context and sentence window
pattern_templates supported with placeholder expansion (<MECH>, <OUTCOME>, <PHYS>, <MAT>)
Split heuristic for G1_PHYSICAL + G6_OUTCOMES_OCCURRENCES compounds (R2 policy)
- Still enforced:
one label per group per span (best score retained)
multi-label allowed only if matrix says ‘A’ OR conditional rule allows it
- Parameters:
context_left (int)
context_right (int)
- assign_groups(candidates, schema)[source]¶
- Parameters:
candidates (List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan])
- Return type:
- apply(doc, candidates, schema)[source]¶
- Parameters:
candidates (List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan])
- Return type:
- resolve_span(doc, cand, schema)[source]¶
Resolve one candidate span into an accept/defer decision.
Policy (current): - Pick the best label per group (by score). - If multiple groups remain:
If same-span multi-label is not whitelisted -> reduce to single best label.
- If whitelisted (currently {G1_PHYSICAL_COMPONENT, G4_MECHANISM_PROCESS}) -> require token evidence
for BOTH roles using exclusive tokens (role-aware), else try conditional rules / split; if none apply -> reduce to single best label.
For other multi-group cases, consult conditional rules; if still not allowed -> reduce to single best label.
This intentionally prefers trustworthy output over forced collapse. When ambiguity remains material, defer instead of inventing certainty.
- Parameters:
- Return type:
Tuple[src.dackar.RCA.ner.hybrid_ner.models.Decision, List[src.dackar.RCA.ner.hybrid_ner.models.RelationProposal]]
- _allowed_same_span(groups)[source]¶
Return True iff same-span multi-labeling is allowed for these groups.
Conservative whitelist: only allow the pair {G1_PHYSICAL_COMPONENT, G4_MECHANISM_PROCESS}. (Change this if you want to allow additional group-pairs.)
- Parameters:
groups (list)
- Return type:
bool
- _multilabel_allowed_with_rules(doc, cand, groups, schema)[source]¶
- Parameters:
groups (List[str])
- Return type:
Tuple[bool, List[str]]
- _conditional_allows(doc, cand, g1, g2, schema)[source]¶
- Parameters:
g1 (str)
g2 (str)
- Return type:
Tuple[bool, str | None]