Accessing a parse tree
Clarendon
jineu21 at hotmail.com
Thu Apr 16 18:55:16 EDT 2009
Hello!
I need a program that accesses a parse tree based on the designated
words (terminals) within the tree. For instance, in:
I came a long way in changing my habit.
(ROOT
(S
(NP (PRP I))
(VP (VBD came)
(NP (DT a) (JJ long) (NN way))
(PP (IN in)
(S
(VP (VBG changing)
(NP (PRP$ my) (NN habit))))))
the designated words are "a long way". I need the program to recognize
how many parentheses there are after them. Currently two: NN way)).
Then I need it to see how many parentheses there are before it.
Currently there are two as well: (NP (DT. Then the program should that
the designated wordssee are followed by (PP (IN in) and then by (S
(VP (VBG.
I looked at the NLTK Tree class but it does not seem to have a method
that works with designated words. Is there some kind of tree navigator
that does something like this? If I need to write one myself, I would
appreciate any tips about where to start.
Thanks.
More information about the Python-list
mailing list