Registry / ai-ml / stop-words

stop-words

JSON →
library2025.11.4pypypi✓ verified 85d ago

A Python library providing curated lists of stop words across 34+ languages. Stop words are common words (like “the”, “is”, “at”) that are typically filtered out in natural language processing and text analysis tasks. It offers extensive language support, built-in caching for performance, and zero external dependencies. The current version is 2025.11.4 and it maintains a regular release cadence. [1, 9]

pip install stop-words
INSTALL
IMPORT
SIG · STOP-WORDS
S
stop-words
ai-mlpythonv2025.11.4
Install
1.8s avg
Import
23ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2018.7.23 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.019s · 19.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.8s · import 0.018s · 20MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_stop_words
from stop_words import get_stop_words
Primary function to retrieve stop words for a specified language.
safe_get_stop_words
from stop_words import safe_get_stop_words
A safer alternative that handles unsupported languages gracefully (returns empty list).
STOP_WORDS_CACHE
from stop_words import STOP_WORDS_CACHE
Access the internal cache for advanced control, e.g., clearing or inspecting cached languages.

Demonstrates how to fetch stop words for English and Spanish and apply them to a simple text string. It highlights the importance of lowercasing and punctuation removal for effective filtering. [1, 9]

from stop_words import get_stop_words # Get English stop words english_stop_words = get_stop_words('en') print(f"English stop words (first 5): {english_stop_words[:5]}") # Get Spanish stop words using full name spanish_stop_words = get_stop_words('spanish') print(f"Spanish stop words (first 5): {spanish_stop_words[:5]}") # Example usage in text processing text = "This is a sample sentence, demonstrating stop word removal." filtered_words = [word.lower() for word in text.replace(',', '').replace('.', '').split() if word.lower() not in english_stop_words] print(f"Filtered text: {' '.join(filtered_words)}")
Debug
Known issues
gotchaThe library caches stop word lists by default for performance. Directly modifying the raw text files (e.g., `english.txt`) within the installed package directory will likely not update the loaded stop words unless the cache is cleared or the application is restarted. [1, 9, 21]
fix
Interact with the returned list (e.g., `my_list = get_stop_words('en'); my_list.append('custom_word')`) or explicitly clear the cache (`from stop_words import STOP_WORDS_CACHE; STOP_WORDS_CACHE.clear()`).
affects: All versions with caching (>=2015.2.23)
gotchaThe `get_stop_words()` function returns an empty list if the requested language is not supported or recognized, rather than raising an error. This can lead to silent failures if not explicitly handled or checked. [1, 9]
fix
Always check if the returned list is empty, or use `safe_get_stop_words()` if an empty list is the desired fallback for unsupported languages. Consult documentation for available language codes.
affects: All versions
gotchaStop word lists are typically in lowercase. Input text containing capitalized words (e.g., 'The') or words with punctuation (e.g., 'word.') will not match their lowercase, punctuation-free counterparts in the stop word list, leading to them not being filtered. [8]
fix
Always normalize your input text by converting words to lowercase (e.g., `.lower()`) and stripping punctuation before comparing them to the stop word list.
affects: All versions
Errors
Common errors & fixes
Words like 'The' or 'Is' are not removed, even when 'the' or 'is' are in the stop word list.
Input text words are not converted to lowercase before comparison with the (lowercase) stop word list. [8]
fix
Ensure all words in your input text are converted to lowercase (e.g., `word.lower()`) before checking them against the stop words.
Words with trailing punctuation (e.g., 'example.') are not being filtered out by the stop word removal process.
Punctuation attached to words prevents an exact match with the clean stop words in the list. [8]
fix
Strip punctuation from words (e.g., using `str.strip(string.punctuation)` or regular expressions) before checking them against the stop word list.
I modified `english.txt` (or another language file) in the installed package, but `get_stop_words('en')` still returns the old list.
The library employs internal caching, and direct modification of files within the installed package doesn't trigger a cache refresh. This is generally an anti-pattern for package customization. [1, 9, 21]
fix
Instead of modifying package files, get the list programmatically and add/remove items (e.g., `my_stop_words = set(get_stop_words('en')) | {'my_new_word'}`). If absolutely necessary, clear the cache using `from stop_words import STOP_WORDS_CACHE; STOP_WORDS_CACHE.clear()`.
Calling `get_stop_words('unsupported_lang_code')` returns an empty list, but I expected an error or the language to be supported.
The requested language code or name is either misspelled or genuinely not included in the library's collection. `get_stop_words` silently returns an empty list for unsupported languages. [1, 9]
fix
Verify the language code/name against the library's available languages (often listed in the GitHub README or PyPI page). If the language is truly unsupported, you'll need to provide your own stop word list.
Upgrade
Version history
2025.11.4latest on PyPI · released Nov 3, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
stop-words — pip install stop-words · libregistry