1

I've tried many times but failed to download the NLTK data files through the internal downloader, but finally I figured out the way to download these files through an external downloader. And then I moved the downloaded files(which are .zip files) into the following path:

C:\Users\Administrator\AppData\Roaming\nltk_data\corpora

and extracted the files here. It should work, but it didn't, which is frustrating. So what's the problem here and how to fix it? Is there a way to install the data files? And thank you.

李鸿章
  • 343
  • 1
  • 2
  • 10

2 Answers2

0

The best way to download the nltk data when you programming is to use the download. Ex:

import nltk

    nltk.download()

Then you can download the data that will be placed in the default folder using this interface:

enter image description here

OR you can set the folder where is your data manually editing the file nltk.data.path. For this use:

import nltk

 nltk.data.path.append('YOUR PATH');
MFigueredo
  • 133
  • 8
-1

You will probably want to forgo manually installing and allow python to do it for you.

If you have already installed NLTK (either pip or conda depending on your Python setup an OS)from your command line or using these directions for windows: Installation

Then it is really easy. In your python script type:

import nltk
nltk.download()  

This will import the necessary functions from NLTK and then download the data associated with the NLTK.

Then you just import what you need from the data files:

from nltk.corpus import "data_name"

And it is ready to use. The reason to download from the script (or by using the command line in administrator mode) is that it stores the data in a centrally accessible location. This allows you to call it as above easily...no chasing down where it lives.

sconfluentus
  • 4,693
  • 1
  • 21
  • 40