From 1262aa0bf9e954b9193781661f29652a97222b56 Mon Sep 17 00:00:00 2001 From: ines Date: Wed, 25 Oct 2017 12:10:04 +0200 Subject: [PATCH] Implement PhraseMatcher.__contains__ --- spacy/matcher.pyx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spacy/matcher.pyx b/spacy/matcher.pyx index be9634fc9..8b815194c 100644 --- a/spacy/matcher.pyx +++ b/spacy/matcher.pyx @@ -480,7 +480,13 @@ cdef class PhraseMatcher: return len(self.phrase_ids) 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): return (self.__class__, (self.vocab,), None, None)