Extract sentences from Penn Treebank text

Say I have a suggestion:

After he had eaten the cheese, Bill went to the grocery. 

In my program, I get the following output:

 ---PARSE TREE--- (ROOT (S (SBAR (IN After) (S (NP (PRP he)) (VP (VBD had) (VP (VBN eaten) (NP (DT the) (NN cheese)))))) (, ,) (NP (NNP Bill)) (VP (VBD went) (PP (TO to) (NP (DT the) (NN grocery)))) (. .))) 

How would I combine things not included in the proposal to become an independent proposal? Like this:

 S Clause { SBAR Clause { After he had eaten the cheese, } S Clause { Bill went to the grocery. } } 

I am sure that I do not know, but basically I want to extract the independent and dependent sentences of the proposal and the subclauses of these proposals.

+4
source share
1 answer

Here is a demo code from the NLTK manual (it does not explicitly show how to extract the sentence): http://nltk.googlecode.com/svn/trunk/doc/howto/tree.html

+1
source

All Articles