From f6a6c39ce8aed756fc66e6a012743850eb026e23 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 8 Jul 2015 19:52:30 +0200 Subject: [PATCH] * Add warning for models not found in parser --- spacy/syntax/parser.pyx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index a8fe20a31..434bc3ca4 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -14,6 +14,7 @@ import os.path from os import path import shutil import json +import sys from cymem.cymem cimport Pool, Address from murmurhash.mrmr cimport hash64 @@ -69,7 +70,13 @@ def ParserFactory(transition_system): cdef class Parser: def __init__(self, StringStore strings, model_dir, transition_system): - assert os.path.exists(model_dir) and os.path.isdir(model_dir) + if not os.path.exists(model_dir): + print >> sys.stderr, "Warning: No model found at", model_dir + self.cfg = Config(labels=[], features=[]) + elif not os.path.isdir(model_dir): + self.cfg = Config(labels=[], features=[]) + print >> sys.stderr, "Warning: model path:", model_dir, "is not a directory" + self.cfg = Config.read(model_dir, 'config') self.moves = transition_system(strings, self.cfg.labels) templates = get_templates(self.cfg.features)