Skip to content

Commit 908f56a

Browse files
committed
prevent [L2 Enhanced unconnected-egraph] validation errors
1 parent 7d1fdcf commit 908f56a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

udapi/block/ud/fixpunct.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __init__(self, check_paired_punct_upos=False, copy_to_enhanced=False, **kwar
5353
based on the form with the exception of single & double quote character,
5454
which is frequently ambiguous*, so UPOS=PUNCT is checked always.
5555
*) Single quote can be an apostrophe. Double quote as a NOUN can be the inch symbol.
56-
copy_to_enhanced: for all upos=PUNCT deprel=punct nodes, let the enhanced depencies
56+
copy_to_enhanced: for all upos=PUNCT, let the enhanced depencies
5757
be the same as the basic dependencies.
5858
"""
5959
super().__init__(**kwargs)
@@ -111,15 +111,17 @@ def process_tree(self, root):
111111
# This may not hold if the original subroot was a paired punctuation, which was rehanged.
112112
if root.children[0].udeprel != 'root':
113113
root.children[0].udeprel = 'root'
114+
if self.copy_to_enhanced:
115+
root.children[0].deps = [{'parent': root, 'deprel': 'root'}]
114116
for another_node in root.children[0].descendants:
115117
if another_node.udeprel == 'root':
116118
another_node.udeprel = 'punct'
117119

118120
# TODO: This block changes parents not only for PUNCT nodes. These should be reflected into enhanced deps as well.
119121
if self.copy_to_enhanced:
120122
for node in root.descendants:
121-
if node.upos == 'PUNCT' and node.udeprel == 'punct':
122-
node.deps = [{'parent': node.parent, 'deprel': 'punct'}]
123+
if node.upos == 'PUNCT':
124+
node.deps = [{'parent': node.parent, 'deprel': node.deprel}]
123125

124126
def _fix_subord_punct(self, node):
125127
# Dot used as the ordinal-number marker (in some languages) or abbreviation marker.

0 commit comments

Comments
 (0)