From c70eb776aee65b4b9c9b353b3f43d2363dc5ea4a Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 13 Oct 2015 15:58:22 +1100 Subject: [PATCH] * Fix whitespace attachment, so that left/right children are consistent with head. --- spacy/syntax/arc_eager.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spacy/syntax/arc_eager.pyx b/spacy/syntax/arc_eager.pyx index 561308928..30726974a 100644 --- a/spacy/syntax/arc_eager.pyx +++ b/spacy/syntax/arc_eager.pyx @@ -384,7 +384,10 @@ cdef class ArcEager(TransitionSystem): for i in range(st.length): # Always attach spaces to the previous word if Lexeme.c_check_flag(st._sent[i].lex, IS_SPACE): - st._sent[i].head = -1 if (i >= 1) else 1 + if i >= 1: + st.add_arc(i-1, i, st._sent[i].dep) + else: + st.add_arc(i+1, i, st._sent[i].dep) if st._sent[i].sent_start and st._sent[i].head == -1: st._sent[i].sent_start = False # If we had this space token as the start of a sentence,