mirror of https://github.com/explosion/spaCy.git
Fixes for serialization
This commit is contained in:
parent
920887f4e4
commit
59f355d525
|
@ -437,7 +437,7 @@ class Language(object):
|
||||||
if not hasattr(proc, 'to_bytes'):
|
if not hasattr(proc, 'to_bytes'):
|
||||||
continue
|
continue
|
||||||
serializers[proc.name] = lambda: proc.to_bytes(p, vocab=False)
|
serializers[proc.name] = lambda: proc.to_bytes(p, vocab=False)
|
||||||
return util.to_bytes(serializers)
|
return util.to_bytes(serializers, {})
|
||||||
|
|
||||||
def from_bytes(self, bytes_data, disable=[]):
|
def from_bytes(self, bytes_data, disable=[]):
|
||||||
"""Load state from a binary string.
|
"""Load state from a binary string.
|
||||||
|
@ -459,7 +459,7 @@ class Language(object):
|
||||||
if not hasattr(proc, 'to_disk'):
|
if not hasattr(proc, 'to_disk'):
|
||||||
continue
|
continue
|
||||||
deserializers[proc.name] = lambda b: proc.from_bytes(b, vocab=False)
|
deserializers[proc.name] = lambda b: proc.from_bytes(b, vocab=False)
|
||||||
util.from_bytes(deserializers, bytes_data)
|
util.from_bytes(deserializers, bytes_data, {})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -652,8 +652,9 @@ cdef class Parser:
|
||||||
if 'model' not in exclude:
|
if 'model' not in exclude:
|
||||||
path = util.ensure_path(path)
|
path = util.ensure_path(path)
|
||||||
if self.model is True:
|
if self.model is True:
|
||||||
self.model = self.Model(**self.cfg)
|
self.model, cfg = self.Model(**self.cfg)
|
||||||
util.model_from_disk(self.model, path / 'model')
|
util.model_from_disk(self.model, path / 'model')
|
||||||
|
self.cfg.update(cfg)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def to_bytes(self, **exclude):
|
def to_bytes(self, **exclude):
|
||||||
|
@ -675,9 +676,9 @@ cdef class Parser:
|
||||||
msg = util.from_bytes(bytes_data, deserializers, exclude)
|
msg = util.from_bytes(bytes_data, deserializers, exclude)
|
||||||
if 'model' not in exclude:
|
if 'model' not in exclude:
|
||||||
if self.model is True:
|
if self.model is True:
|
||||||
print(msg['cfg'])
|
self.model, cfg = self.Model(self.moves.n_moves)
|
||||||
self.model = self.Model(self.moves.n_moves)
|
|
||||||
util.model_from_bytes(self.model, msg['model'])
|
util.model_from_bytes(self.model, msg['model'])
|
||||||
|
self.cfg.update(cfg)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue