From 9285f01d265cb9c4a3ad20f394826c5b02914cdb Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 7 Nov 2015 06:06:39 +1100 Subject: [PATCH] * Fix broken StateClass.E tracking --- spacy/syntax/stateclass.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spacy/syntax/stateclass.pyx b/spacy/syntax/stateclass.pyx index f5a49aea1..82de140f6 100644 --- a/spacy/syntax/stateclass.pyx +++ b/spacy/syntax/stateclass.pyx @@ -46,7 +46,7 @@ cdef class StateClass: cdef int E(self, int i) nogil: if self._e_i <= 0 or self._e_i >= self.length: return 0 - if i < 0 or i >= self.length: + if i < 0 or i > self._e_i: return 0 self._ents[self._e_i - (i+1)].start @@ -174,7 +174,8 @@ cdef class StateClass: self._e_i += 1 cdef void close_ent(self) nogil: - self._ents[self._e_i-1].end = self.B(0)+1 + self._e_i -= 1 + self._ents[self._e_i].end = self.B(0)+1 self._sent[self.B(0)].ent_iob = 1 cdef void set_ent_tag(self, int i, int ent_iob, int ent_type) nogil: