Class TypeTokenFilter

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

public final class TypeTokenFilter extends FilteringTokenFilter
Removes tokens whose types appear in a set of blocked types from a token stream.
  • Constructor Details

    • TypeTokenFilter

      public TypeTokenFilter(TokenStream input, Set<String> stopTypes, boolean useWhiteList)
      Create a new TypeTokenFilter.
      Parameters:
      input - the TokenStream to consume
      stopTypes - the types to filter
      useWhiteList - if true, then tokens whose type is in stopTypes will be kept, otherwise they will be filtered out
    • TypeTokenFilter

      public TypeTokenFilter(TokenStream input, Set<String> stopTypes)
      Create a new TypeTokenFilter that filters tokens out (useWhiteList=false).
  • Method Details

    • accept

      protected boolean accept()
      By default accept the token if its type is not a stop type. When the useWhiteList parameter is set to true then accept the token if its type is contained in the stopTypes
      Specified by:
      accept in class FilteringTokenFilter