Refactor Language, dropping Language.blank() method.

This commit is contained in:
Matthew Honnibal 2016-10-12 13:45:58 +02:00
parent 7c5fe84b80
commit 847a4a4182
1 changed files with 14 additions and 9 deletions

View File

@ -189,12 +189,6 @@ class Language(object):
Defaults = BaseDefaults
lang = None
@classmethod
def blank(cls):
return cls(path=False, vocab=False, tokenizer=False, tagger=False,
parser=False, entity=False, matcher=False, serializer=False,
vectors=False, pipeline=False)
@classmethod
@contextmanager
def train(cls, path, gold_tuples, *configs):
@ -228,11 +222,22 @@ class Language(object):
with (pos_model_dir / 'config.json').open('wb') as file_:
json.dump(tagger_cfg, file_)
self = cls.blank()
self.path = path
self.vocab = self.defaults.Vocab()
self = cls(
path=path,
vocab=False,
tokenizer=False,
tagger=False,
parser=False,
entity=False,
matcher=False,
serializer=False,
vectors=False,
pipeline=False)
self.defaults.parser_labels = parser_cfg['labels']
self.defaults.entity_labels = entity_cfg['labels']
self.vocab = self.defaults.Vocab()
self.tokenizer = self.defaults.Tokenizer(self.vocab)
self.tagger = self.defaults.Tagger(self.vocab, **tagger_cfg)
self.parser = self.defaults.Parser(self.vocab, **parser_cfg)