Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLTK Data installation issues

Tags:

python

nltk

I am trying to install NLTK Data on Mac OSX 10.9 . The download directory to be set, as mentioned in NLTK 3.0 documentation, is /usr/share/nltk_data for central installation. But for this path, I get the error OSError: [Errno 13] Permission denied: '/usr/share/nltk_data'

Can I set the download directory as /Users/ananya/nltk_data for central installation?

I have Python 2.7 installed in my machine

Thanks, Ananya

like image 368
ac11 Avatar asked Mar 05 '14 07:03

ac11


People also ask

Where do I put nltk data?

Command line installation The recommended system location is C:\nltk_data (Windows); /usr/local/share/nltk_data (Mac); and /usr/share/nltk_data (Unix).


1 Answers

Have you tried:

$ sudo python
>>> import nltk
>>> nltk.download()

To check if the downloads work, try a few of the corpora that you have downloaded, e.g.

>>> from nltk.corpus import wordnet
>>> wordnet.synsets('dog')
[Synset('dog.n.01'), Synset('frump.n.01'), Synset('dog.n.03'), Synset('cad.n.01'), Synset('frank.n.02'), Synset('pawl.n.01'), Synset('andiron.n.01'), Synset('chase.v.01')]

If the corpora are not installed properly, you will see something like this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/util.py", line 68, in __getattr__
    self.__load()
  File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/util.py", line 56, in __load
    except LookupError: raise e
LookupError: 
**********************************************************************
  Resource 'corpora/wordnet' not found.  Please use the NLTK
  Downloader to obtain the resource:  >>> nltk.download()
  Searched in:
    - '/home/alvas/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************
like image 136
alvas Avatar answered Oct 05 '22 09:10

alvas