Extract parent and child node from python tree -
i using nltk's tree data structure.below sample nltk.tree. (s (s (advp (rb recently)) (np (nn someone)) (vp (vbd mentioned) (np (dt the) (nn word) (nn malaria)) (pp (to to) (np (prp me))))) (, ,) (cc and) (in so) (s (np (np (cd one) (jj whole) (nn flood)) (pp (in of) (np (nns memories)))) (vp (vbd came) (s (vp (vbg pouring) (advp (rb back)))))) (. .)) i not aware of nltk.tree datastructure. want extract parent , super parent node every leaf node e.g. 'recently' want (advp, rb), , 'someone' (np, nn)this final outcome want.earlier answer used eval() function want avoid. [('advp', 'rb'), ('np', 'nn'), ('vp', 'vbd'), ('np', 'dt'), ('np', 'nn'), ('np', 'nn'), ('pp', 'to'), ('np', 'prp'), ('s', 'cc'), ('s', 'in'), ('np', 'cd'),...