mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 10:46:29 +03:00
Fix get_matching_ents (#10451)
* Fix get_matching_ents Not sure what happened here - the code prior to this commit simply does not work. It's already covered by entity linker tests, which were succeeding in the NEL PR, but couldn't possibly succeed on master. * Fix test Test was indented inside another test and so doesn't seem to have been running properly.
This commit is contained in:
parent
7ed7908716
commit
61ba5450ff
|
@ -1009,7 +1009,7 @@ def test_legacy_architectures(name, config):
|
||||||
losses = {}
|
losses = {}
|
||||||
nlp.update(train_examples, sgd=optimizer, losses=losses)
|
nlp.update(train_examples, sgd=optimizer, losses=losses)
|
||||||
|
|
||||||
@pytest.mark.parametrize("patterns", [
|
@pytest.mark.parametrize("patterns", [
|
||||||
# perfect case
|
# perfect case
|
||||||
[{"label": "CHARACTER", "pattern": "Kirby"}],
|
[{"label": "CHARACTER", "pattern": "Kirby"}],
|
||||||
# typo for false negative
|
# typo for false negative
|
||||||
|
@ -1017,8 +1017,8 @@ def test_legacy_architectures(name, config):
|
||||||
# random stuff for false positive
|
# random stuff for false positive
|
||||||
[{"label": "IS", "pattern": "is"}, {"label": "COLOR", "pattern": "pink"}],
|
[{"label": "IS", "pattern": "is"}, {"label": "COLOR", "pattern": "pink"}],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_no_gold_ents(patterns):
|
def test_no_gold_ents(patterns):
|
||||||
# test that annotating components work
|
# test that annotating components work
|
||||||
TRAIN_DATA = [
|
TRAIN_DATA = [
|
||||||
(
|
(
|
||||||
|
|
|
@ -263,11 +263,11 @@ cdef class Example:
|
||||||
kept. Otherwise only the character indices need to match.
|
kept. Otherwise only the character indices need to match.
|
||||||
"""
|
"""
|
||||||
gold = {}
|
gold = {}
|
||||||
for ent in self.reference:
|
for ent in self.reference.ents:
|
||||||
gold[(ent.start_char, ent.end_char)] = ent.label
|
gold[(ent.start_char, ent.end_char)] = ent.label
|
||||||
|
|
||||||
keep = []
|
keep = []
|
||||||
for ent in self.predicted:
|
for ent in self.predicted.ents:
|
||||||
key = (ent.start_char, ent.end_char)
|
key = (ent.start_char, ent.end_char)
|
||||||
if key not in gold:
|
if key not in gold:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue
Block a user