nltk.ImmutableTree.leaves

ImmutableTree.leaves()

Return the leaves of the tree.

>>> t = Tree.fromstring("(S (NP (D the) (N dog)) (VP (V chased) (NP (D the) (N cat))))")
>>> t.leaves()
['the', 'dog', 'chased', 'the', 'cat']
Returns:a list containing this tree’s leaves. The order reflects the order of the leaves in the tree’s hierarchical structure.
Return type:list