From 59f355d5254ad9b052de4fd4037d33efc0256fd2 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 29 May 2017 13:38:20 +0200 Subject: [PATCH] Fixes for serialization --- spacy/language.py | 4 ++-- spacy/syntax/nn_parser.pyx | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index 36ee9d8fc..6ca6947ba 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -437,7 +437,7 @@ class Language(object): if not hasattr(proc, 'to_bytes'): continue 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=[]): """Load state from a binary string. @@ -459,7 +459,7 @@ class Language(object): if not hasattr(proc, 'to_disk'): continue 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 diff --git a/spacy/syntax/nn_parser.pyx b/spacy/syntax/nn_parser.pyx index 9daa7a284..0270a6890 100644 --- a/spacy/syntax/nn_parser.pyx +++ b/spacy/syntax/nn_parser.pyx @@ -652,8 +652,9 @@ cdef class Parser: if 'model' not in exclude: path = util.ensure_path(path) 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') + self.cfg.update(cfg) return self def to_bytes(self, **exclude): @@ -675,9 +676,9 @@ cdef class Parser: msg = util.from_bytes(bytes_data, deserializers, exclude) if 'model' not in exclude: if self.model is True: - print(msg['cfg']) - self.model = self.Model(self.moves.n_moves) + self.model, cfg = self.Model(self.moves.n_moves) util.model_from_bytes(self.model, msg['model']) + self.cfg.update(cfg) return self