Skip to content

Commit ed822b8

Browse files
committed
Better implementation following suggestions by @martinpopel
1 parent 3f9dd84 commit ed822b8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

udapi/block/ud/fixcompoundname.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ def process_node(self, node):
2424
grandparent = origparent.parent
2525
outdeprel = origparent.deprel
2626
# See if there are other PROPN compound siblings.
27-
namewords = sorted([x for x in origparent.children(add_self=True) if x.upos == 'PROPN' and (x.udeprel == 'compound' or x == origparent)], key=lambda y: y.ord)
27+
# (The list node.children is automatically sorted by ord. If any new sorting is needed later, we can compare nodes directly, their default comparison value is ord.)
28+
namewords = [x for x in origparent.children(add_self=True) if x.upos == 'PROPN' and (x.udeprel == 'compound' or x == origparent)]
2829
# The Hindi treebank tags dates (['30', 'navaṁbara'], ['disaṁbara', '1993']) as PROPN compounds.
2930
# This is wrong but it is also different from personal names we are targeting here.
3031
# Hence, we will skip "names" that contain numbers.
31-
if len([x for x in namewords if re.search(r"\d", x.form)]) == 0:
32+
if any(re.search(r"\d", x.form) for x in namewords):
3233
#logging.info(str([x.misc['Translit'] for x in namewords]))
3334
###!!! We currently cannot transform enhanced dependencies.
3435
###!!! If we proceed, the basic tree would diverge from the enhanced dependencies.

0 commit comments

Comments
 (0)