Mention -> alias renaming. Drop Candidate.mentions(). Drop InMemoryLookupKB.get_alias_candidates() from docs.

This commit is contained in:
Raphael Mitsch 2023-03-15 09:23:31 +01:00
parent 961795d9f1
commit 3cfc1c6acc
3 changed files with 7 additions and 26 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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.