title: Drawing a flatten NLTK Parse Tree with NP chunks
body: <p>I want to analyze sentences with NLTK and display their chunks as a tree. NLTK offers the method <code>tree.draw()</code> to draw a tree. This following code draws a tree for the sentence <em>"the little yellow dog barked at the cat"</em>:</p>
  
  <pre><code>import nltk 
  sentence = [("the", "DT"), ("little", "JJ"), ("yellow", "JJ"), ("dog", "NN"), ("barked","VBD"), ("at", "IN"), ("the", "DT"), ("cat", "NN")]
  
  pattern = "NP: {&lt;DT&gt;?&lt;JJ&gt;*&lt;NN&gt;}"
  NPChunker = nltk.RegexpParser(pattern) 
  result = NPChunker.parse(sentence)
  result.draw()
  </code></pre>
  
  <p>The result is this tree:</p>
  
  <p><a href="https://i.stack.imgur.com/Id64E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Id64E.png" alt="example tree"></a></p>
  
  <p>How do i get a tree with one more level like this?</p>
  
  <p><a href="https://i.stack.imgur.com/qOuYb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qOuYb.png" alt="deeper tree"></a></p>