NLTK tree data structure, finding a node, it's parent or children
I am using nltk's Tree data structure to work with parsetree strings. from nltk.tree import Tree parsed = Tree('(ROOT (S (NP (PRP It)) (VP (VBZ is) (ADJP (RB so) (JJ nice))) (. .)))') The data structure, however, seems to be limited. Is it possible to get a node by it's string value and then navigate to top or bottom? For example suppose you want to get the node with string value 'nice' and then see what's its parent, children, etc. Is it achievable via nltk's Tree? For NLTK 3.0, you want to use the ParentedTree subclass. http://www.nltk.org/api/nltk.html#nltk.tree.ParentedTree Using the