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

Function test_issue2800

spacy/tests/parser/test_ner.py:119–137  ·  view source on GitHub ↗

Test issue that arises when too many labels are added to NER model. Used to cause segfault.

()

Source from the content-addressed store, hash-verified

117
118@pytest.mark.issue(2800)
119def test_issue2800():
120 """Test issue that arises when too many labels are added to NER model.
121 Used to cause segfault.
122 """
123 nlp = English()
124 train_data = []
125 train_data.extend(
126 [Example.from_dict(nlp.make_doc("One sentence"), {"entities": []})]
127 )
128 entity_types = [str(i) for i in range(1000)]
129 ner = nlp.add_pipe("ner")
130 for entity_type in list(entity_types):
131 ner.add_label(entity_type)
132 optimizer = nlp.initialize()
133 for i in range(20):
134 losses = {}
135 random.shuffle(train_data)
136 for example in train_data:
137 nlp.update([example], sgd=optimizer, losses=losses, drop=0.5)
138
139
140@pytest.mark.issue(3209)

Callers

nothing calls this directly

Calls 8

EnglishClass · 0.90
extendMethod · 0.80
from_dictMethod · 0.80
make_docMethod · 0.80
add_pipeMethod · 0.80
add_labelMethod · 0.45
initializeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…