Snowball Stemmers
raw JSON → 0.6.0 verified Sat Apr 25 auth: no javascript
JavaScript port of the Snowball stemming algorithms (http://snowball.tartarus.org/), supporting 24 languages including Arabic, Russian, English, and more. The current stable version is 0.6.0, released sporadically. It is autogenerated from the Snowball compiler and uses ESJava. Key differentiators: lightweight, no dependencies, pure JS, and supports a wide range of languages. Compared to alternatives like natural or stemming libraries, it focuses on comprehensive language coverage. The library provides a simple factory API for creating stemmers and lists available algorithms.
Common errors
error TypeError: require(...).newStemmer is not a function ↓
cause Incorrect import style using named import or requiring wrong path.
fix
Use
const snowballFactory = require('snowball-stemmers'); then snowballFactory.newStemmer('english'). error Error: algorithm 'russin' not supported ↓
cause Misspelling the language name.
fix
Check available algorithms with
snowballFactory.algorithms(). Use exact string like 'russian'. error TypeError: stemmer.stem is not a function ↓
cause Accessing stem method on the factory instead of an instance.
fix
Create a stemmer instance first:
const stemmer = snowballFactory.newStemmer('english'); then call stemmer.stem(word). Warnings
gotcha The stem method may not handle non-ASCII characters correctly in all languages (e.g., Unicode normalization). ↓
fix Normalize input strings (NFKC) before stemming.
gotcha The package uses CommonJS and cannot be imported with ES module import syntax directly. ↓
fix Use require() instead of import. If using ESM, create a dynamic import wrapper.
deprecated Some algorithms like 'porter' are legacy and may be superseded by more recent Snowball algorithms. ↓
fix Use language-specific algorithm (e.g., 'english') instead of 'porter'.
gotcha The package is unmaintained since 2018; no updates for new languages or bug fixes. ↓
fix Consider using 'snowball-stemmer' (fork) or 'natural' library for active maintenance.
Install
npm install snowball-stemmers yarn add snowball-stemmers pnpm add snowball-stemmers Imports
- newStemmer (via default export) wrong
import { newStemmer } from 'snowball-stemmers'; // wrong: not a named exportcorrectconst snowballFactory = require('snowball-stemmers'); const stemmer = snowballFactory.newStemmer('english'); - algorithms wrong
const algorithms = require('snowball-stemmers/algorithms'); // wrong: no submodule pathcorrectconst snowballFactory = require('snowball-stemmers'); const algs = snowballFactory.algorithms(); - Stemmer instance (prototype methods) wrong
const result = snowballFactory.stem('чаво', 'russian'); // wrong: no such static methodcorrectconst stemmer = snowballFactory.newStemmer('russian'); const result = stemmer.stem('чаво');
Quickstart
const snowballFactory = require('snowball-stemmers');
const stemmer = snowballFactory.newStemmer('english');
console.log(stemmer.stem('running')); // 'run'
console.log(snowballFactory.algorithms());
// ['arabic', 'armenian', ..., 'turkish']