Reputation: 2227
I am trying to learn NLTK by following instructions in a book. The code is:
from nltk.corpus import brown
brown_news_tagged = brown.tagged_words(categories='news', tagsets='universal')
However, the error I get is: tagged_words() got an unexpected keyword argument 'tagsets'
Upvotes: 1
Views: 938
Reputation: 1
The correct argument (I think) for python 2.7.8 is [now?] simplify_tags=...
Upvotes: 0
Reputation: 7593
Here are a few reasons why this could be happening:
If you choose to use Python 3 and the alpha version of NLTK 3.0, you can verify the availability of the tagset
argument by using the following commands on a command line:
python3
>>> from nltk.corpus import brown
>>> import inspect
>>> inspect.getargspec(brown.tagged_words)
After running those commands, we can see that the tagset
parameter/argument is available:
ArgSpec(args=['self', 'fileids', 'categories', 'tagset'], varargs=None, keywords=None, defaults=(None, None, None))
Looking back at the NLTK book in Chapter 5, we can also see that the examples given in relation to the universal
option indeed uses tagset
(singular rather than plural) in order to obtain the desired results.
Upvotes: 3