title: chunk NP and VP using nltk
body: <p>I am trying to use nltk to find noun phrase (NP) and verb phrase (VP) in some LaTeX files.
  my LaTeX files contains lots of maths. As I am new to nltk I start trying to get what I need from the terminal. so for example I tried this sentence:</p>
  
  <p>Let the sizes be denoted by <code>$s(n)$</code> and <code>$t(n)$</code> respectively.</p>
  
  <p>the code I tried:</p>
  
  <pre><code>&gt;&gt;&gt; from nltk import sent_tokenize, word_tokenize, pos_tag
  
  &gt;&gt;&gt; text = "Let the sizes be denoted by $s(n)$ and $t(n)$ respectively."
  
  &gt;&gt;&gt; sents = sent_tokenize(text)
  
  &gt;&gt;&gt; tokens = word_tokenize(text)
  
  &gt;&gt;&gt; tagged_tokens = pos_tag(tokens)
  </code></pre>
  
  <p>and all these worked fine. but when I tried these:</p>
  
  <pre><code>&gt;&gt;&gt; from nltk.chunk import *
  
  &gt;&gt;&gt; from nltk.chunk.util import *
  
  &gt;&gt;&gt; from nltk.chunk.regexp import *
  
  &gt;&gt;&gt; from nltk import Tree
  
  &gt;&gt;&gt; gold_chunked_text = tagstr2tree(tagged_tokens)
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nltk/chunk/util.py", line 331, in tagstr2tree
      for match in WORD_OR_BRACKET.finditer(s):
  TypeError: expected string or buffer
  </code></pre>
  
  <p>Any idea what is the problem? </p>