Pass cfg through parser, and have is_valid default to 1, not 0 when resetting state

This commit is contained in:
Matthew Honnibal 2016-11-25 09:00:21 -06:00
parent cc7e607a8a
commit 608d8f5421
1 changed files with 3 additions and 3 deletions

View File

@ -75,11 +75,11 @@ cdef class ParserModel(AveragedPerceptron):
cdef class Parser:
@classmethod
def load(cls, path, Vocab vocab, TransitionSystem=None, require=False):
def load(cls, path, Vocab vocab, TransitionSystem=None, require=False, **cfg):
with (path / 'config.json').open() as file_:
cfg = json.load(file_)
# TODO: remove this shim when we don't have to support older data
if 'labels' in cfg:
if 'labels' in cfg and 'actions' not in cfg:
cfg['actions'] = cfg.pop('labels')
self = cls(vocab, TransitionSystem=TransitionSystem, model=None, **cfg)
if (path / 'model').exists():
@ -215,7 +215,7 @@ cdef class Parser:
loss += eg.costs[eg.guess]
eg.fill_scores(0, eg.nr_class)
eg.fill_costs(0, eg.nr_class)
eg.fill_is_valid(0, eg.nr_class)
eg.fill_is_valid(1, eg.nr_class)
return loss
def step_through(self, Doc doc):