title: NLTK Chunking and walking the results tree
body: <p>I'm using NLTK RegexpParser to extract noungroups and verbgroups from tagged tokens.</p>
  
  <p>How do I walk the resulting tree to find only the chunks that are NP or V groups?</p>
  
  <pre><code>from nltk.chunk import RegexpParser
  
  grammar = '''
  NP: {&lt;DT&gt;?&lt;JJ&gt;*&lt;NN&gt;*}
  V: {&lt;V.*&gt;}'''
  chunker = RegexpParser(grammar)
  token = [] ## Some tokens from my POS tagger
  chunked = chunker.parse(tokens)
  print chunked
  
  #How do I walk the tree?
  #for chunk in chunked:
  #    if chunk.??? == 'NP':
  #         print chunk
  </code></pre>
  
  <p>(S
    (NP Carrier/NN)
    for/IN
    tissue-/JJ
    and/CC
    cell-culture/JJ
    for/IN
    (NP the/DT preparation/NN)
    of/IN
    (NP implants/NNS)
    and/CC
    (NP implant/NN)
    (V containing/VBG)
    (NP the/DT carrier/NN)
    ./.)</p>