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

Function test_issue2179

spacy/tests/parser/test_ner.py:85–98  ·  view source on GitHub ↗

Test that spurious 'extra_labels' aren't created when initializing NER.

()

Source from the content-addressed store, hash-verified

83
84@pytest.mark.issue(2179)
85def test_issue2179():
86 """Test that spurious 'extra_labels' aren't created when initializing NER."""
87 nlp = Italian()
88 ner = nlp.add_pipe("ner")
89 ner.add_label("CITIZENSHIP")
90 nlp.initialize()
91 nlp2 = Italian()
92 nlp2.add_pipe("ner")
93 assert len(nlp2.get_pipe("ner").labels) == 0
94 model = nlp2.get_pipe("ner").model
95 model.attrs["resize_output"](model, nlp.get_pipe("ner").moves.n_moves)
96 nlp2.from_bytes(nlp.to_bytes())
97 assert "extra_labels" not in nlp2.get_pipe("ner").cfg
98 assert nlp2.get_pipe("ner").labels == ("CITIZENSHIP",)
99
100
101@pytest.mark.issue(2385)

Callers

nothing calls this directly

Calls 7

ItalianClass · 0.90
add_pipeMethod · 0.80
get_pipeMethod · 0.80
add_labelMethod · 0.45
initializeMethod · 0.45
from_bytesMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…