Registry / ai-ml / pystemmer

pystemmer

JSON →
library3.1.0pypypi✓ verified 24d ago

PyStemmer provides efficient access to stemming algorithms from the Snowball project, wrapping the `libstemmer_c` library in a Python module. It's primarily used in information retrieval and search engines to reduce words to their common linguistic base form. The current version is 3.0.0, with an active but irregular release cadence typically driven by updates to the underlying Snowball library or Python compatibility.

pip install PyStemmer
INSTALL
IMPORT
SIG · PYSTEMMER
P
pystemmer
ai-mlpythonv3.1.0
Install
1.6s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.0 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 21MB
18MB installed
● package 18MB
Code
Verified usage

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

Stemmer
import Stemmer

Initialize a stemmer for a specific language and use it to stem single words or lists of words. It's recommended to reuse the stemmer object for performance due to caching.

import Stemmer # Get a list of available algorithms algorithms = Stemmer.algorithms() # print(algorithms) # Uncomment to see the list # Get an instance of the English stemmer stemmer = Stemmer.Stemmer('english') # Stem a single word word = 'cycling' stemmed_word = stemmer.stemWord(word) print(f"'{word}' stemmed to: '{stemmed_word}'") # Stem a list of words words = ['connection', 'connections', 'connective', 'connected', 'connecting'] stemmed_words = stemmer.stemWords(words) print(f"Words {words} stemmed to: {stemmed_words}")
Debug
Known issues
gotchaStemmer objects are not thread-safe if used concurrently by multiple threads. Race conditions can occur.
fix
Create a new `Stemmer.Stemmer()` object for each thread or protect access to a shared stemmer object with a mutex (e.g., `threading.Lock`).
affects: All versions
gotchaInstalling PyStemmer might fail if pre-built wheels are not available for your system and Python version, as it requires a C compiler and Python development header files to build from source.
fix
Ensure you have a C compiler (e.g., GCC, Clang) and Python development headers installed on your system. For Debian/Ubuntu: `sudo apt-get install build-essential python3-dev`.
affects: All versions, particularly on less common architectures or specific Python versions
breakingPython 2 is no longer actively supported. PyStemmer 2.2.0.1 was the final version tested with Python 2.
fix
Upgrade to Python 3.8+ and PyStemmer 3.0.0 or newer. Earlier versions of PyStemmer supporting Python 3 are also available for older Python 3 environments.
affects: < 3.0.0
gotchaInput strings are assumed to be Unicode. While `stemWords` can accept UTF-8 encoded byte strings, inconsistencies with other encodings or incorrect handling of Unicode can lead to unexpected stemming results.
fix
Ensure all input text is consistently handled as Unicode strings before passing it to PyStemmer. Explicitly decode byte strings if their encoding is known and not UTF-8.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'Stemmer'
The `pystemmer` library, which exposes the `Stemmer` module, is either not installed in the current Python environment or the environment is not active.
fix
pip install pystemmer
Failed building wheel for pystemmer
This generic installation error typically indicates missing C compiler tools or Python development headers required to compile the underlying `libstemmer_c` C extension.
fix
On Debian/Ubuntu: `sudo apt-get install build-essential python3-dev`. On macOS: `xcode-select --install`. On Windows: Install 'Build Tools for Visual Studio' with the 'Desktop development with C++' workload from Microsoft.
AttributeError: module 'pystemmer' has no attribute 'Stemmer'
The `pystemmer` package, when imported directly as `pystemmer`, does not expose the `Stemmer` class. The main module containing the class is simply named `Stemmer`.
fix
import Stemmer
TypeError: Stemmer.Stemmer() takes 1 positional argument but 0 were given
The `Stemmer` class constructor requires a string argument specifying the language (e.g., `'english'`) to initialize the stemmer.
fix
s = Stemmer.Stemmer('english') # Replace 'english' with your desired language
Upgrade
Version history
3.1.0latest on PyPI · released May 22, 2026
Audit
Dependencies
libstemmer_crequiredPyStemmer is a wrapper around the C implementation of Snowball stemmers for performance.
C compileroptionalRequired for building from source if pre-built wheels are not available.
Python header filesoptionalRequired for building from source if pre-built wheels are not available.
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
pystemmer — pip install pystemmer · libregistry