|
| 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