* Fix resource loading for Matcher

This commit is contained in:
Matthew Honnibal 2015-12-31 02:45:12 +01:00
parent 55bcdf8bdd
commit 029136a007

View File

@ -172,9 +172,9 @@ cdef class Matcher:
@classmethod
def load(cls, pkg_or_str_or_file, Vocab vocab):
package = Package.create_or_return(pkg_or_str_or_file)
patterns = package.load_utf8(json.load,
'vocab', 'gazetteer.json',
default={}) # TODO: really optional?
with package.open(('vocab', 'serializer.json'), default=None) as file_:
patterns = json.load(file_) if file_ is not None else {}
return cls(vocab, patterns)
def __init__(self, vocab, patterns):