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.