The details are on the above. I run it on Jupiter notebook, and get the error message.
TL;DR
On the terminal:
python -m nltk.downloader averaged_perceptron_tagger
or in Python
import nltk
nltk.download('averaged_perceptron_tagger')
Firstly, please update your NLTK version to version 3.2.5, on the command line (Use sudo
if necessary):
pip install -U nltk
Now you can try using the pos_tag
function again and you should see a more helpful error message:
>>> from nltk import pos_tag
>>> pos_tag(['foo', 'bar'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/nltk/tag/__init__.py", line 133, in pos_tag
tagger = _get_tagger(lang)
File "/usr/local/lib/python2.7/site-packages/nltk/tag/__init__.py", line 97, in _get_tagger
tagger = PerceptronTagger()
File "/usr/local/lib/python2.7/site-packages/nltk/tag/perceptron.py", line 140, in __init__
AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
File "/usr/local/lib/python2.7/site-packages/nltk/data.py", line 673, in find
raise LookupError(resource_not_found)
LookupError:
**********************************************************************
Resource averaged_perceptron_tagger not found.
Please use the NLTK Downloader to obtain the resource:
>>> import nltk
>>> nltk.download('averaged_perceptron_tagger')
Searched in:
- '/Users/alvas/nltk_data'
- '/usr/share/nltk_data'
- '/usr/local/share/nltk_data'
- '/usr/lib/nltk_data'
- '/usr/local/lib/nltk_data'
**********************************************************************
Note that the punkt
resource is used for word_tokenize()
but the pos_tag()
function requires the averaged_perceptron_tagger
model.
So, on the terminal, do:
python -m nltk.downloader averaged_perceptron_tagger
or in Python
import nltk
nltk.download('averaged_perceptron_tagger')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With