From 6c47b10a6ef3232e3077e3cd91b278e8b23f6277 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 2 Jun 2015 21:05:24 +0200 Subject: [PATCH] * Make optimization to children_in_buffer: stop searching when we would cross a bracket. --- spacy/syntax/_state.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spacy/syntax/_state.pyx b/spacy/syntax/_state.pyx index dbc70e4fc..3e28a6cd4 100644 --- a/spacy/syntax/_state.pyx +++ b/spacy/syntax/_state.pyx @@ -82,6 +82,8 @@ cdef int children_in_buffer(const State *s, int head, const int* gold) except -1 for i in range(s.i, s.sent_len): if gold[i] == head: n += 1 + elif gold[i] == i or gold[i] < head: + break return n