Link to home
Start Free TrialLog in
Avatar of xRalf
xRalf

asked on

python Lookup Error

Hello,

Could you help me to solve this error message? Code and error are attached.

thank you
import nltk.data

text = "Punkt knows that the periods in Mr. Smith and Johann S. Bach do not mark sentence boundaries.  And sometimes sentences can start with non-capitalize words.  i is a good variable name."

tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')

print '\n-----\n'.join(tokenizer.tokenize(text.strip()))

Open in new window

$ python nltkexample.py
Traceback (most recent call last):
  File "nltkexample.py", line 5, in <module>
    tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
  File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/data.py", line 594, in load
    resource_val = pickle.load(_open(resource_url))
  File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/data.py", line 673, in _open
    return find(path).open()
  File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/data.py", line 455, in find
    raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
  Resource 'tokenizers/punkt/english.pickle' not found.  Please
  use the NLTK Downloader to obtain the resource: >>>
  nltk.download().
  Searched in:
    - '/home/xralf/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************

Open in new window

Avatar of mish33
mish33
Flag of United States of America image

As error says: Resource 'tokenizers/punkt/english.pickle' not found.

You need to place it in one of the listed dirs.
Avatar of xRalf
xRalf

ASKER

When
I write
nltk.download('tokenizers/punkt/english.pickle')
it writes error
/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/__init__.py:588: DeprecationWarning: object.__new__() takes no parameters
[nltk_data] Error loading tokenizers/punkt/english.pickle: Package
[nltk_data]     'tokenizers/punkt/english.pickle' not found in index
False

Should I use it another way? I don't know how to get the missing things. That's why I ask.
ASKER CERTIFIED SOLUTION
Avatar of mish33
mish33
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xRalf

ASKER

thanks I found there similar discussion which showed me link to the files that were needed to download and I've done it rather manually.