I need some NLTK
data packages in my code. I tried installing it from below command, but It installs all the packages that I do not need
conda install -c conda-forge nltk_data
How can I install specific NLTK data packages like stopwords, punkt, etc.
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.
The recommended system location is C:\nltk_data (Windows); /usr/local/share/nltk_data (Mac); and /usr/share/nltk_data (Unix). You can use the -d flag to specify a different location (but if you do this, be sure to set the NLTK_DATA environment variable accordingly).
NLTK Tutorials The following steps are from Installing NLTK: Install Setuptools: http://pypi.python.org/pypi/setuptools. Install Pip: run sudo easy_install pip. Install Numpy (optional): run sudo pip install -U numpy.
After installing nltk using pip,run the following code in ipython
import nltk
nltk.download()
After this you will get a GUI where you can download all the data
If you want specific download, you can do that too. GUI looks as shown below
From the NLTK documentation:
Run the Python interpreter and type the commands:
import nltk nltk.download()
A new window will pop up where you can select the packages that you wish to install.
Alternatively, you can use
python -m nltk.downloader <collection|package|all>
to install the package or collection you want, or use all
to install all of them.
Here is a list of the packages and collections that you can use in this command, extracted from nltk_data gh-pages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With