title: Extracting clause from a Penn Treebank-formatted text
body: <p>Say I have a sentence:</p>
  
  <pre><code>After he had eaten the cheese, Bill went to the grocery.
  </code></pre>
  
  <p>In my program, I get the following output:</p>
  
  <pre><code>---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))))
      (. .)))
  </code></pre>
  
  <p>How would I merge the stuff not within a clause to become an independent clause? Like this:</p>
  
  <pre><code>S Clause {
      SBAR Clause {
           After he had eaten the cheese,
      }
  
      S Clause {
          Bill went to the grocery.
      }
  }
  </code></pre>
  
  <p>I'm pretty sure that I'm not clear, but basically I want to extract the independent and dependent clauses of the sentence, and the subclauses of those clauses.</p>