Class StopFilter

All Implemented Interfaces:
Closeable, AutoCloseable, Unwrappable<TokenStream>

public class StopFilter extends FilteringTokenFilter
Removes stop words from a token stream.
  • Constructor Details

  • Method Details

    • makeStopSet

      public static CharArraySet makeStopSet(String... stopWords)
      Builds a Set from an array of stop words, appropriate for passing into the StopFilter constructor. This permits this stopWords construction to be cached once when an Analyzer is constructed.
      Parameters:
      stopWords - An array of stopwords
      See Also:
    • makeStopSet

      public static CharArraySet makeStopSet(List<?> stopWords)
      Builds a Set from an array of stop words, appropriate for passing into the StopFilter constructor. This permits this stopWords construction to be cached once when an Analyzer is constructed.
      Parameters:
      stopWords - A List of Strings or char[] or any other toString()-able list representing the stopwords
      Returns:
      A Set (CharArraySet) containing the words
      See Also:
    • makeStopSet

      public static CharArraySet makeStopSet(String[] stopWords, boolean ignoreCase)
      Creates a stopword set from the given stopword array.
      Parameters:
      stopWords - An array of stopwords
      ignoreCase - If true, all words are lower cased first.
      Returns:
      a Set containing the words
    • makeStopSet

      public static CharArraySet makeStopSet(List<?> stopWords, boolean ignoreCase)
      Creates a stopword set from the given stopword list.
      Parameters:
      stopWords - A List of Strings or char[] or any other toString()-able list representing the stopwords
      ignoreCase - if true, all words are lower cased first
      Returns:
      A Set (CharArraySet) containing the words
    • accept

      protected boolean accept()
      Returns the next input Token whose term() is not a stop word.
      Specified by:
      accept in class FilteringTokenFilter