mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-11 12:18:04 +03:00
unit test on number of candidates generated
This commit is contained in:
parent
0ff4ce6c59
commit
34969dddeb
|
@ -63,3 +63,20 @@ def test_kb_invalid_combination():
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
mykb.add_alias(alias="douglassss", entities=["Q2", "Q3"], probabilities=[0.3, 0.4, 0.1])
|
mykb.add_alias(alias="douglassss", entities=["Q2", "Q3"], probabilities=[0.3, 0.4, 0.1])
|
||||||
|
|
||||||
|
|
||||||
|
def test_candidate_generation():
|
||||||
|
"""Test correct candidate generation"""
|
||||||
|
mykb = KnowledgeBase()
|
||||||
|
|
||||||
|
# adding entities
|
||||||
|
mykb.add_entity(entity_id="Q1", prob=0.9)
|
||||||
|
mykb.add_entity(entity_id="Q2", prob=0.2)
|
||||||
|
mykb.add_entity(entity_id="Q3", prob=0.5)
|
||||||
|
|
||||||
|
# adding aliases
|
||||||
|
mykb.add_alias(alias="douglas", entities=["Q2", "Q3"], probabilities=[0.8, 0.2])
|
||||||
|
mykb.add_alias(alias="adam", entities=["Q2"], probabilities=[0.9])
|
||||||
|
|
||||||
|
# test the size of the relevant candidates
|
||||||
|
assert(len(mykb.get_candidates("douglas")) == 2)
|
||||||
|
assert(len(mykb.get_candidates("adam")) == 1)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user