Fix newly introduced bug in EntityLinker.predict().

This commit is contained in:
Raphael Mitsch 2022-11-29 23:03:03 +01:00
parent 96909f3203
commit 6a30df3039
2 changed files with 4 additions and 4 deletions

View File

@ -529,7 +529,7 @@ class EntityLinker(TrainablePipe):
# set all prior probabilities to 0 if incl_prior=False # set all prior probabilities to 0 if incl_prior=False
scores = prior_probs = xp.asarray( scores = prior_probs = xp.asarray(
[ [
0.0 if self.incl_prior else c.prior_prob c.prior_prob if self.incl_prior else 0.0
for c in candidates for c in candidates
] ]
) )

View File

@ -496,7 +496,7 @@ def test_el_pipe_configuration(nlp):
doc = nlp(text) doc = nlp(text)
assert doc[0].ent_kb_id_ == "NIL" assert doc[0].ent_kb_id_ == "NIL"
assert doc[1].ent_kb_id_ == "" assert doc[1].ent_kb_id_ == ""
assert doc[2].ent_kb_id_ in ("Q2", "Q3") assert doc[2].ent_kb_id_ == "Q2"
# Replace the pipe with a new one with with a different candidate generator. # Replace the pipe with a new one with with a different candidate generator.
@ -540,9 +540,9 @@ def test_el_pipe_configuration(nlp):
) )
_entity_linker.set_kb(create_kb) _entity_linker.set_kb(create_kb)
_doc = nlp(doc_text) _doc = nlp(doc_text)
assert _doc[0].ent_kb_id_ in ("Q2", "Q3") assert _doc[0].ent_kb_id_ == "Q2"
assert _doc[1].ent_kb_id_ == "" assert _doc[1].ent_kb_id_ == ""
assert _doc[2].ent_kb_id_ in ("Q2", "Q3") assert _doc[2].ent_kb_id_ == "Q2"
# Test individual and doc-wise candidate generation. # Test individual and doc-wise candidate generation.
test_reconfigured_el(False, text) test_reconfigured_el(False, text)