Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install nltk_data as package with pip? [duplicate]

Tags:

python

pip

nltk

I am new at Python and coming from Java background.

I've got a project, which uses nltk and nltk_data. I downloaded nltk_data with nltk.download() on my laptop and the project works fine but I would like to automate the downloading of nltk_data.

I can download it from command line but I want to do it lazily as pip downloads package upon pip install. So my questions are:

  • Can I install nltk_data as a regular Python package with pip ?
  • What is the best way to download nltk_data lazily ?
like image 214
Michael Avatar asked May 29 '17 16:05

Michael


People also ask

How do I manually download Punkt?

Go to GitHub repo, download the package we need and unzip this file. For example, in this punkt case, we are going to download the zip file in this link. After we download it, we can then unzip it to get a folder named punkt.

What does NLTK download (' Punkt ') do?

This tokenizer divides a text into a list of sentences by using an unsupervised algorithm to build a model for abbreviation words, collocations, and words that start sentences. It must be trained on a large collection of plaintext in the target language before it can be used.

How do I download and install NLTK in Anaconda?

Through Anaconda First, to install Anaconda, go to the link www.anaconda.com/distribution/#download-section and then select the version of Python you need to install. You need to review the output and enter 'yes'. NLTK will be downloaded and installed in your Anaconda package.


1 Answers

The bottom of the NLTK data documentation explains this:

Run the command python -m nltk.downloader all. To ensure central installation, run the command sudo python -m nltk.downloader -d /usr/local/share/nltk_data all.

If you want to distribute your program, you might want to consider writing a setuptools setup.py file to simplify installation:

What is setup.py?

Official packaging docs

like image 173
Azsgy Avatar answered Sep 19 '22 12:09

Azsgy