Class PorterStemmer

Namespace
NOpenNLP.Tools.Stemmer
Assembly
NOpenNLP.Tools.dll

Stemmer, implementing the Porter Stemming Algorithm

The Stemmer class transforms a word into its root form. The input word can be provided a character at time (by calling Add(char)), or at once by calling one of the various Stem(something) methods.

public class PorterStemmer : IStemmer
Inheritance
PorterStemmer
Implements
Inherited Members

Constructors

PorterStemmer()

public PorterStemmer()

Properties

ResultBuffer

Returns a reference to a character buffer containing the results of the stemming process. You also need to consult ResultLength to determine the length of the result.

public char[] ResultBuffer { get; }

Property Value

char[]

ResultLength

Returns the length of the word resulting from the stemming process.

public int ResultLength { get; }

Property Value

int

Methods

Add(char)

Add a character to the word being stemmed. When you are finished adding characters, you can call Stem() to process the word.

public void Add(char ch)

Parameters

ch char

Reset()

Reset() resets the stemmer so it can stem another word. If you invoke the stemmer by calling Add(char) and then Stem(), you must call Reset() before starting another word.

public void Reset()

Stem()

Stem the word placed into the Stemmer buffer through calls to Add(char). Returns true if the stemming process resulted in a word different from the input. You can retrieve the result with ResultLength/ResultBuffer or ToString().

public bool Stem()

Returns

bool

Stem(char[])

Stem a word contained in a char[]. Returns true if the stemming process resulted in a word different from the input. You can retrieve the result with ResultLength/ResultBuffer or ToString().

public bool Stem(char[] word)

Parameters

word char[]

Returns

bool

Stem(char[], int)

Stem a word contained in a leading portion of a char[] array. Returns true if the stemming process resulted in a word different from the input. You can retrieve the result with ResultLength/ResultBuffer or ToString().

public bool Stem(char[] word, int wordLen)

Parameters

word char[]
wordLen int

Returns

bool

Stem(char[], int, int)

Stem a word contained in a portion of a char[] array. Returns true if the stemming process resulted in a word different from the input. You can retrieve the result with ResultLength/ResultBuffer or ToString().

public bool Stem(char[] wordBuffer, int offset, int wordLen)

Parameters

wordBuffer char[]
offset int
wordLen int

Returns

bool

Stem(int)

public bool Stem(int i0)

Parameters

i0 int

Returns

bool

Stem(string)

Stem a word provided as a string. Returns the result as a string.

public string Stem(string word)

Parameters

word string

Returns

string

ToString()

After a word has been stemmed, it can be retrieved by ToString(), or a reference to the internal buffer can be retrieved by ResultBuffer and ResultLength (which is generally more efficient.)

public override string ToString()

Returns

string