diff --git a/spacy/kb/candidate.pyx b/spacy/kb/candidate.pyx index 6707d32ed..94445f27d 100644 --- a/spacy/kb/candidate.pyx +++ b/spacy/kb/candidate.pyx @@ -49,7 +49,7 @@ cdef class InMemoryCandidate(Candidate): self, kb: InMemoryLookupKB, entity_hash: int, - mention_hash: int, + alias_hash: int, entity_vector: vector[float], prior_prob: float, entity_freq: float @@ -59,9 +59,9 @@ cdef class InMemoryCandidate(Candidate): entity_id (int): Entity ID as hash that can be looked up with InMemoryKB.vocab.strings.__getitem__(). entity_freq (int): Entity frequency in KB corpus. entity_vector (List[float]): Entity embedding. - mention_hash (int): Mention hash. - prior_prob (float): Prior probability of entity for this mention. I. e. the probability that, independent of - the context, this mention - which matches one of this entity's aliases - resolves to one this entity. + alias_hash (int): Alias hash. + prior_prob (float): Prior probability of entity for this alias. I. e. the probability that, independent of + the context, this alias - which matches one of this entity's aliases - resolves to one this entity. """ super().__init__() @@ -69,7 +69,7 @@ cdef class InMemoryCandidate(Candidate): self._entity_vector = entity_vector self._prior_prob = prior_prob self._kb = kb - self._mention = mention_hash + self._mention = alias_hash self._entity_freq = entity_freq @property @@ -82,7 +82,7 @@ cdef class InMemoryCandidate(Candidate): @property def prior_prob(self) -> float: - """RETURNS (float): Prior probability that this mention, which matches one of this entity's aliases, resolves to + """RETURNS (float): Prior probability that this alias, which matches one of this entity's synonyms, resolves to this entity.""" return self._prior_prob diff --git a/spacy/kb/kb_in_memory.pyx b/spacy/kb/kb_in_memory.pyx index e3b9dfcb3..c9ced8309 100644 --- a/spacy/kb/kb_in_memory.pyx +++ b/spacy/kb/kb_in_memory.pyx @@ -245,7 +245,7 @@ cdef class InMemoryLookupKB(KnowledgeBase): InMemoryCandidate( kb=self, entity_hash=self._entries[entry_index].entity_hash, - mention_hash=alias_hash, + alias_hash=alias_hash, entity_vector=self._vectors_table[self._entries[entry_index].vector_index], prior_prob=prior_prob, entity_freq=self._entries[entry_index].freq diff --git a/website/docs/api/kb.mdx b/website/docs/api/kb.mdx index e3b699140..9536a3fe3 100644 --- a/website/docs/api/kb.mdx +++ b/website/docs/api/kb.mdx @@ -175,11 +175,11 @@ Restore the state of the knowledge base from a given directory. Note that the ## InMemoryCandidate {id="candidate",tag="class"} -An `InMemoryCandidate` object refers to a textual mention (alias) that may or may -not be resolved to a specific entity from a `KnowledgeBase`. This will be used -as input for the entity linking algorithm which will disambiguate the various -candidates to the correct one. Each candidate `(alias, entity)` pair is assigned -to a certain prior probability. +An `InMemoryCandidate` object refers to a textual mention (alias) that may or +may not be resolved to a specific entity from a `KnowledgeBase`. This will be +used as input for the entity linking algorithm which will disambiguate the +various candidates to the correct one. Each candidate `(alias, entity)` pair is +assigned to a certain prior probability. ### InMemoryCandidate.\_\_init\_\_ {id="candidate-init",tag="method"} @@ -190,19 +190,19 @@ of the [`entity_linker`](/api/entitylinker) pipe. > #### Example```python > > from spacy.kb import InMemoryCandidate candidate = InMemoryCandidate(kb, -> entity_hash, entity_freq, entity_vector, mention_hash, prior_prob) +> entity_hash, entity_freq, entity_vector, alias_hash, prior_prob) > > ``` > > ``` -| Name | Description | -| -------------- | ------------------------------------------------------------------------- | -| `kb` | The knowledge base that defined this candidate. ~~KnowledgeBase~~ | -| `entity_hash` | The hash of the entity's KB ID. ~~int~~ | -| `entity_freq` | The entity frequency as recorded in the KB. ~~float~~ | -| `mention_hash` | The hash of the textual mention. ~~int~~ | -| `prior_prob` | The prior probability of the `alias` referring to the `entity`. ~~float~~ | +| Name | Description | +| ------------- | ------------------------------------------------------------------------- | +| `kb` | The knowledge base that defined this candidate. ~~KnowledgeBase~~ | +| `entity_hash` | The hash of the entity's KB ID. ~~int~~ | +| `entity_freq` | The entity frequency as recorded in the KB. ~~float~~ | +| `alias_hash` | The hash of the entity alias. ~~int~~ | +| `prior_prob` | The prior probability of the `alias` referring to the `entity`. ~~float~~ | ## InMemoryCandidate attributes {id="candidate-attributes"}