Text swedishsnowballstemmer stem - CyrilB1531/lodestar GitHub Wiki

Development build. This page describes main, not a released package. The latest published Lodestar.Text is 0.6.0 — read its documentation.

HomeTextStemming

SwedishSnowballStemmer.Stem

The Snowball stem of one Swedish word.

public static string Stem(string word)

Parametersword is a single Swedish word. It is lowercased and NFC-normalised before the rules run, so a decomposed ä and a composed one are the same letter to the algorithm.

Returnsstring, the stem, always lowercase, and still carrying whatever ä, å or ö the input had.

ExceptionsArgumentNullException when word is null. An empty string, or a word of one character, is returned lowercased and otherwise untouched.

Example — an inflected noun stripped, and an adjective rewritten rather than stripped.

using Lodestar.Text.Stemming;

string plural = SwedishSnowballStemmer.Stem("nyheter");  // => nyhet
string definite = SwedishSnowballStemmer.Stem("nyheterna");  // => nyhet
string adjective = SwedishSnowballStemmer.Stem("hjälplöst");  // => hjälplös

Remarkshärlighär is the result most likely to look like a bug. It is not: lig is one of the three derivational endings the last step removes, and the algorithm has no dictionary to tell it that what remains happens to be another word. A stemmer produces keys, not words, and härlig, härligt and härligheten all reaching här is the point of it.

The consonant-pair step is the other one worth knowing. A word left ending in dd, gd, nn, dt, gt, kt or tt inside R1 loses the second letter, which is what makes an adjective and its neuter form one key — and what lets the derivational step then see the ig underneath.

using Lodestar.Text.Stemming;

string neuter = SwedishSnowballStemmer.Stem("friskt");  // => frisk
string common = SwedishSnowballStemmer.Stem("frisk");  // => frisk
string derived = SwedishSnowballStemmer.Stem("härligt");  // => här

Applies to — net10.0, netstandard2.0.

See alsoSwedishSnowballStemmer, the stemming index.