Use type alias.

This commit is contained in:
Raphael Mitsch 2024-02-01 12:36:41 +01:00
parent c8691a27d6
commit f169614c53
3 changed files with 7 additions and 2 deletions

View File

@ -5,7 +5,6 @@ from libc.stdint cimport int64_t
from ..vocab cimport Vocab from ..vocab cimport Vocab
cdef class KnowledgeBase: cdef class KnowledgeBase:
cdef Pool mem cdef Pool mem
cdef readonly Vocab vocab cdef readonly Vocab vocab

View File

@ -9,6 +9,8 @@ from ..errors import Errors
from ..tokens import SpanGroup from ..tokens import SpanGroup
from ..util import SimpleFrozenList from ..util import SimpleFrozenList
from .candidate import Candidate from .candidate import Candidate
from .typedefs import CandidatesForMention
cdef class KnowledgeBase: cdef class KnowledgeBase:
@ -32,7 +34,7 @@ cdef class KnowledgeBase:
self.entity_vector_length = entity_vector_length self.entity_vector_length = entity_vector_length
self.mem = Pool() self.mem = Pool()
def get_candidates(self, mentions: Iterator[SpanGroup]) -> Iterator[Iterable[Iterable[Candidate]]]: def get_candidates(self, mentions: Iterator[SpanGroup]) -> Iterator[Iterable[CandidatesForMention]]:
""" """
Return candidate entities for a specified Span mention. Each candidate defines at least the entity and the Return candidate entities for a specified Span mention. Each candidate defines at least the entity and the
entity's embedding vector. Depending on the KB implementation, further properties - such as the prior entity's embedding vector. Depending on the KB implementation, further properties - such as the prior

4
spacy/kb/typedefs.pxd Normal file
View File

@ -0,0 +1,4 @@
from .candidate import Candidate
from typing import Iterable
ctypedef Iterable[Candidate] CandidatesForMention