Implement PhraseMatcher.__contains__

This commit is contained in:
ines 2017-10-25 12:10:04 +02:00
parent 9c733a8849
commit 1262aa0bf9
1 changed files with 7 additions and 1 deletions

View File

@ -480,7 +480,13 @@ cdef class PhraseMatcher:
return len(self.phrase_ids) return len(self.phrase_ids)
def __contains__(self, key): def __contains__(self, key):
raise NotImplementedError """Check whether the matcher contains rules for a match ID.
key (unicode): The match ID.
RETURNS (bool): Whether the matcher contains rules for this match ID.
"""
cdef hash_t ent_id = self.matcher._normalize_key(key)
return ent_id in self.phrase_ids
def __reduce__(self): def __reduce__(self):
return (self.__class__, (self.vocab,), None, None) return (self.__class__, (self.vocab,), None, None)