mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-12 02:06:31 +03:00
Fix deserialization
This commit is contained in:
parent
2df563ad24
commit
c4a81a47a4
|
@ -120,12 +120,19 @@ class BaseThincComponent(object):
|
|||
deserialize = OrderedDict((
|
||||
('model', lambda p: self.model.from_bytes(p.open('rb').read())),
|
||||
('vocab', lambda p: self.vocab.from_disk(p)),
|
||||
('cfg', lambda p: self.cfg.update(ujson.load(p.open()))),
|
||||
('cfg', lambda p: self.cfg.update(_load_cfg(p)))
|
||||
))
|
||||
util.from_disk(path, deserialize, exclude)
|
||||
return self
|
||||
|
||||
|
||||
def _load_cfg(path):
|
||||
if path.exists():
|
||||
return ujson.load(path.open())
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
class TokenVectorEncoder(BaseThincComponent):
|
||||
"""Assign position-sensitive vectors to tokens, using a CNN or RNN."""
|
||||
name = 'tensorizer'
|
||||
|
|
Loading…
Reference in New Issue
Block a user