Skip to content

Commit 5a7dd36

Browse files
committed
Similarly to FixMultiSubjects, we need FixMultiObjects.
1 parent cecb9eb commit 5a7dd36

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

udapi/block/ud/fixmultiobjects.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
Block ud.FixMultiObjects will ensure that no node has more than one (direct) object child.
3+
"""
4+
from udapi.core.block import Block
5+
6+
7+
class FixMultiObjects(Block):
8+
"""
9+
Make sure there is at most one object.
10+
"""
11+
12+
def process_node(self, node):
13+
objects = [x for x in node.children if x.udeprel == 'obj']
14+
# For the moment, we take the dummiest approach possible: The first object survives and all others are forced to a different deprel.
15+
if len(objects) > 1:
16+
objects = objects[1:]
17+
for o in objects:
18+
o.deprel = 'iobj'

0 commit comments

Comments
 (0)