pythonparsingnlpparse-tree

How can I easily draw a parse tree from Stanford parsing data in python?


So I have this Stanford-style parsing of an english sentence:

"There is a tree behind a car"
Parse: [S [NP There_EX NP] [VP is_VBZ [NP [NP a_DT tree_NN NP] [PP behind_IN [NP a_DT car_NN NP] PP] NP] VP] S]

I want to use some of the tree drawing methods in python to draw a parsing tree from the data.

Is there an easy way to use that parsing representation to draw a tree with python or should I change the representation somehow?


Solution

  • NLTK has a tree module. You can use it to parse the representation you get out of Stanford (see this related question). Then you can use nltk.tree.draw to display it.