From c4a81a47a484ed3db7e2feb892cf9f2e21f29378 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 23 Jul 2017 14:11:07 +0200 Subject: [PATCH] Fix deserialization --- spacy/pipeline.pyx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spacy/pipeline.pyx b/spacy/pipeline.pyx index 41aefdd59..d48cae26d 100644 --- a/spacy/pipeline.pyx +++ b/spacy/pipeline.pyx @@ -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'