mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 01:04:34 +03:00
test corner cases
This commit is contained in:
parent
9f8c1e71a2
commit
76184374e2
|
@ -191,7 +191,7 @@ cdef class KnowledgeBase:
|
||||||
|
|
||||||
def get_candidates(self, unicode alias):
|
def get_candidates(self, unicode alias):
|
||||||
cdef hash_t alias_hash = self.vocab.strings[alias]
|
cdef hash_t alias_hash = self.vocab.strings[alias]
|
||||||
alias_index = <int64_t>self._alias_index.get(alias_hash) # TODO: check for error? unit test !
|
alias_index = <int64_t>self._alias_index.get(alias_hash)
|
||||||
alias_entry = self._aliases_table[alias_index]
|
alias_entry = self._aliases_table[alias_index]
|
||||||
|
|
||||||
return [Candidate(kb=self,
|
return [Candidate(kb=self,
|
||||||
|
@ -219,7 +219,6 @@ cdef class KnowledgeBase:
|
||||||
cdef hash_t alias_hash = self.vocab.strings[alias]
|
cdef hash_t alias_hash = self.vocab.strings[alias]
|
||||||
cdef hash_t entity_hash = self.vocab.strings[entity]
|
cdef hash_t entity_hash = self.vocab.strings[entity]
|
||||||
|
|
||||||
# TODO: error ?
|
|
||||||
if entity_hash not in self._entry_index or alias_hash not in self._alias_index:
|
if entity_hash not in self._entry_index or alias_hash not in self._alias_index:
|
||||||
return 0.0
|
return 0.0
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ def test_kb_valid_entities(nlp):
|
||||||
# test retrieval of prior probabilities
|
# test retrieval of prior probabilities
|
||||||
assert_almost_equal(mykb.get_prior_prob(entity="Q2", alias="douglas"), 0.8)
|
assert_almost_equal(mykb.get_prior_prob(entity="Q2", alias="douglas"), 0.8)
|
||||||
assert_almost_equal(mykb.get_prior_prob(entity="Q3", alias="douglas"), 0.2)
|
assert_almost_equal(mykb.get_prior_prob(entity="Q3", alias="douglas"), 0.2)
|
||||||
|
assert_almost_equal(mykb.get_prior_prob(entity="Q342", alias="douglas"), 0.0)
|
||||||
|
assert_almost_equal(mykb.get_prior_prob(entity="Q3", alias="douglassssss"), 0.0)
|
||||||
|
|
||||||
|
|
||||||
def test_kb_invalid_entities(nlp):
|
def test_kb_invalid_entities(nlp):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user