Fix merge leftovers.

This commit is contained in:
Raphael Mitsch 2023-03-20 10:31:11 +01:00
parent 73bdeb01e4
commit cb79af3a10
4 changed files with 6 additions and 7 deletions

View File

@ -228,7 +228,7 @@ cdef class InMemoryLookupKB(KnowledgeBase):
def get_candidates(self, mentions: Iterator[SpanGroup]) -> Iterator[Iterable[Iterable[InMemoryCandidate]]]: def get_candidates(self, mentions: Iterator[SpanGroup]) -> Iterator[Iterable[Iterable[InMemoryCandidate]]]:
for mentions_for_doc in mentions: for mentions_for_doc in mentions:
yield [self.get_alias_candidates(ent_span.text) for ent_span in mentions_for_doc] yield [self._get_alias_candidates(ent_span.text) for ent_span in mentions_for_doc]
def _get_alias_candidates(self, str alias) -> Iterable[InMemoryCandidate]: def _get_alias_candidates(self, str alias) -> Iterable[InMemoryCandidate]:
""" """

View File

@ -521,12 +521,12 @@ class EntityLinker(TrainablePipe):
) )
elif len(candidates) == 1 and self.threshold is None: elif len(candidates) == 1 and self.threshold is None:
# shortcut for efficiency reasons: take the 1 candidate # shortcut for efficiency reasons: take the 1 candidate
final_kb_ids.append(candidates[0].entity_) final_kb_ids.append(candidates[0].entity_id_)
self._add_activations( self._add_activations(
doc_scores=doc_scores, doc_scores=doc_scores,
doc_ents=doc_ents, doc_ents=doc_ents,
scores=[1.0], scores=[1.0],
ents=[candidates[0].entity], ents=[candidates[0].entity_id],
) )
else: else:
random.shuffle(candidates) random.shuffle(candidates)
@ -558,7 +558,7 @@ class EntityLinker(TrainablePipe):
raise ValueError(Errors.E161) raise ValueError(Errors.E161)
scores = prior_probs + sims - (prior_probs * sims) scores = prior_probs + sims - (prior_probs * sims)
final_kb_ids.append( final_kb_ids.append(
candidates[scores.argmax().item()].entity_ candidates[scores.argmax().item()].entity_id_
if self.threshold is None or scores.max() >= self.threshold if self.threshold is None or scores.max() >= self.threshold
else EntityLinker.NIL else EntityLinker.NIL
) )
@ -566,7 +566,7 @@ class EntityLinker(TrainablePipe):
doc_scores=doc_scores, doc_scores=doc_scores,
doc_ents=doc_ents, doc_ents=doc_ents,
scores=scores, scores=scores,
ents=[c.entity for c in candidates], ents=[c.entity_id for c in candidates],
) )
self._add_doc_activations( self._add_doc_activations(

View File

@ -512,7 +512,7 @@ def test_el_pipe_configuration(nlp):
def get_lowercased_candidates(kb: InMemoryLookupKB, mentions: Iterator[SpanGroup]): def get_lowercased_candidates(kb: InMemoryLookupKB, mentions: Iterator[SpanGroup]):
for mentions_for_doc in mentions: for mentions_for_doc in mentions:
yield [ yield [
kb.get_alias_candidates(ent_span.text.lower()) kb._get_alias_candidates(ent_span.text.lower())
for ent_span in mentions_for_doc for ent_span in mentions_for_doc
] ]

View File

@ -594,7 +594,6 @@ Note that spaCy v3.0 now requires **Python 3.6+**.
| `GoldParse` | [`Example`](/api/example) | | `GoldParse` | [`Example`](/api/example) |
| `GoldCorpus` | [`Corpus`](/api/corpus) | | `GoldCorpus` | [`Corpus`](/api/corpus) |
| `KnowledgeBase.load_bulk`, `KnowledgeBase.dump` | [`KnowledgeBase.from_disk`](/api/kb#from_disk), [`KnowledgeBase.to_disk`](/api/kb#to_disk) | | `KnowledgeBase.load_bulk`, `KnowledgeBase.dump` | [`KnowledgeBase.from_disk`](/api/kb#from_disk), [`KnowledgeBase.to_disk`](/api/kb#to_disk) |
| `KnowledgeBase.get_candidates` | [`KnowledgeBase.get_alias_candidates`](/api/kb#get_alias_candidates) |
| `Matcher.pipe`, `PhraseMatcher.pipe` | not needed | | `Matcher.pipe`, `PhraseMatcher.pipe` | not needed |
| `gold.offsets_from_biluo_tags`, `gold.spans_from_biluo_tags`, `gold.biluo_tags_from_offsets` | [`training.biluo_tags_to_offsets`](/api/top-level#biluo_tags_to_offsets), [`training.biluo_tags_to_spans`](/api/top-level#biluo_tags_to_spans), [`training.offsets_to_biluo_tags`](/api/top-level#offsets_to_biluo_tags) | | `gold.offsets_from_biluo_tags`, `gold.spans_from_biluo_tags`, `gold.biluo_tags_from_offsets` | [`training.biluo_tags_to_offsets`](/api/top-level#biluo_tags_to_offsets), [`training.biluo_tags_to_spans`](/api/top-level#biluo_tags_to_spans), [`training.offsets_to_biluo_tags`](/api/top-level#offsets_to_biluo_tags) |
| `spacy init-model` | [`spacy init vectors`](/api/cli#init-vectors) | | `spacy init-model` | [`spacy init vectors`](/api/cli#init-vectors) |