mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +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 = {}
|
||||
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 = [
|
||||
(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user