mirror of
https://github.com/explosion/spaCy.git
synced 2025-04-24 19:11:58 +03:00
Fix EL test.
This commit is contained in:
parent
77680421b4
commit
cb640abe81
|
@ -246,14 +246,18 @@ cdef class InMemoryLookupKB(KnowledgeBase):
|
|||
alias_index = <int64_t>self._alias_index.get(alias_hash)
|
||||
alias_entry = self._aliases_table[alias_index]
|
||||
|
||||
return [Candidate(retrieve_string_from_hash=self.vocab.strings.__getitem__,
|
||||
entity_hash=self._entries[entry_index].entity_hash,
|
||||
entity_freq=self._entries[entry_index].freq,
|
||||
entity_vector=self._vectors_table[self._entries[entry_index].vector_index],
|
||||
alias_hash=alias_hash,
|
||||
prior_prob=prior_prob)
|
||||
for (entry_index, prior_prob) in zip(alias_entry.entry_indices, alias_entry.probs)
|
||||
if entry_index != 0]
|
||||
return [
|
||||
Candidate(
|
||||
retrieve_string_from_hash=self.vocab.strings.__getitem__,
|
||||
entity_hash=self._entries[entry_index].entity_hash,
|
||||
entity_freq=self._entries[entry_index].freq,
|
||||
entity_vector=self._vectors_table[self._entries[entry_index].vector_index],
|
||||
alias_hash=alias_hash,
|
||||
prior_prob=prior_prob
|
||||
)
|
||||
for (entry_index, prior_prob) in zip(alias_entry.entry_indices, alias_entry.probs)
|
||||
if entry_index != 0
|
||||
]
|
||||
|
||||
def get_vector(self, str entity):
|
||||
cdef hash_t entity_hash = self.vocab.strings[entity]
|
||||
|
|
|
@ -1199,7 +1199,19 @@ def test_threshold(meet_threshold: bool, config: Dict[str, Any]):
|
|||
entity_linker = nlp.add_pipe(
|
||||
"entity_linker",
|
||||
last=True,
|
||||
config={"threshold": None if meet_threshold else 1.0, "model": config},
|
||||
config={
|
||||
**(
|
||||
{"threshold": None}
|
||||
if meet_threshold
|
||||
else {
|
||||
"threshold": 1.0,
|
||||
# Prior for candidate may be 1.0, rendering the our test setting with threshold 1.0 useless
|
||||
# otherwise.
|
||||
"incl_prior": False,
|
||||
}
|
||||
),
|
||||
"model": config,
|
||||
},
|
||||
)
|
||||
entity_linker.set_kb(create_kb) # type: ignore
|
||||
nlp.initialize(get_examples=lambda: train_examples)
|
||||
|
|
Loading…
Reference in New Issue
Block a user