简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM