* Improve efficiency of L and R features, correcting the non-linear-in-length problem.

This commit is contained in:
Matthew Honnibal 2015-07-09 12:17:26 +02:00
parent 70d2acb579
commit 55f1042443
1 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ cdef class StateClass:
cdef const TokenC* target = &self._sent[i] cdef const TokenC* target = &self._sent[i]
if target.l_kids < idx: if target.l_kids < idx:
return -1 return -1
cdef const TokenC* ptr = self._sent cdef const TokenC* ptr = &self._sent[target.l_edge]
while ptr < target: while ptr < target:
# If this head is still to the right of us, we can skip to it # If this head is still to the right of us, we can skip to it
@ -78,7 +78,7 @@ cdef class StateClass:
cdef const TokenC* target = &self._sent[i] cdef const TokenC* target = &self._sent[i]
if target.r_kids < idx: if target.r_kids < idx:
return -1 return -1
cdef const TokenC* ptr = self._sent + (self.length - 1) cdef const TokenC* ptr = &self._sent[target.r_edge]
while ptr > target: while ptr > target:
# If this head is still to the right of us, we can skip to it # If this head is still to the right of us, we can skip to it
# No token that's between this token and this head could be our # No token that's between this token and this head could be our