rust-stemmers

Rust implementations of Snowball stemming algorithms for 18 languages

Library
Cargo
v1.2.0
135stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
34/100Needs Attention
Development Activity0
Maintenance0
Community56
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
52/100Fair
Architecture55
Code Quality48
Innovation40
Learning Curve65

rust-stemmers provides native Rust implementations of the Snowball project’s word-stemming algorithms, reducing words to their root form (e.g. “fruitlessly” to “fruitless”) across 18 languages including English, French, German, Russian, and Arabic. It exposes a simple Stemmer::create(Algorithm) API and is commonly used as a preprocessing step in search indexing and information-retrieval pipelines.

What You Get

  • An Algorithm enum covering 18 languages (English, French, German, Spanish, Russian, Arabic, Tamil, Turkish, and more)
  • A Stemmer struct with a single stem(&str) -> Cow<str> method for reducing words to their root form
  • Serde Serialize/Deserialize derives on the Algorithm enum for easy configuration persistence
  • Zero runtime dependencies beyond serde, with each algorithm’s rules compiled directly into the binary

Common Use Cases

  • Normalizing tokens before indexing documents in a search engine to match word variants
  • Preprocessing text for information-retrieval or NLP pipelines that need language-aware stemming
  • Building multilingual search or text-analysis tools without shelling out to external stemming services

Under The Hood

Architecture - The crate exposes a thin Stemmer wrapper (src/lib.rs, ~325 lines) around a generated snowball module (src/snowball/mod.rs, algorithms/) where each supported language has its own .sbl-derived Rust implementation compiled ahead of time from the Snowball compiler’s Rust backend; a shared SnowballEnv and Among matching structure (snowball_env.rs, among.rs) implement the common suffix-stripping state machine that each language algorithm module drives with its own rule tables.

Tech Stack - 100% Rust with no build-time codegen step in the published crate (the generated algorithm files are checked in), depending only on serde/serde_derive for enum serialization; there are no other runtime dependencies, keeping the binary footprint small.

Code Quality - Test coverage is present but minimal (a single #[test]-bearing file), relying instead on test_data/ fixtures with expected stem outputs per language for validation against the reference Snowball test vectors; the code is a fairly direct, low-abstraction port of generated stemming logic rather than hand-written idiomatic Rust, which keeps behavior aligned with upstream Snowball but limits readability of the algorithm modules themselves.

API Design - The public surface is intentionally minimal: an Algorithm enum plus Stemmer::create() and .stem(), requiring no configuration beyond selecting a language, though callers must pre-lowercase input themselves since the algorithms assume lowercase text — a constraint documented in the crate-level doc comment but easy to miss without reading it.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search