nltk/nltk — Issue #185: Illegal pattern given on page 268
Author: alexrudnick
Created: 2012-01-17 06:28:01+00:00
State: open

Which version of the book are you using?

June 2009 (First Edition)

Please specify the chapter and section number(s)

7.2

Please describe any problems in as much detail as possible, and feel free
to suggest fixes.

In the "Your Turn" box of the subsection 'Exploring Text Corpora' on page 268 (of the PDF version, downloaded from O'Reilly), we are suggested to search for four nouns in a row using the pattern "NOUNS: {<N.*>{4,}}". This seems like a perfectly valid way, using regular expressions, to search for four or more nouns. However, this seems to be an illegal pattern for a grammar. Specifically, I don't believe that curlie braces part used to indicate 'four or more' - that is, the {4,} - is allowed. I get a ValueError exception raised if I try this call:

nltk.RegexpParser('NOUNS: {<N.*>{4,}}')

I am curious how one WOULD express 'four or more' legally in a grammar?

Migrated from http://code.google.com/p/nltk/issues/detail?id=731

earlier comments

harrylippy said, at 2012-01-11T07:28:30.000Z:

>>> import nltk
>>> nltk.__version__
'2.0b9'
>>>

harrylippy said, at 2012-01-11T07:29:01.000Z:

Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2