diff --git a/spacy/kb/candidate.pyx b/spacy/kb/candidate.pyx index 94445f27d..9f141b20a 100644 --- a/spacy/kb/candidate.pyx +++ b/spacy/kb/candidate.pyx @@ -31,11 +31,6 @@ cdef class Candidate: """RETURNS (str): String representation of entity ID.""" raise NotImplementedError - @property - def mention(self) -> str: - """RETURNS (str): Mention.""" - raise NotImplementedError - @property def entity_vector(self) -> vector[float]: """RETURNS (vector[float]): Entity vector.""" @@ -69,7 +64,7 @@ cdef class InMemoryCandidate(Candidate): self._entity_vector = entity_vector self._prior_prob = prior_prob self._kb = kb - self._mention = alias_hash + self._alias = alias_hash self._entity_freq = entity_freq @property @@ -87,8 +82,9 @@ cdef class InMemoryCandidate(Candidate): return self._prior_prob @property - def mention(self) -> str: - return self._kb.vocab.strings[self._mention] + def alias(self) -> str: + """RETURNS (str): Alias.""" + return self._kb.vocab.strings[self._alias] @property def entity_id_(self) -> str: diff --git a/spacy/kb/kb.pyx b/spacy/kb/kb.pyx index d10123e37..e4165301e 100644 --- a/spacy/kb/kb.pyx +++ b/spacy/kb/kb.pyx @@ -42,8 +42,9 @@ cdef class KnowledgeBase: def get_candidates(self, mention: Span) -> Iterable[Candidate]: """ - Return candidate entities for specified text. Each candidate defines the entity, the original mention, - and the prior probability of that mention resolving to that entity. + Return candidate entities for specified text. Each candidate defines at least the entity and the entity's + embedding vector. Depending on the KB implementation, further properties - such as the prior probability of the + specified mention text resolving to that entity - might be included. If the no candidate is found for a given text, an empty list is returned. mention (Span): Mention for which to get candidates. RETURNS (Iterable[Candidate]): Identified candidates. diff --git a/website/docs/api/inmemorylookupkb.mdx b/website/docs/api/inmemorylookupkb.mdx index e88e4a500..9063939a3 100644 --- a/website/docs/api/inmemorylookupkb.mdx +++ b/website/docs/api/inmemorylookupkb.mdx @@ -199,22 +199,6 @@ to you. | `mentions` | The textual mention or alias. ~~Iterable[Span]~~ | | **RETURNS** | An iterable of iterable with relevant `InMemoryCandidate` objects. ~~Iterable[Iterable[InMemoryCandidate]]~~ | -## InMemoryLookupKB.get_alias_candidates {id="get_alias_candidates",tag="method"} - -Given a certain textual mention as input, retrieve a list of candidate entities -of type [`InMemoryCandidate`](/api/kb#candidate). - -> #### Example -> -> ```python -> candidates = kb.get_alias_candidates("Douglas") -> ``` - -| Name | Description | -| ----------- | ----------------------------------------------------------------------------- | -| `alias` | The textual mention or alias. ~~str~~ | -| **RETURNS** | The list of relevant `InMemoryCandidate` objects. ~~List[InMemoryCandidate]~~ | - ## InMemoryLookupKB.get_vector {id="get_vector",tag="method"} Given a certain entity ID, retrieve its pretrained entity vector.