mirror of https://github.com/explosion/spaCy.git
Fix internal keyword add/remove for numpy arrays
This commit is contained in:
parent
0d851db6d9
commit
3a4e1f5ca7
|
@ -122,7 +122,8 @@ cdef class PhraseMatcher:
|
||||||
break
|
break
|
||||||
# otherwise simply remove the key
|
# otherwise simply remove the key
|
||||||
else:
|
else:
|
||||||
current_dict[self._terminal].remove(key)
|
if key in current_dict[self._terminal]:
|
||||||
|
current_dict[self._terminal].remove(key)
|
||||||
|
|
||||||
del self._keywords[key]
|
del self._keywords[key]
|
||||||
del self._callbacks[key]
|
del self._callbacks[key]
|
||||||
|
@ -159,8 +160,7 @@ cdef class PhraseMatcher:
|
||||||
keyword = self._convert_to_array(doc)
|
keyword = self._convert_to_array(doc)
|
||||||
# keep track of keywords per key to make remove easier
|
# keep track of keywords per key to make remove easier
|
||||||
# (would use a set, but can't hash numpy arrays)
|
# (would use a set, but can't hash numpy arrays)
|
||||||
if keyword not in self._keywords[key]:
|
self._keywords[key].append(keyword)
|
||||||
self._keywords[key].append(keyword)
|
|
||||||
current_dict = self.keyword_trie_dict
|
current_dict = self.keyword_trie_dict
|
||||||
for token in keyword:
|
for token in keyword:
|
||||||
current_dict = current_dict.setdefault(token, {})
|
current_dict = current_dict.setdefault(token, {})
|
||||||
|
|
Loading…
Reference in New Issue