From 78498a072de1104baefe0e5b075303d24a7828f6 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 6 Aug 2017 14:16:36 +0200 Subject: [PATCH] Return Transition for missing actions in lookup_action --- spacy/syntax/arc_eager.pyx | 1 + spacy/syntax/transition_system.pyx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index 29e8de0aa..9477449a5 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -385,6 +385,7 @@ cdef class ArcEager(TransitionSystem): for i in range(self.n_moves): if self.c[i].move == move and self.c[i].label == label: return self.c[i] + return Transition(clas=0, move=MISSING, label=0) def move_name(self, int move, attr_t label): label_str = self.strings[label] diff --git a/spacy/syntax/transition_system.pyx b/spacy/syntax/transition_system.pyx index 27b375bba..d3f64f827 100644 --- a/spacy/syntax/transition_system.pyx +++ b/spacy/syntax/transition_system.pyx @@ -107,6 +107,8 @@ cdef class TransitionSystem: def is_valid(self, StateClass stcls, move_name): action = self.lookup_transition(move_name) + if action.move == 0: + return False return action.is_valid(stcls.c, action.label) cdef int set_valid(self, int* is_valid, const StateC* st) nogil: