Skip to content

Commit 59f0fda

Browse files
committed
n1 < n2 is faster and shorter than n1.precedes(n2)
1 parent aa30a54 commit 59f0fda

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

udapi/block/ud/fixpunct.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ def _fix_subord_punct(self, node):
148148
if l_cand is None or l_cand.is_root():
149149
l_cand, l_path = None, []
150150
else:
151-
while (not l_cand.parent.is_root() and l_cand.parent.precedes(node)
152-
and not node.precedes(l_cand.descendants(add_self=1)[-1])):
151+
while (not l_cand.parent.is_root() and l_cand.parent < node
152+
and not node < l_cand.descendants(add_self=1)[-1]):
153153
l_cand = l_cand.parent
154154
l_path.append(l_cand)
155155
if r_cand is not None:
156-
while (not r_cand.parent.is_root() and node.precedes(r_cand.parent)
157-
and not r_cand.descendants(add_self=1)[0].precedes(node)):
156+
while (not r_cand.parent.is_root() and node < r_cand.parent
157+
and not r_cand.descendants(add_self=1)[0] < node):
158158
r_cand = r_cand.parent
159159
r_path.append(r_cand)
160160

@@ -226,8 +226,8 @@ def _fix_pair(self, root, opening_node, closing_node):
226226
if node == opening_node or node == closing_node:
227227
continue
228228
# If this is a node inside of the pair, is its parent outside?
229-
if opening_node.precedes(node) and node.precedes(closing_node):
230-
if node.parent.precedes(opening_node) or closing_node.precedes(node.parent):
229+
if node > opening_node and node < closing_node:
230+
if node.parent < opening_node or node.parent > closing_node:
231231
if node.upos == 'PUNCT':
232232
punct_heads.append(node)
233233
else:
@@ -237,7 +237,7 @@ def _fix_pair(self, root, opening_node, closing_node):
237237
# happen if an outside node is attached to an inside node. To account for
238238
# this, mark the inside parent as a head, too.
239239
else:
240-
if opening_node.precedes(node.parent) and node.parent.precedes(closing_node):
240+
if node.parent > opening_node and node.parent < closing_node:
241241
if node.parent.upos == 'PUNCT':
242242
punct_heads.append(node.parent)
243243
else:

0 commit comments

Comments
 (0)