diff --git a/spacy/ml/models/entity_linker.py b/spacy/ml/models/entity_linker.py index 46b4cd83f..293c3910a 100644 --- a/spacy/ml/models/entity_linker.py +++ b/spacy/ml/models/entity_linker.py @@ -118,13 +118,13 @@ def get_candidates(kb: KnowledgeBase, mention: Span) -> Iterable[Candidate]: def get_candidates_all( - kb: KnowledgeBase, mentions: Generator[Iterable[Span], None, None] + kb: KnowledgeBase, mentions: Iterator[Iterable[Span]] ) -> Iterator[Iterable[Iterable[Candidate]]]: """ Return candidate entities for the given mentions and fetching appropriate entries from the index. kb (KnowledgeBase): Knowledge base to query. - mention (Generator[Iterable[Span]]): Entity mentions per document for which to identify candidates. - RETURNS (Generator[Iterable[Iterable[Candidate]]]): Identified candidates per document. + mention (Iterator[Iterable[Span]]): Entity mentions per document for which to identify candidates. + RETURNS (Iterator[Iterable[Iterable[Candidate]]]): Identified candidates per document. """ return kb.get_candidates_all(mentions) diff --git a/spacy/pipeline/entity_linker.py b/spacy/pipeline/entity_linker.py index 5fa826383..ed9d79da5 100644 --- a/spacy/pipeline/entity_linker.py +++ b/spacy/pipeline/entity_linker.py @@ -6,7 +6,6 @@ from typing import ( Union, List, Any, - Generator, Iterator, ) from thinc.types import Floats2d @@ -88,7 +87,7 @@ def make_entity_linker( entity_vector_length: int, get_candidates: Callable[[KnowledgeBase, Span], Iterable[Candidate]], get_candidates_all: Callable[ - [KnowledgeBase, Generator[Iterable[Span], None, None]], + [KnowledgeBase, Iterator[Iterable[Span]]], Iterator[Iterable[Iterable[Candidate]]], ], generate_empty_kb: Callable[[Vocab, int], KnowledgeBase], @@ -110,11 +109,8 @@ def make_entity_linker( entity_vector_length (int): Size of encoding vectors in the KB. get_candidates (Callable[[KnowledgeBase, Span], Iterable[Candidate]]): Function that produces a list of candidates, given a certain knowledge base and a textual mention. - get_candidates_all ( - Callable[ - [KnowledgeBase, Generator[Iterable[Span], None, None]], - Iterator[Iterable[Iterable[Candidate]]] - ]): Function that produces a list of candidates per document, given a certain knowledge base and several textual + get_candidates_all (Callable[[KnowledgeBase, Iterator[Iterable[Span]]], Iterator[Iterable[Iterable[Candidate]]]]): + Function that produces a list of candidates per document, given a certain knowledge base and several textual documents with textual mentions. generate_empty_kb (Callable[[Vocab, int], KnowledgeBase]): Callable returning empty KnowledgeBase. scorer (Optional[Callable]): The scoring method. @@ -192,7 +188,7 @@ class EntityLinker(TrainablePipe): entity_vector_length: int, get_candidates: Callable[[KnowledgeBase, Span], Iterable[Candidate]], get_candidates_all: Callable[ - [KnowledgeBase, Generator[Iterable[Span], None, None]], + [KnowledgeBase, Iterator[Iterable[Span]]], Iterator[Iterable[Iterable[Candidate]]], ], generate_empty_kb: Callable[[Vocab, int], KnowledgeBase], @@ -215,12 +211,9 @@ class EntityLinker(TrainablePipe): entity_vector_length (int): Size of encoding vectors in the KB. get_candidates (Callable[[KnowledgeBase, Span], Iterable[Candidate]]): Function that produces a list of candidates, given a certain knowledge base and a textual mention. - get_candidates_all ( - Callable[ - [KnowledgeBase, Generator[Iterable[Span], None, None]], - Iterator[Iterable[Iterable[Candidate]]] - ]): Function that produces a list of candidates per document, given a certain knowledge base and several - textual documents with textual mentions. + get_candidates_all (Callable[[KnowledgeBase, Iterator[Iterable[Span]]], Iterator[Iterable[Iterable[Candidate]]]]): + Function that produces a list of candidates per document, given a certain knowledge base and several textual + documents with textual mentions. generate_empty_kb (Callable[[Vocab, int], KnowledgeBase]): Callable returning empty KnowledgeBase. scorer (Optional[Callable]): The scoring method. Defaults to Scorer.score_links. use_gold_ents (bool): Whether to copy entities from gold docs or not. If false, another