From 8f31d3b86437da9e2a2afaa2d854128fe07d1147 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Thu, 28 May 2015 23:38:19 +0200 Subject: [PATCH] * Relax constraint on Break transition for non-monotonic parsing. --- spacy/syntax/arc_eager.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index 8de4b8a74..3935fa917 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -407,8 +407,13 @@ cdef inline bint _can_break(const State* s) nogil: return False elif at_eol(s): return False + elif NON_MONOTONIC: + return True else: - # If stack is disconnected, cannot break + # In the Break transition paper, they have this constraint that prevents + # Break if stack is disconnected. But, if we're doing non-monotonic parsing, + # we prefer to relax this constraint. This is helpful in parsing whole + # documents, because then we don't get stuck with words on the stack. seen_headless = False for i in range(s.stack_len): if s.sent[s.stack[-i]].head == 0: