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:
Paul O'Leary McCann 2022-03-08 00:56:57 +09:00 committed by GitHub
parent 7ed7908716
commit 61ba5450ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 56 additions and 56 deletions

View File

@ -1009,7 +1009,7 @@ def test_legacy_architectures(name, config):
losses = {}
nlp.update(train_examples, sgd=optimizer, losses=losses)
@pytest.mark.parametrize("patterns", [
@pytest.mark.parametrize("patterns", [
# perfect case
[{"label": "CHARACTER", "pattern": "Kirby"}],
# typo for false negative
@ -1017,8 +1017,8 @@ def test_legacy_architectures(name, config):
# random stuff for false positive
[{"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
TRAIN_DATA = [
(

View File

@ -263,11 +263,11 @@ cdef class Example:
kept. Otherwise only the character indices need to match.
"""
gold = {}
for ent in self.reference:
for ent in self.reference.ents:
gold[(ent.start_char, ent.end_char)] = ent.label
keep = []
for ent in self.predicted:
for ent in self.predicted.ents:
key = (ent.start_char, ent.end_char)
if key not in gold:
continue