From 9c733a884922a447ae620ab41d97c086d429c8a4 Mon Sep 17 00:00:00 2001 From: ines Date: Wed, 25 Oct 2017 12:09:56 +0200 Subject: [PATCH] Implement PhraseMatcher.__len__ --- spacy/matcher.pyx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spacy/matcher.pyx b/spacy/matcher.pyx index ea5b7e416..be9634fc9 100644 --- a/spacy/matcher.pyx +++ b/spacy/matcher.pyx @@ -471,7 +471,13 @@ cdef class PhraseMatcher: self._callbacks = {} def __len__(self): - raise NotImplementedError + """Get the number of rules added to the matcher. Note that this only + returns the number of rules (identical with the number of IDs), not the + number of individual patterns. + + RETURNS (int): The number of rules. + """ + return len(self.phrase_ids) def __contains__(self, key): raise NotImplementedError