We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c651b04 commit 16fc5e5Copy full SHA for 16fc5e5
udapi/core/root.py
@@ -300,3 +300,17 @@ def steal_nodes(self, nodes):
300
self.create_multiword_token(words=words, form=mwt.form, misc=mwt.misc)
301
self._descendants += nodes
302
# pylint: enable=protected-access
303
+
304
+ def flatten(self, deprel='root'):
305
+ """Flatten the tree (i.e. attach all nodes to the root) and reset all deprels.
306
307
+ This is equivalent to
308
+ for node in root.descendants:
309
+ node.parent = root
310
+ node.deprel = 'root'
311
+ but it is faster.
312
+ """
313
+ self._children = self._descendants[:]
314
+ for node in self._children:
315
+ node._parent = self
316
+ node._children.clear()
0 commit comments