Fix array out of bounds error in Span

This commit is contained in:
Matthew Honnibal 2018-02-28 12:27:09 +01:00
parent aff5f007b3
commit a1be01185c

View File

@ -294,6 +294,7 @@ cdef class Span:
cdef int i cdef int i
if self.doc.is_parsed: if self.doc.is_parsed:
root = &self.doc.c[self.start] root = &self.doc.c[self.start]
n = 0
while root.head != 0: while root.head != 0:
root += root.head root += root.head
n += 1 n += 1
@ -307,8 +308,10 @@ cdef class Span:
start += -1 start += -1
# find end of the sentence # find end of the sentence
end = self.end end = self.end
while self.doc.c[end].sent_start != 1: n = 0
while end < self.doc.length and self.doc.c[end].sent_start != 1:
end += 1 end += 1
n += 1
if n >= self.doc.length: if n >= self.doc.length:
break break
# #