Table of Contents

Public classSealed KStemLexicon

Namespace
Rowles.LeanCorpus.Analysis.Stemmers
Assembly
Rowles.LeanCorpus.dll

Immutable IKStemLexicon backed by a frozen set.

public sealed class KStemLexicon : IKStemLexicon
KStemLexicon
Implements

Remarks

The lexicon must be provided via From(IEnumerable<string>), FromFile(string), or FromStream(Stream). A lexicon file is available in the repository under lexicons/kstem-dict.txt.

Constructors

Private constructorPrivate KStemLexicon(FrozenSet<string>)

Fields

Private fieldRead-onlyPrivate _words

Methods

Public method Contains(ReadOnlySpan<char>)

Returns true when word is a known base form.

Public method Contains(string)

Returns true when word is a known base form.

Public method ContainsPreLowered(ReadOnlySpan<char>)

Returns true when word is a known base form. The caller guarantees the input is already lowercased, so the implementation can skip the internal ToLowerInvariant step.

Public methodStatic From(IEnumerable<string>)

Builds a lexicon from base-form words. Empty lines and duplicate entries are ignored.

Public methodStatic FromEmbeddedResource(string, Assembly?)

Loads a UTF-8 text lexicon from an embedded resource in the calling assembly.

Public methodStatic FromFile(string)

Loads a UTF-8 text lexicon from disk. If path is relative, it is resolved against System.AppContext.BaseDirectory.

Public methodStatic FromStream(Stream)

Loads a UTF-8 text lexicon from a stream, using one base form per line. Lines starting with # are ignored. The stream is not disposed.