Fix serialization when empty parser model. Closes
@@ -531,7 +531,7 @@ cdef class Parser:
def to_disk(self, path, **exclude):
serializers = {
- 'model': lambda p: self.model.to_disk(p),
+ 'model': lambda p: (self.model.to_disk(p) if self.model is not True else True),
'vocab': lambda p: self.vocab.to_disk(p),
'moves': lambda p: self.moves.to_disk(p, strings=False),
'cfg': lambda p: p.open('w').write(json_dumps(self.cfg))
@@ -560,7 +560,7 @@ cdef class Parser:
def to_bytes(self, **exclude):
serializers = OrderedDict((
- ('model', lambda: self.model.to_bytes()),
+ ('model', lambda: (self.model.to_bytes() if self.model is not True else True)),
('vocab', lambda: self.vocab.to_bytes()),
('moves', lambda: self.moves.to_bytes(strings=False)),
('cfg', lambda: json.dumps(self.cfg, indent=2, sort_keys=True))
