src.dackar.RCA.ner.hybrid_ner.generators.candidate_utils

Attributes

logger

Functions

split_component_mechanism_spans(candidates, ...)

Split spans that contain both a component token and a mechanism token.

dedupe_candidate_spans(candidates)

Deduplicate and filter candidate spans:

Module Contents

src.dackar.RCA.ner.hybrid_ner.generators.candidate_utils.logger[source]
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:
Return type:

List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan]

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:

List[src.dackar.RCA.ner.hybrid_ner.models.CandidateSpan]