lterfgr
lterfgr

Reputation: 3

Stopwords in Python 3

I'm unable to import stopwords by using from stop_words import stopwords as they state that the module does not exist. Is there another command I can put in to remove around 900 stopwords?

Im aware of the 100+ stopwords command but I'm trying to find a command that removes around 900 stopwords.

Upvotes: 0

Views: 1619

Answers (1)

ashcrok
ashcrok

Reputation: 244

You can use nltk library for this easily. First you need to install it by going to a shell and pip install nltk (note for python 3 go for pip3 instead of pip). After that you can easily got and download a stopwords corpus directly from python through nltk like this:

import nltk
nltk.download('stopwords')

Now that you have the corpus downloaded, you can use it like this:

from nltk.corpus import stopwords
print(stopwords.words('english'))

This will print out a list of all the stopwords in english corpus. Other languages are available.

Upvotes: 1

Related Questions