From 6a30df3039af389cb4bd43826a4aad65627699ca Mon Sep 17 00:00:00 2001 From: Raphael Mitsch Date: Tue, 29 Nov 2022 23:03:03 +0100 Subject: [PATCH] Fix newly introduced bug in EntityLinker.predict(). --- spacy/pipeline/entity_linker.py | 2 +- spacy/tests/pipeline/test_entity_linker.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index ed9d79da5..9df8c357c 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -529,7 +529,7 @@ class EntityLinker(TrainablePipe): # set all prior probabilities to 0 if incl_prior=False 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 ] ) diff --git a/spacy/tests/pipeline/test_entity_linker.py b/spacy/tests/pipeline/test_entity_linker.py index 7ef155bfb..4997631f3 100644 --- a/spacy/tests/pipeline/test_entity_linker.py +++ b/spacy/tests/pipeline/test_entity_linker.py @@ -496,7 +496,7 @@ def test_el_pipe_configuration(nlp): doc = nlp(text) assert doc[0].ent_kb_id_ == "NIL" 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. @@ -540,9 +540,9 @@ def test_el_pipe_configuration(nlp): ) _entity_linker.set_kb(create_kb) _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[2].ent_kb_id_ in ("Q2", "Q3") + assert _doc[2].ent_kb_id_ == "Q2" # Test individual and doc-wise candidate generation. test_reconfigured_el(False, text)