13

I installed some NLTK-packages in python3 NLTK (via nltk.download()), tried them and -not needing them- want to remove them now.

How can I remove for example the package large_grammars from my NLTK-installation? (I do not want to remove the complete NLTK-installation!)

alvas
  • 115,346
  • 109
  • 446
  • 738
dia
  • 329
  • 2
  • 12

1 Answers1

14

By default NLTK packages/data are saved in the nltk_data directory.

First, you have to find where the directory might be:

>>> import nltk
>>> nltk.data.path
['/home/alvas/nltk_data', '/usr/share/nltk_data', '/usr/local/share/nltk_data', '/usr/lib/nltk_data', '/usr/local/lib/nltk_data']

Check the exact location of nltk_data:

>>> import os
>>> next(p for p in nltk.data.path if os.path.exists(p))
'/home/alvas/nltk_data'

On linux, simply go to the directory on the command line:

$ cd /home/alvas/nltk_data/
$ ls
corpora  grammars  tokenizers
$ cd grammars/
$ ls
large_grammars  large_grammars.zip
$ rm -rf large_grammars 
$ rm large_grammars.zip 
alvas
  • 115,346
  • 109
  • 446
  • 738
  • in your code you missed to `import os` (before checking the "exact location"). worked! thank you! (I thought I would need to remove it inside the nltk-framework.) – dia Apr 02 '17 at 12:26