简体   繁体   中英

NLTK Data installation issues

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

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, eg

>>> 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'
**********************************************************************

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM