From 56164ab6883cef9c1235ede2fbbb055e89b257d8 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 22 Jan 2018 20:18:04 +0100 Subject: [PATCH] Set l_edge and r_edge correctly for non-projective parses. Fixes #1799 --- spacy/tokens/doc.pyx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/tokens/doc.pyx b/spacy/tokens/doc.pyx index 12932238f..b88c02320 100644 --- a/spacy/tokens/doc.pyx +++ b/spacy/tokens/doc.pyx @@ -1035,18 +1035,19 @@ cdef int set_children_from_heads(TokenC* tokens, int length) except -1: child = &tokens[i] head = &tokens[i + child.head] if child < head: - if child.l_edge < head.l_edge: - head.l_edge = child.l_edge head.l_kids += 1 + if child.l_edge < head.l_edge: + head.l_edge = child.l_edge # Set right edges --- same as above, but iterate in reverse for i in range(length-1, -1, -1): child = &tokens[i] head = &tokens[i + child.head] if child > head: - if child.r_edge > head.r_edge: - head.r_edge = child.r_edge head.r_kids += 1 + if child.r_edge > head.r_edge: + head.r_edge = child.r_edge + # Set sentence starts for i in range(length):