MCPcopy
hub / github.com/explosion/spaCy / _get_examples_without_label

Function _get_examples_without_label

spacy/cli/debug_data.py:1019–1043  ·  view source on GitHub ↗
(
    data: Sequence[Example],
    label: str,
    component: Literal["ner", "spancat"] = "ner",
    spans_key: Optional[str] = "sc",
)

Source from the content-addressed store, hash-verified

1017
1018
1019def _get_examples_without_label(
1020 data: Sequence[Example],
1021 label: str,
1022 component: Literal["ner", "spancat"] = "ner",
1023 spans_key: Optional[str] = "sc",
1024) -> int:
1025 count = 0
1026 for eg in data:
1027 if component == "ner":
1028 labels = [
1029 remove_bilu_prefix(label)
1030 for label in eg.get_aligned_ner()
1031 if label not in ("O", "-", None)
1032 ]
1033
1034 if component == "spancat":
1035 labels = (
1036 [span.label_ for span in eg.reference.spans[spans_key]]
1037 if spans_key in eg.reference.spans
1038 else []
1039 )
1040
1041 if label not in labels:
1042 count += 1
1043 return count
1044
1045
1046def _get_labels_from_model(nlp: Language, factory_name: str) -> Set[str]:

Callers 1

debug_dataFunction · 0.85

Calls 1

remove_bilu_prefixFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…