mirror of
https://github.com/explosion/spaCy.git
synced 2025-03-03 10:55:52 +03:00
* Check valency in L and R feature methods, to make feaure calculation faster
This commit is contained in:
parent
f4986d5d3c
commit
5d870720bc
|
@ -52,6 +52,8 @@ cdef class StateClass:
|
||||||
if i < 0 or i >= self.length:
|
if i < 0 or i >= self.length:
|
||||||
return -1
|
return -1
|
||||||
cdef const TokenC* target = &self._sent[i]
|
cdef const TokenC* target = &self._sent[i]
|
||||||
|
if target.l_kids < idx:
|
||||||
|
return -1
|
||||||
cdef const TokenC* ptr = self._sent
|
cdef const TokenC* ptr = self._sent
|
||||||
|
|
||||||
while ptr < target:
|
while ptr < target:
|
||||||
|
@ -75,8 +77,10 @@ cdef class StateClass:
|
||||||
return -1
|
return -1
|
||||||
if i < 0 or i >= self.length:
|
if i < 0 or i >= self.length:
|
||||||
return -1
|
return -1
|
||||||
cdef const TokenC* ptr = self._sent + (self.length - 1)
|
|
||||||
cdef const TokenC* target = &self._sent[i]
|
cdef const TokenC* target = &self._sent[i]
|
||||||
|
if target.r_kids < idx:
|
||||||
|
return -1
|
||||||
|
cdef const TokenC* ptr = self._sent + (self.length - 1)
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user