src.dackar.RCA.ner.hybrid_ner.generators.candidate_utils¶
Functions¶
|
Split spans that contain both a component token and a mechanism token. |
|
Deduplicate and filter candidate spans: |
|
Split candidates that have multiple proposed_labels into minimal single-label spans |
Module Contents¶
- src.dackar.RCA.ner.hybrid_ner.generators.candidate_utils.split_component_mechanism_spans(candidates, component_tokens, mechanism_tokens)[source]¶
Split spans that contain both a component token and a mechanism token.
Notes: - Uses word-boundary regex finditer (handles repeated tokens with correct offsets). - Creates unique span_ids per emitted token occurrence. - Copies sources/proposed_labels to avoid shared mutable lists and label loss.
- Parameters:
candidates (List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan])
component_tokens (set[str])
mechanism_tokens (set[str])
- Return type:
- src.dackar.RCA.ner.hybrid_ner.generators.candidate_utils.dedupe_candidate_spans(candidates)[source]¶
Deduplicate and filter candidate spans: - normalize by (start,end,text_lower) - prefer spans with proposed_labels - remove spans that are substrings of longer spans with identical proposed_labels - if labels differ, prefer shorter labeled spans (to keep minimal atomic tokens)
- Parameters:
candidates (List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan])
- Return type:
- src.dackar.RCA.ner.hybrid_ner.generators.candidate_utils.split_multi_label_spans(candidates, token_index=None)[source]¶
Split candidates that have multiple proposed_labels into minimal single-label spans using simple keyword heuristics for components vs degradations. If token_index is provided (dict token->labels from gazetteer), it will be used to find tokens inside the text.
- Parameters:
candidates (List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan])
- Return type: