diff --git a/spacy/kb/kb_in_memory.pyx b/spacy/kb/kb_in_memory.pyx index b93fa5a4d..8a444d6e7 100644 --- a/spacy/kb/kb_in_memory.pyx +++ b/spacy/kb/kb_in_memory.pyx @@ -228,7 +228,7 @@ cdef class InMemoryLookupKB(KnowledgeBase): def get_candidates(self, mentions: Iterator[SpanGroup]) -> Iterator[Iterable[Iterable[InMemoryCandidate]]]: for mentions_for_doc in mentions: - yield [self.get_alias_candidates(ent_span.text) for ent_span in mentions_for_doc] + yield [self._get_alias_candidates(ent_span.text) for ent_span in mentions_for_doc] def _get_alias_candidates(self, str alias) -> Iterable[InMemoryCandidate]: """ diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index e8ea9eb94..77c1017b5 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -521,12 +521,12 @@ class EntityLinker(TrainablePipe): ) elif len(candidates) == 1 and self.threshold is None: # shortcut for efficiency reasons: take the 1 candidate - final_kb_ids.append(candidates[0].entity_) + final_kb_ids.append(candidates[0].entity_id_) self._add_activations( doc_scores=doc_scores, doc_ents=doc_ents, scores=[1.0], - ents=[candidates[0].entity], + ents=[candidates[0].entity_id], ) else: random.shuffle(candidates) @@ -558,7 +558,7 @@ class EntityLinker(TrainablePipe): raise ValueError(Errors.E161) scores = prior_probs + sims - (prior_probs * sims) final_kb_ids.append( - candidates[scores.argmax().item()].entity_ + candidates[scores.argmax().item()].entity_id_ if self.threshold is None or scores.max() >= self.threshold else EntityLinker.NIL ) @@ -566,7 +566,7 @@ class EntityLinker(TrainablePipe): doc_scores=doc_scores, doc_ents=doc_ents, scores=scores, - ents=[c.entity for c in candidates], + ents=[c.entity_id for c in candidates], ) self._add_doc_activations( diff --git a/spacy/tests/pipeline/test_entity_linker.py b/spacy/tests/pipeline/test_entity_linker.py index 406bfc841..fbbe8d16f 100644 --- a/spacy/tests/pipeline/test_entity_linker.py +++ b/spacy/tests/pipeline/test_entity_linker.py @@ -512,7 +512,7 @@ def test_el_pipe_configuration(nlp): def get_lowercased_candidates(kb: InMemoryLookupKB, mentions: Iterator[SpanGroup]): for mentions_for_doc in mentions: yield [ - kb.get_alias_candidates(ent_span.text.lower()) + kb._get_alias_candidates(ent_span.text.lower()) for ent_span in mentions_for_doc ] diff --git a/website/docs/usage/v3.mdx b/website/docs/usage/v3.mdx index 7e7548d6a..df0724bba 100644 --- a/website/docs/usage/v3.mdx +++ b/website/docs/usage/v3.mdx @@ -594,7 +594,6 @@ Note that spaCy v3.0 now requires **Python 3.6+**. | `GoldParse` | [`Example`](/api/example) | | `GoldCorpus` | [`Corpus`](/api/corpus) | | `KnowledgeBase.load_bulk`, `KnowledgeBase.dump` | [`KnowledgeBase.from_disk`](/api/kb#from_disk), [`KnowledgeBase.to_disk`](/api/kb#to_disk) | -| `KnowledgeBase.get_candidates` | [`KnowledgeBase.get_alias_candidates`](/api/kb#get_alias_candidates) | | `Matcher.pipe`, `PhraseMatcher.pipe` | not needed | | `gold.offsets_from_biluo_tags`, `gold.spans_from_biluo_tags`, `gold.biluo_tags_from_offsets` | [`training.biluo_tags_to_offsets`](/api/top-level#biluo_tags_to_offsets), [`training.biluo_tags_to_spans`](/api/top-level#biluo_tags_to_spans), [`training.offsets_to_biluo_tags`](/api/top-level#offsets_to_biluo_tags) | | `spacy init-model` | [`spacy init vectors`](/api/cli#init-vectors) |