Download all nltk packages in google colaboratory at once
Asked Answered
T

4

11

I want to use stopwords in my code on google colab, there are no errors when I import stuff regarding nltk but when I use stopwords in my code google colab gives this error:-

Resource 'corpora/stopwords.zip/stopwords/' not found.  Please
use the NLTK Downloader to obtain the resource:  >>>
nltk.download()

But when I do:-

 import nltk
 nltk.download()

It gives me all the packages list so I have to select 1 to download, in terminal I could do "all" to download all packages but how an I do that in google colab? I don't want to add a name everytime to download stuff. this is what colab shows me when I do "nltk.download()":-

NLTK Downloader

d) Download l) List u) Update c) Config h) Help q) Quit

 Downloader> d

 Download which package (l=list; x=cancel)?

Is there any way I can download all packages of nltk at once to my project in google colab?

Trulatrull answered 3/3, 2018 at 15:18 Comment(2)
Most probably you don't need all packages. Try Downloader> popularAcutance
Yeah I dont, but it takes a lot of time to look for each package and then download it, besides "popular" doesn't work.Trulatrull
D
19

I reached this page When I faced same problem.
I can use "popular" with this code at google colab.

import nltk
nltk.download("popular")
Dogoodism answered 20/7, 2018 at 12:52 Comment(0)
L
7

Use:

import nltk

nltk.download('all')

It worked for me.

Latinize answered 1/3, 2021 at 10:0 Comment(1)
How does that add further more than @Bal Krishna Jha answer?Passel
M
5

You have several other options:

all-corpora......... All the corpora
all-nltk............ All packages available on nltk_data gh-pages
                           branch
all................. All packages
book................ Everything used in the NLTK Book
popular............. Popular packages
tests............... Packages for running tests

You can use them as :

import nltk
nltk.download('book')
#or
nltk.download('tests')
#or
nltk.download('all-corpora')# not recommended as it download huge amount of data.
Mashe answered 2/9, 2018 at 12:26 Comment(0)
D
0

import nltk

nltk.download('all')

Worked for me!

Dorsey answered 24/10, 2023 at 15:57 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Selvage

© 2022 - 2024 — McMap. All rights reserved.