From 4884b2c113f1b729f8602adf617cb15dd2c501b6 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 15 Apr 2017 16:00:28 +0200 Subject: [PATCH] Refix StepwiseState --- spacy/syntax/parser.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index b3281fe14..872677842 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -366,11 +366,11 @@ cdef class Parser: def add_label(self, label): # Doesn't set label into serializer -- subclasses override it to do that. for action in self.moves.action_types: - self.moves.add_action(action, label) - if 'actions' in self.cfg: + added = self.moves.add_action(action, label) + if added: # Important that the labels be stored as a list! We need the # order, or the model goes out of synch - self.cfg['actions'].setdefault(str(action), []).append(label) + self.cfg.setdefault('extra_labels', []).append(label) cdef class StepwiseState: @@ -385,11 +385,11 @@ cdef class StepwiseState: self.doc = doc if gold is not None: self.gold = gold + self.parser.moves.preprocess_gold(self.gold) else: self.gold = GoldParse(doc) self.stcls = StateClass.init(doc.c, doc.length) self.parser.moves.initialize_state(self.stcls.c) - self.parser.moves.preprocess_gold(gold) self.eg = Example( nr_class=self.parser.moves.n_moves, nr_atom=CONTEXT_SIZE,