From 4cbad510ff61b5c165a8829d28344f043fefe92c Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 3 Feb 2016 02:32:21 +0100 Subject: [PATCH] * Fix calculation of head for spans with punctuation. --- spacy/tokens/span.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spacy/tokens/span.pyx b/spacy/tokens/span.pyx index aa2751a56..6f2ba9154 100644 --- a/spacy/tokens/span.pyx +++ b/spacy/tokens/span.pyx @@ -242,6 +242,8 @@ cdef int _count_words_to_root(const TokenC* token, int sent_length) except -1: # better candidates if Lexeme.c_check_flag(token.lex, IS_SPACE): return sent_length-1 + if Lexeme.c_check_flag(token.lex, IS_PUNCT): + return sent_length-1 cdef int n = 0 while token.head != 0: