Is there a way to chunk 2 or more repititions of a tag in a tagged sentence using nltk? <p>I'm trying to use the nltk module in python to chunk together any instances where two to five nouns occur in sequence.</p> <p>This is the code I am using:</p> <pre><code>parse_pattern = "Keyword: {&lt; N&gt;{2,5}}" keyword_parser = nltk.RegexpParser(parse_pattern) result = keyword_parser.parse(sentence) </code></pre> <p>I makes sense that this bit should do the trick: <code>Keyword: {&lt; N&gt;{2,5}}</code></p> <p>I even found an example in the book Natural Language Processing with Python that uses the above bit completely analogously: <code>NOUNS: {&lt; N.*&gt;{4,}}</code> where the authors explain that that bit of code should chunk 4 or more nouns.</p> <p>However, I get an error when I run the above code:</p> <pre><code>ValueError: Illegal chunk pattern: {&lt; N&gt;{2,5}} </code></pre> <p>Note: I also tried the above using <code>{&lt; N.*&gt;{2,5}}</code> (with the dot star solely because the author of the aforementioned book did) with no luck.</p> <p>Any help in how to chunk two or more repetitions of a tag would be highly appreciated.</p>