Fix defaults for Parser and Entity, adding a blank= argument.

This commit is contained in:
Matthew Honnibal 2016-09-30 19:56:06 +02:00
parent d61feffe24
commit eceeaefe53
1 changed files with 12 additions and 14 deletions

View File

@ -94,25 +94,23 @@ class BaseDefaults(object):
else: else:
return Tagger.blank(vocab, Tagger.default_templates()) return Tagger.blank(vocab, Tagger.default_templates())
def Parser(self, vocab): def Parser(self, vocab, blank=False):
if self.path: if blank:
if (self.path / 'deps').exists():
return Parser.load(self.path / 'deps', vocab, ArcEager)
else:
return None
else:
return Parser.blank(vocab, ArcEager, return Parser.blank(vocab, ArcEager,
features=self.parser_features, labels=self.parser_labels) features=self.parser_features, labels=self.parser_labels)
elif self.path and (self.path / 'deps').exists():
def Entity(self, vocab): return Parser.load(self.path / 'deps', vocab, ArcEager)
if self.path:
if (self.path / 'ner').exists():
return Parser.load(self.path / 'ner', vocab, BiluoPushDown)
else:
return None
else: else:
return None
def Entity(self, vocab, blank=False):
if blank:
return Parser.blank(vocab, BiluoPushDown, return Parser.blank(vocab, BiluoPushDown,
features=self.entity_features, labels=self.entity_labels) features=self.entity_features, labels=self.entity_labels)
elif self.path and (self.path / 'ner').exists():
return Parser.load(self.path / 'ner', vocab, BiluoPushDown)
else:
return None
def Matcher(self, vocab): def Matcher(self, vocab):
if self.path: if self.path: