How can I efficiently list all pairs of subtrees (rooted in specific nonterminal) of a parse tree? For example, I have the following tree:
(S (S (S (S (X (PRO pro))) (X (V v))) (X (ADJ adj))) (X (N n)))
You can see the image on this link.
I want to list all adjacent instances of the symbol X expanding to other symbols, i. e.:
(X (PRO pro)) and (X (V v))
(X (V v)) and (X (ADJ adj))
(X (ADJ adj)) and (X (N n))
I recommend using the new tgrep module recently added to NLTK (install the latest version from GitHub), and once you've identified the nodes of interest, generate all pairs of subtrees using nested iteration.
--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.