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

Function test_issue4267

spacy/tests/parser/test_ner.py:179–201  ·  view source on GitHub ↗

Test that running an entity_ruler after ner gives consistent results

()

Source from the content-addressed store, hash-verified

177
178@pytest.mark.issue(4267)
179def test_issue4267():
180 """Test that running an entity_ruler after ner gives consistent results"""
181 nlp = English()
182 ner = nlp.add_pipe("ner")
183 ner.add_label("PEOPLE")
184 nlp.initialize()
185 assert "ner" in nlp.pipe_names
186 # assert that we have correct IOB annotations
187 doc1 = nlp("hi")
188 assert doc1.has_annotation("ENT_IOB")
189 for token in doc1:
190 assert token.ent_iob == 2
191 # add entity ruler and run again
192 patterns = [{"label": "SOFTWARE", "pattern": "spacy"}]
193 ruler = nlp.add_pipe("entity_ruler")
194 ruler.add_patterns(patterns)
195 assert "entity_ruler" in nlp.pipe_names
196 assert "ner" in nlp.pipe_names
197 # assert that we still have correct IOB annotations
198 doc2 = nlp("hi")
199 assert doc2.has_annotation("ENT_IOB")
200 for token in doc2:
201 assert token.ent_iob == 2
202
203
204@pytest.mark.issue(4313)

Callers

nothing calls this directly

Calls 6

EnglishClass · 0.90
add_pipeMethod · 0.80
nlpFunction · 0.50
add_labelMethod · 0.45
initializeMethod · 0.45
add_patternsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…