diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index 845e7cb17..2bd4da6cc 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -287,10 +287,6 @@ cdef class ArcEager(TransitionSystem): RIGHT: {}, LEFT: {}, BREAK: {'ROOT': True}}) - for label in kwargs.get('labels', []): - if label.upper() != 'ROOT': - actions[LEFT][label] = True - actions[RIGHT][label] = True for label in kwargs.get('left_labels', []): if label.upper() != 'ROOT': actions[LEFT][label] = True diff --git a/spacy/syntax/parser.pyx b/spacy/syntax/parser.pyx index 4cfa66214..85407b942 100644 --- a/spacy/syntax/parser.pyx +++ b/spacy/syntax/parser.pyx @@ -78,6 +78,9 @@ cdef class Parser: def load(cls, path, Vocab vocab, TransitionSystem=None, require=False): 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: + cfg['actions'] = cfg.pop('labels') self = cls(vocab, TransitionSystem=TransitionSystem, model=None, **cfg) if (path / 'model').exists(): self.model.load(str(path / 'model')) @@ -188,8 +191,8 @@ cdef class Parser: free(eg.is_valid) return 0 - def update(self, Doc tokens, raw_gold): - cdef GoldParse gold = self.preprocess_gold(raw_gold) + def update(self, Doc tokens, GoldParse gold): + self.moves.preprocess_gold(gold) cdef StateClass stcls = StateClass.init(tokens.c, tokens.length) self.moves.initialize_state(stcls.c) cdef Pool mem = Pool() @@ -226,15 +229,6 @@ cdef class Parser: for action in self.moves.action_types: self.moves.add_action(action, label) - def preprocess_gold(self, raw_gold): - cdef GoldParse gold - if isinstance(raw_gold, GoldParse): - gold = raw_gold - self.moves.preprocess_gold(raw_gold) - return gold - else: - raise ValueError("Parser.preprocess_gold requires GoldParse-type input.") - cdef class StepwiseState: cdef readonly StateClass stcls