nltk pos_tag usage
Asked Answered
F

3

8

I am trying to use speech tagging in NLTK and have used this command:

>>> text = nltk.word_tokenize("And now for something completely different")

>>> nltk.pos_tag(text)

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
nltk.pos_tag(text)
File "C:\Python27\lib\site-packages\nltk\tag\__init__.py", line 99, in pos_tag
tagger = load(_POS_TAGGER)
File "C:\Python27\lib\site-packages\nltk\data.py", line 605, in load
resource_val = pickle.load(_open(resource_url))
File "C:\Python27\lib\site-packages\nltk\data.py", line 686, in _open
return find(path).open()
File "C:\Python27\lib\site-packages\nltk\data.py", line 467, in find
raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
Resource 'taggers/maxent_treebank_pos_tagger/english.pickle' not
found.  Please use the NLTK Downloader to obtain the resource:

However, I get an error message which shows:

engish.pickle not found.

I have download the whole corpora and the english.pickle file is there in the maxtent_treebank_pos_tagger

What can I do to get this to work?

Freeboot answered 30/12, 2012 at 10:16 Comment(1)
Welcome to SO. Try and be as descriptive as possible in your questions to get the best answers.Cooker
L
7

Your Python installation is not able to reach maxent or treemap.

First, check if the tagger is indeed there: Start Python from the command line.

>>> import nltk

Then you can check using

>>> dir (nltk)

Look through the list to see if maxent and treebank are both there.

Easier would be to type

>>> "maxent" in dir(nltk)
>>> True
>>> "treebank" in dir(nltk)
>>> True

Use nltk.download() --> Models tab and check to see if the treemap tagger shows as installed. You should also try downloading the tagger again.

NLTK Downloader, Models Tab

Laterality answered 31/12, 2012 at 20:28 Comment(1)
thnks @ram i got the sollution to my problem. i created a folder taggers and copied the maxtent_treebank_pos in that and it finally works..:)Freeboot
G
3

If you don't want to use the downloader gui, you can just use the following commands in a python or ipython shell:

import nltk
nltk.download('punkt')
nltk.download('maxent_treebank_pos_tagger')
Giza answered 31/7, 2015 at 5:18 Comment(1)
This works perfect for me, but why is that i need to run it all the time if i close the shellMarsland
P
0

Over 50 corpora and lexical resources such as WordNet: http://www.nltk.org/nltk_data/ for free. Use http://nltk.github.com/nltk_data/ as server index instead of googlecode Google code 401: Authorization Required

Pacian answered 22/10, 2014 at 11:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.