A Node.js interface to the Snowball stemming algorithms
npm install node-stemmer!CI
``shell`
npm i node-stemmer
| node-stemmer | libstemmer |
| -------- | ------- |
| 3.0.2 | 3.0.0, 3.0.1 |
| 1.0.0 | 2.0.0, 2.1.0, 2.2.0 |
`typescript
import { Stemmer, CharacterEncoding } from 'node-stemmer';
const algorithms = Stemmer.algorithms();
console.log(algorithms);
/*
[
'arabic', 'armenian', 'basque',
'catalan', 'danish', 'dutch',
'dutch_porter', 'english', 'esperanto',
'estonian', 'finnish', 'french',
'german', 'greek', 'hindi',
'hungarian', 'indonesian', 'irish',
'italian', 'lithuanian', 'nepali',
'norwegian', 'porter', 'portuguese',
'romanian', 'russian', 'serbian',
'spanish', 'swedish', 'tamil',
'turkish', 'yiddish'
]
*/
const algorithm = 'english';
const word = Buffer.from('cycling');
const stemmer = new Stemmer(algorithm); // default character encoding is UTF-8
const stem = stemmer.stemWord(word);
console.log(stem);
/*
cycl
*/
const algorithm = 'basque';
const word = Buffer.from('aberatsenetakoa');
const stemmer = new Stemmer(algorithm, CharacterEncoding.ISO_8859_1);
const stem = stemmer.stemWord(word);
console.log(stem);
/*
aberatse
*/
``