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

Function test_init_labels

spacy/tests/test_cli.py:715–741  ·  view source on GitHub ↗
(component_name)

Source from the content-addressed store, hash-verified

713
714@pytest.mark.parametrize("component_name", ["ner", "textcat", "spancat", "tagger"])
715def test_init_labels(component_name):
716 nlp = Dutch()
717 component = nlp.add_pipe(component_name)
718 for label in ["T1", "T2", "T3", "T4"]:
719 component.add_label(label)
720 assert len(nlp.get_pipe(component_name).labels) == 4
721
722 with make_tempdir() as tmp_dir:
723 _init_labels(nlp, tmp_dir)
724
725 config = init_config(
726 lang="nl",
727 pipeline=[component_name],
728 optimize="efficiency",
729 gpu=False,
730 )
731 config["initialize"]["components"][component_name] = {
732 "labels": {
733 "@readers": "spacy.read_labels.v1",
734 "path": f"{tmp_dir}/{component_name}.json",
735 }
736 }
737
738 nlp2 = load_model_from_config(config, auto_fill=True)
739 assert len(nlp2.get_pipe(component_name).labels) == 0
740 nlp2.initialize()
741 assert len(nlp2.get_pipe(component_name).labels) == 4
742
743
744def test_get_third_party_dependencies():

Callers

nothing calls this directly

Calls 9

DutchClass · 0.90
_init_labelsFunction · 0.90
init_configFunction · 0.90
load_model_from_configFunction · 0.90
make_tempdirFunction · 0.85
add_pipeMethod · 0.80
get_pipeMethod · 0.80
add_labelMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…