Class PorterStemmer
java.lang.Object
opennlp.tools.stemmer.PorterStemmer
- All Implemented Interfaces:
Stemmer
A
Stemmer, implementing the
Porter Stemming Algorithm
The Stemmer implementation 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(..) methods.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(char ch) Add a character to the word being stemmed.private booleancons(int i) private booleancvc(int i) private booleandoublec(int j) private booleanchar[]Returns a reference to a character buffer containing the results of the stemming process.intReturns the length of the word resulting from the stemming process.private intm()(package private) voidvoidreset()reset() resets the stemmer so it can stem another word.(package private) voidbooleanstem()Stem the word placed into the Stemmer buffer through calls to add().booleanstem(char[] word) Stem a word contained in a char[].booleanstem(char[] word, int wordLen) Stem a word contained in a leading portion of a char[] array.booleanstem(char[] wordBuffer, int offset, int wordLen) Stem a word contained in a portion of a char[] array.booleanstem(int i0) stem(CharSequence word) Stem a word provided as a CharSequence.Stem a word provided as a String.private voidstep1()private voidstep2()private voidstep3()private voidstep4()private voidstep5()private voidstep6()toString()After a word has been stemmed, it can be retrieved by toString(), or a reference to the internal buffer can be retrieved by getResultBuffer and getResultLength (which is generally more efficient.)private boolean
-
Field Details
-
INC
private static final int INC- See Also:
-
b
private char[] b -
i
private int i -
j
private int j -
k
private int k -
k0
private int k0 -
dirty
private boolean dirty
-
-
Constructor Details
-
PorterStemmer
public PorterStemmer()
-
-
Method Details
-
reset
public void 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. -
add
public void add(char ch) Add a character to the word being stemmed. When you are finished adding characters, you can call stem(void) to process the word. -
toString
-
getResultLength
public int getResultLength()Returns the length of the word resulting from the stemming process. -
getResultBuffer
public char[] getResultBuffer()Returns a reference to a character buffer containing the results of the stemming process. You also need to consult getResultLength() to determine the length of the result. -
cons
private boolean cons(int i) -
m
private int m() -
vowelinstem
private boolean vowelinstem() -
doublec
private boolean doublec(int j) -
cvc
private boolean cvc(int i) -
ends
-
setto
-
r
-
step1
private void step1() -
step2
private void step2() -
step3
private void step3() -
step4
private void step4() -
step5
private void step5() -
step6
private void step6() -
stem
-
stem
Stem a word provided as a CharSequence. Returns the result as a CharSequence. -
stem
public boolean stem(char[] word) 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 getResultLength()/getResultBuffer() or toString(). -
stem
public boolean stem(char[] wordBuffer, int offset, int wordLen) 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 getResultLength()/getResultBuffer() or toString(). -
stem
public boolean stem(char[] word, int wordLen) 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 getResultLength()/getResultBuffer() or toString(). -
stem
public boolean stem()Stem the word placed into the Stemmer buffer through calls to add(). Returns true if the stemming process resulted in a word different from the input. You can retrieve the result with getResultLength()/getResultBuffer() or toString(). -
stem
public boolean stem(int i0)
-