Return None if /deps directory not present, instead of trying to load the parser.

This commit is contained in:
Matthew Honnibal 2016-09-26 18:48:03 +02:00
parent e07b9665f7
commit b14b9b096b
1 changed files with 9 additions and 3 deletions

View File

@ -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)