This commit is contained in:
Raphael Mitsch 2024-02-19 10:25:35 +01:00
parent ca1f86ebb9
commit 79798c0181
2 changed files with 8 additions and 3 deletions

View File

@ -138,7 +138,9 @@ def get_candidates(kb: KnowledgeBase, mention: Span) -> Iterable[Candidate]:
mention (Span): Entity mention.
RETURNS (Iterable[Candidate]): Identified candidates for specified mention.
"""
return next(next(get_candidates_v2(kb, iter([SpanGroup(mention.doc, spans=[mention])])))[0])
return next(
next(get_candidates_v2(kb, iter([SpanGroup(mention.doc, spans=[mention])])))[0]
)
def get_candidates_v2(

View File

@ -453,10 +453,13 @@ def test_candidate_generation(nlp):
mykb.add_alias(alias="adam", entities=["Q2"], probabilities=[0.9])
# test the size of the relevant candidates
adam_ent_cands = next(get_candidates_v2(mykb, SpanGroup(doc=doc, spans=[adam_ent])))[0]
adam_ent_cands = next(
get_candidates_v2(mykb, SpanGroup(doc=doc, spans=[adam_ent]))
)[0]
assert len(adam_ent_cands) == 1
assert (
len(next(get_candidates_v2(mykb, SpanGroup(doc=doc, spans=[douglas_ent])))[0]) == 2
len(next(get_candidates_v2(mykb, SpanGroup(doc=doc, spans=[douglas_ent])))[0])
== 2
)
assert (
len(next(get_candidates_v2(mykb, SpanGroup(doc=doc, spans=[Adam_ent])))[0]) == 0