From 87f5348e1769768cf1d52659c2955b7ce867719f Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 21 Jun 2020 17:17:18 +0200 Subject: [PATCH] Update nonproj --- spacy/syntax/nonproj.pyx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spacy/syntax/nonproj.pyx b/spacy/syntax/nonproj.pyx index eded53fac..5ccb11f37 100644 --- a/spacy/syntax/nonproj.pyx +++ b/spacy/syntax/nonproj.pyx @@ -7,7 +7,6 @@ from copy import copy from ..tokens.doc cimport Doc, set_children_from_heads -from ..gold import Example from ..errors import Errors @@ -50,8 +49,12 @@ def is_nonproj_arc(tokenid, heads): return False elif head is None: # unattached tokens cannot be non-projective return False - - start, end = (head+1, tokenid) if head < tokenid else (tokenid+1, head) + + cdef int start, end + if head < tokenid: + start, end = (head+1, tokenid) + else: + start, end = (tokenid+1, head) for k in range(start, end): for ancestor in ancestors(k, heads): if ancestor is None: # for unattached tokens/subtrees