/**
* PorterStemAnalyzer processes input
* text by stemming English words to their roots.
* This Analyzer also converts the input to lower case
* and removes stop words. A small set of default stop
* words is defined in the STOP_WORDS
* array, but a caller can specify an alternative set
* of stop words by calling non-default constructor.
*/
public class PorterStemAnalyzer extends Analyzer
{
private static Hashtable _stopTable;
/**
* Builds an analyzer.
*/
public PorterStemAnalyzer()
{
this(STOP_WORDS);
}
/**
* Builds an analyzer with the given stop words.
*
* @param stopWords a String array of stop words
*/
public PorterStemAnalyzer(String[] stopWords)
{
_stopTable = StopFilter.makeStopTable(stopWords);
}
/**
* Processes the input by first converting it to
* lower case, then by eliminating stop words, and
* finally by performing Porter stemming on it.
*
* @param reader the Reader that
* provides access to the input text
* @return an instance of TokenStream
*/
public final TokenStream tokenStream(Reader reader)
{
System.out.println("PorterStemAnalyzer.tokenStream(Reader reader)");
return new PorterStemFilter(
new StopFilter(new LowerCaseTokenizer(reader),
_stopTable));
}
}