mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-10 16:22:29 +03:00
Update alias/mention usage in doc(strings).
This commit is contained in:
parent
be858981e6
commit
28dbed64cb
|
@ -49,7 +49,7 @@ cdef class InMemoryCandidate(Candidate):
|
||||||
self,
|
self,
|
||||||
kb: InMemoryLookupKB,
|
kb: InMemoryLookupKB,
|
||||||
entity_hash: int,
|
entity_hash: int,
|
||||||
mention_hash: int,
|
alias_hash: int,
|
||||||
entity_vector: vector[float],
|
entity_vector: vector[float],
|
||||||
prior_prob: float,
|
prior_prob: float,
|
||||||
entity_freq: 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_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_freq (int): Entity frequency in KB corpus.
|
||||||
entity_vector (List[float]): Entity embedding.
|
entity_vector (List[float]): Entity embedding.
|
||||||
mention_hash (int): Mention hash.
|
alias_hash (int): Alias hash.
|
||||||
prior_prob (float): Prior probability of entity for this mention. I. e. the probability that, independent of
|
prior_prob (float): Prior probability of entity for this alias. I. e. the probability that, independent of
|
||||||
the context, this mention - which matches one of this entity's aliases - resolves to one this entity.
|
the context, this alias - which matches one of this entity's aliases - resolves to one this entity.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ cdef class InMemoryCandidate(Candidate):
|
||||||
self._entity_vector = entity_vector
|
self._entity_vector = entity_vector
|
||||||
self._prior_prob = prior_prob
|
self._prior_prob = prior_prob
|
||||||
self._kb = kb
|
self._kb = kb
|
||||||
self._mention = mention_hash
|
self._mention = alias_hash
|
||||||
self._entity_freq = entity_freq
|
self._entity_freq = entity_freq
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -82,7 +82,7 @@ cdef class InMemoryCandidate(Candidate):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def prior_prob(self) -> float:
|
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."""
|
this entity."""
|
||||||
return self._prior_prob
|
return self._prior_prob
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ cdef class InMemoryLookupKB(KnowledgeBase):
|
||||||
InMemoryCandidate(
|
InMemoryCandidate(
|
||||||
kb=self,
|
kb=self,
|
||||||
entity_hash=self._entries[entry_index].entity_hash,
|
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],
|
entity_vector=self._vectors_table[self._entries[entry_index].vector_index],
|
||||||
prior_prob=prior_prob,
|
prior_prob=prior_prob,
|
||||||
entity_freq=self._entries[entry_index].freq
|
entity_freq=self._entries[entry_index].freq
|
||||||
|
|
|
@ -175,11 +175,11 @@ Restore the state of the knowledge base from a given directory. Note that the
|
||||||
|
|
||||||
## InMemoryCandidate {id="candidate",tag="class"}
|
## InMemoryCandidate {id="candidate",tag="class"}
|
||||||
|
|
||||||
An `InMemoryCandidate` object refers to a textual mention (alias) that may or may
|
An `InMemoryCandidate` object refers to a textual mention (alias) that may or
|
||||||
not be resolved to a specific entity from a `KnowledgeBase`. This will be used
|
may not be resolved to a specific entity from a `KnowledgeBase`. This will be
|
||||||
as input for the entity linking algorithm which will disambiguate the various
|
used as input for the entity linking algorithm which will disambiguate the
|
||||||
candidates to the correct one. Each candidate `(alias, entity)` pair is assigned
|
various candidates to the correct one. Each candidate `(alias, entity)` pair is
|
||||||
to a certain prior probability.
|
assigned to a certain prior probability.
|
||||||
|
|
||||||
### InMemoryCandidate.\_\_init\_\_ {id="candidate-init",tag="method"}
|
### InMemoryCandidate.\_\_init\_\_ {id="candidate-init",tag="method"}
|
||||||
|
|
||||||
|
@ -190,19 +190,19 @@ of the [`entity_linker`](/api/entitylinker) pipe.
|
||||||
> #### Example```python
|
> #### Example```python
|
||||||
>
|
>
|
||||||
> from spacy.kb import InMemoryCandidate candidate = InMemoryCandidate(kb,
|
> 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 |
|
| Name | Description |
|
||||||
| -------------- | ------------------------------------------------------------------------- |
|
| ------------- | ------------------------------------------------------------------------- |
|
||||||
| `kb` | The knowledge base that defined this candidate. ~~KnowledgeBase~~ |
|
| `kb` | The knowledge base that defined this candidate. ~~KnowledgeBase~~ |
|
||||||
| `entity_hash` | The hash of the entity's KB ID. ~~int~~ |
|
| `entity_hash` | The hash of the entity's KB ID. ~~int~~ |
|
||||||
| `entity_freq` | The entity frequency as recorded in the KB. ~~float~~ |
|
| `entity_freq` | The entity frequency as recorded in the KB. ~~float~~ |
|
||||||
| `mention_hash` | The hash of the textual mention. ~~int~~ |
|
| `alias_hash` | The hash of the entity alias. ~~int~~ |
|
||||||
| `prior_prob` | The prior probability of the `alias` referring to the `entity`. ~~float~~ |
|
| `prior_prob` | The prior probability of the `alias` referring to the `entity`. ~~float~~ |
|
||||||
|
|
||||||
## InMemoryCandidate attributes {id="candidate-attributes"}
|
## InMemoryCandidate attributes {id="candidate-attributes"}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user