From b14b9b096bff69c73e4646e694114f2486b21bc4 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 26 Sep 2016 18:48:03 +0200 Subject: [PATCH] Return None if /deps directory not present, instead of trying to load the parser. --- spacy/language.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spacy/language.py b/spacy/language.py index 8f50efd4c..46f9009cc 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -96,14 +96,20 @@ class BaseDefaults(object): def Parser(self, vocab): if self.path: - return Parser.load(self.path / 'deps', vocab, ArcEager) + if (self.path / 'deps').exists(): + return Parser.load(self.path / 'deps', vocab, ArcEager) + else: + return None else: return Parser.blank(vocab, ArcEager, features=self.parser_features, labels=self.parser_labels) def Entity(self, vocab): - if self.path and (self.path / 'ner').exists(): - return Parser.load(self.path / 'ner', vocab, BiluoPushDown) + if self.path: + if (self.path / 'ner').exists(): + return Parser.load(self.path / 'ner', vocab, BiluoPushDown) + else: + return None else: return Parser.blank(vocab, BiluoPushDown, features=self.entity_features, labels=self.entity_labels)