NLTK Stopwords List: What It Removes and When to Use It
A practical review of the NLTK stopwords list: how filtering word tokens works, what it changes, where it can distort meaning, and when to keep the original text.
The NLTK stopwords list is a set of very common words, such as articles, pronouns, auxiliary verbs and prepositions, that NLTK ships as a downloadable corpus. It is mostly used to filter word tokens before tasks like keyword extraction, topic modeling or bag-of-words features. This review covers what the filter actually changes, where it helps, where it can damage meaning, and when you should keep the unfiltered text.
Is stopword filtering suitable for your use?
Recommendation: use the NLTK list as a starting point for frequency-based analysis, where common function words would otherwise crowd out the content words you care about. The main benefit is a shorter, content-heavy token list with almost no setup. The decisive tradeoff is that the list is generic. It does not know your domain or your task, and it removes words that carry meaning in some contexts, most notably negations.
Keep the plain, unfiltered text when any of the following apply:
- Sentiment or opinion analysis, where words like "not" or "no" reverse the meaning of a phrase.
- Phrase matching, question answering or search over exact wording, where function words distinguish one query from another.
- Models that rely on word order and context, such as modern transformer-based models, which are generally designed to take full sentences as input.
- Anything a person will read, quote or edit afterward.
- Short texts such as titles or search queries, where removing a few words can leave almost nothing behind.
What the transformation actually changes
Stopword filtering changes stored data rather than how text looks. Unlike reversal, mirroring or Unicode "font" substitution, no characters are altered and nothing is restyled. Whole tokens are deleted from a sequence. The words that remain keep their original spelling and order, but the gaps where function words were are not marked. The original sentence cannot be rebuilt from the filtered output.
The process runs in three steps. First, the text is split into word tokens. Second, each token is normalized, usually by lowercasing it. Third, any token found in the stopword set is dropped. The NLTK lists are stored in lowercase and contain words, not punctuation. Lowercase your tokens before comparing them, and handle punctuation as a separate step.
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
nltk.download("stopwords")
# word_tokenize also needs NLTK's tokenizer models; if it raises a
# LookupError, the message names the resource to download.
stop_en = set(stopwords.words("english"))
text = "The service was not good at all."
tokens = word_tokenize(text)
filtered = [t for t in tokens if t.isalpha() and t.lower() not in stop_en]
print(filtered)
This example shows the main risk. If the installed English list includes "not", as standard NLTK releases do, the output is reduced to content words like "service" and "good". That reads as positive, although the original sentence is negative. Run the code against your own installation and print the set to confirm which words it contains before relying on this behavior.
Three details are easy to overlook:
- Contractions: the English list contains fragments and contracted forms, so results depend on how your tokenizer splits words like "don't". Check that the tokenizer output and the list use the same forms.
- Languages: lists exist for many languages, including Russian through stopwords.words("russian"). stopwords.fileids() shows what your installation provides. Coverage and quality vary by language, so review a non-English list before using it.
- Customization: the function returns an ordinary Python list. You can convert it to a set, then add domain-specific terms or remove words you need to keep, such as negations.
stop_custom = set(stopwords.words("english")) - {"not", "no", "nor"}
stop_custom |= {"via", "etc"}
Will the result stay readable and usable?
Filtered tokens are meant for machines. Once function words are gone, the output stops being readable prose. Copying or sharing it gives other people a keyword list, not the original statement, and they may misread it, as the negation example shows. Assistive technology such as screen readers will read the remaining words, but the result will not match the sentence a human wrote. Store the original text next to the filtered tokens and show the original whenever people are the audience.
Practical usability also depends on consistency. If you filter documents with one version of the list and queries or later data with another, the vocabularies no longer line up. Pin the list contents, for example by saving your customized set with the project, so the same words are removed every time.
Gaps in the available evidence
No version-specific measurements were available for this review. That includes word counts per language, changes between NLTK releases, and benchmarks showing how much stopword removal improves or hurts a given model. Treat the claims here as general behavior of list-based filtering. Before relying on the list, inspect it in your own environment and compare task results with and without filtering on your data.