Skip to content

Commit

Permalink
perf(REL_OP): Replace some token.children with token.rights or token.…
Browse files Browse the repository at this point in the history
…lefts (#12528)

Co-authored-by: Tan Long <[email protected]>
  • Loading branch information
tanloong and tanloong authored Apr 17, 2023
1 parent 119f959 commit 923d24e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spacy/matcher/dependencymatcher.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -432,22 +432,22 @@ cdef class DependencyMatcher:
return [doc[child.i] for child in doc[node].head.children if child.i < 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:
return [doc[child.i]]
return []

def _imm_left_child(self, doc, node):
for child in doc[node].children:
for child in doc[node].lefts:
if child.i == node - 1:
return [doc[child.i]]
return []

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):
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):
if doc[node].head.i == node + 1:
Expand Down

0 comments on commit 923d24e

Please sign in to comment.