Add __reduce__ method for PhraseMatcher

This commit is contained in:
Matthew Honnibal 2017-09-20 22:26:40 +02:00
parent cc408fc189
commit 0c93c73e49

View File

@ -422,6 +422,7 @@ cdef class PhraseMatcher:
cdef attr_t* _phrase_key
cdef public object _callbacks
cdef public object _patterns
def __init__(self, Vocab vocab, max_length=10):
self.mem = Pool()
@ -436,6 +437,9 @@ cdef class PhraseMatcher:
self.matcher.add('Candidate', None, *abstract_patterns)
self._callbacks = {}
def __reduce__(self):
return (self.__class__, (self.vocab,), None, None)
def add(self, key, on_match, *docs):
cdef Doc doc
for doc in docs: