From 7e0c692daf099d09e679229bda4c39c6c6e32ddb Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 18 Dec 2014 09:16:10 +1100 Subject: [PATCH] * Automatically push when the stack is empty --- spacy/syntax/_state.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/_state.pyx b/spacy/syntax/_state.pyx index 8a37a760b..b8abece8b 100644 --- a/spacy/syntax/_state.pyx +++ b/spacy/syntax/_state.pyx @@ -22,7 +22,9 @@ cdef int pop_stack(State *s) except -1: assert s.stack_len >= 1 s.stack_len -= 1 s.stack -= 1 - + if s.stack_len == 0 and not at_eol(s): + push_stack(s) + cdef int push_stack(State *s) except -1: assert s.i < s.sent_len @@ -117,4 +119,5 @@ cdef State* init_state(Pool mem, TokenC* sent, const int sent_length) except NUL s.stack_len = 0 s.i = 0 s.sent_len = sent_length + push_stack(s) return s