mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
perf(REL_OP): Replace some token.children with token.rights or token.lefts (#12528)
Co-authored-by: Tan Long <tanloong@foxmail.com>
This commit is contained in:
parent
6be67db59f
commit
b0e5aed5ed
|
@ -432,22 +432,22 @@ cdef class DependencyMatcher:
|
||||||
return [doc[child.i] for child in doc[node].head.children if child.i < node]
|
return [doc[child.i] for child in doc[node].head.children if child.i < node]
|
||||||
|
|
||||||
def _imm_right_child(self, doc, node):
|
def _imm_right_child(self, doc, node):
|
||||||
for child in doc[node].children:
|
for child in doc[node].rights:
|
||||||
if child.i == node + 1:
|
if child.i == node + 1:
|
||||||
return [doc[child.i]]
|
return [doc[child.i]]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _imm_left_child(self, doc, node):
|
def _imm_left_child(self, doc, node):
|
||||||
for child in doc[node].children:
|
for child in doc[node].lefts:
|
||||||
if child.i == node - 1:
|
if child.i == node - 1:
|
||||||
return [doc[child.i]]
|
return [doc[child.i]]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _right_child(self, doc, node):
|
def _right_child(self, doc, node):
|
||||||
return [doc[child.i] for child in doc[node].children if child.i > node]
|
return [child for child in doc[node].rights]
|
||||||
|
|
||||||
def _left_child(self, doc, node):
|
def _left_child(self, doc, node):
|
||||||
return [doc[child.i] for child in doc[node].children if child.i < node]
|
return [child for child in doc[node].lefts]
|
||||||
|
|
||||||
def _imm_right_parent(self, doc, node):
|
def _imm_right_parent(self, doc, node):
|
||||||
if doc[node].head.i == node + 1:
|
if doc[node].head.i == node + 1:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user