I need to extract triplets of the form NP-VP-NP
from the dependency parse tree produced as the output of lexalized parsing in Stanford Parser.
Whats the best way to do this. e.g. If the parse tree is as follows:
(ROOT
(S
(S
(NP (NNP Exercise))
(VP (VBZ reduces)
(NP (NN stress)))
(. .))
(NP (JJ Regular) (NN exercise))
(VP (VBZ maintains)
(NP (JJ mental) (NN fitness)))
(. .)))
I need to extract 2 triplets:
- Exercise-reduces-stress and
- Regular Exercise-maintains-mental fitness
Any ideas?