* Make patterns argument to Matcher class optional

This commit is contained in:
Matthew Honnibal 2016-04-17 21:32:24 +02:00
parent 8b4677d34d
commit 67ce96c9c9
1 changed files with 3 additions and 3 deletions

View File

@ -163,12 +163,12 @@ cdef class Matcher:
patterns = package.load_json(('vocab', 'gazetteer.json')) patterns = package.load_json(('vocab', 'gazetteer.json'))
return cls(vocab, patterns) return cls(vocab, patterns)
def __init__(self, vocab, patterns): def __init__(self, vocab, patterns={}):
self._patterns = dict(patterns) # Make sure we own the object
self.vocab = vocab self.vocab = vocab
self.mem = Pool() self.mem = Pool()
self.vocab = vocab self.vocab = vocab
self._patterns = dict(patterns) for entity_key, (etype, attrs, specs) in sorted(self._patterns.items()):
for entity_key, (etype, attrs, specs) in sorted(patterns.items()):
self.add(entity_key, etype, attrs, specs) self.add(entity_key, etype, attrs, specs)
def __reduce__(self): def __reduce__(self):