Fix serialization

This commit is contained in:
Matthew Honnibal 2017-11-08 13:08:48 +01:00
parent 1d5599cd28
commit c27c82d5f9

View File

@ -533,7 +533,7 @@ class Tagger(Pipe):
serialize['model'] = self.model.to_bytes serialize['model'] = self.model.to_bytes
serialize['vocab'] = self.vocab.to_bytes serialize['vocab'] = self.vocab.to_bytes
tag_map = OrderedDict(sorted(self.vocab.morphology.item())) tag_map = OrderedDict(sorted(self.vocab.morphology.tag_map.items()))
serialize['tag_map'] = lambda: msgpack.dumps( serialize['tag_map'] = lambda: msgpack.dumps(
tag_map, use_bin_type=True, encoding='utf8') tag_map, use_bin_type=True, encoding='utf8')
return util.to_bytes(serialize, exclude) return util.to_bytes(serialize, exclude)
@ -566,7 +566,7 @@ class Tagger(Pipe):
def to_disk(self, path, **exclude): def to_disk(self, path, **exclude):
self.cfg['pretrained_dims'] = self.vocab.vectors.data.shape[1] self.cfg['pretrained_dims'] = self.vocab.vectors.data.shape[1]
tag_map = OrderedDict(sorted(self.vocab.morphology.item())) tag_map = OrderedDict(sorted(self.vocab.morphology.tag_map.items()))
serialize = OrderedDict(( serialize = OrderedDict((
('vocab', lambda p: self.vocab.to_disk(p)), ('vocab', lambda p: self.vocab.to_disk(p)),
('tag_map', lambda p: p.open('wb').write(msgpack.dumps( ('tag_map', lambda p: p.open('wb').write(msgpack.dumps(