mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Fix parser serialization
This commit is contained in:
parent
e34e70673f
commit
5056743ad5
|
@ -7,6 +7,7 @@ from __future__ import unicode_literals, print_function
|
||||||
|
|
||||||
from collections import Counter, OrderedDict
|
from collections import Counter, OrderedDict
|
||||||
import ujson
|
import ujson
|
||||||
|
import json
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
from libc.math cimport exp
|
from libc.math cimport exp
|
||||||
|
@ -829,7 +830,7 @@ cdef class Parser:
|
||||||
('upper_model', lambda: self.model[2].to_bytes()),
|
('upper_model', lambda: self.model[2].to_bytes()),
|
||||||
('vocab', lambda: self.vocab.to_bytes()),
|
('vocab', lambda: self.vocab.to_bytes()),
|
||||||
('moves', lambda: self.moves.to_bytes(strings=False)),
|
('moves', lambda: self.moves.to_bytes(strings=False)),
|
||||||
('cfg', lambda: ujson.dumps(self.cfg))
|
('cfg', lambda: json.dumps(self.cfg, indent=2, sort_keys=True))
|
||||||
))
|
))
|
||||||
if 'model' in exclude:
|
if 'model' in exclude:
|
||||||
exclude['tok2vec_model'] = True
|
exclude['tok2vec_model'] = True
|
||||||
|
@ -842,7 +843,7 @@ cdef class Parser:
|
||||||
deserializers = OrderedDict((
|
deserializers = OrderedDict((
|
||||||
('vocab', lambda b: self.vocab.from_bytes(b)),
|
('vocab', lambda b: self.vocab.from_bytes(b)),
|
||||||
('moves', lambda b: self.moves.from_bytes(b, strings=False)),
|
('moves', lambda b: self.moves.from_bytes(b, strings=False)),
|
||||||
('cfg', lambda b: self.cfg.update(ujson.loads(b))),
|
('cfg', lambda b: self.cfg.update(json.loads(b))),
|
||||||
('tok2vec_model', lambda b: None),
|
('tok2vec_model', lambda b: None),
|
||||||
('lower_model', lambda b: None),
|
('lower_model', lambda b: None),
|
||||||
('upper_model', lambda b: None)
|
('upper_model', lambda b: None)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user