nltk.ParentedTree.flatten¶
-
ParentedTree.
flatten
()¶ Return a flat version of the tree, with all non-root non-terminals removed.
>>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))") >>> print(t.flatten()) (S the dog chased the cat)
Returns: a tree consisting of this tree’s root connected directly to its leaves, omitting all intervening non-terminal nodes. Return type: Tree