0

I have python 2.6 , NLTK for python , and a couple of external resources which I am using. Problem is, everything is recognised (import statements)

from nltk import sent_tokenize
from nltk import word_tokenize 
import re 
from nltk.corpus import stopwords 
from nltk.stem import PorterStemmer 
from nltk.probability import FreqDist

Traceback (most recent call last):
  File "E:\Program Files\eclipse\Martin Project Folder\labs2\src\lab2.py", line 22, in <module>
    sents.append(sent_tokenize( review.raw( ) ))

on line 22 you :

Resource 'tokenizers/punkt/english.pickle' not found.  Please
  use the NLTK Downloader to obtain the resource: >>>
  nltk.download().
  Searched in:
    - 'C:\\Users\\Martinos/nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
    - 'E:\\Python26\\nltk_data'
    - 'E:\\Python26\\lib\\nltk_data'
    - 'C:\\Users\\Martinos\\AppData\\Roaming\\nltk_data'

Anyone know why is that since the program should find the punkd version IN the nltk (since it recognises nltk) ?

joaquin
  • 82,968
  • 29
  • 138
  • 152
Martin
  • 1,873
  • 2
  • 13
  • 5
  • possible duplicate of [Failed loading english.pickle with nltk.data.load](http://stackoverflow.com/questions/4867197/failed-loading-english-pickle-with-nltk-data-load) – Daniel DiPaolo Feb 01 '11 at 19:53

2 Answers2

1

You need to download the nltk resources. To resolve the issue do as following:

Python mode in the Terminal and run following commands 
import nltk 
nltk.download()
J4cK
  • 30,459
  • 8
  • 42
  • 54
1

As the error message in stacktrace said you should invoke a function 'nltk.download()' from python console to download resources you need. Also this message lists all paths in which nltk tried to find the missing resource.

Andrey Sboev
  • 7,454
  • 1
  • 20
  • 37