Categories
Python Answers

How to remove stop words using nltk or Python?

Spread the love

Sometimes, we want to remove stop words using nltk or Python

In this article, we’ll look at how to remove stop words using nltk or Python.

How to remove stop words using nltk or Python?

To remove stop words using nltk or Python, we can use the stopwords.words list from nltk.

For instance, we write

from nltk.corpus import stopwords
# ...
filtered_words = [word for word in word_list if word not in stopwords.words('english')]

to get English stop words with stopwords.words('english').

Then we return a list of words in word_list that aren’t stop words with

word for word in word_list if word not in stopwords.words('english')

Conclusion

To remove stop words using nltk or Python, we can use the stopwords.words list from nltk.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *