HunspellStemFilter (Lucene 10.5.0 common API)
Description: declaration: package: org.apache.lucene.analysis.hunspell, class: HunspellStemFilter

Package org.apache.lucene.analysis.hunspell

# Class HunspellStemFilter

java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.TokenFilter
org.apache.lucene.analysis.hunspell.HunspellStemFilter

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

public final class HunspellStemFilter extends TokenFilter
TokenFilter that uses hunspell affix rules and words to stem tokens. Since hunspell supports a word having multiple stems, this filter can emit multiple tokens for each consumed token

Note: This filter is aware of the `KeywordAttribute`. To prevent certain terms from being passed to the stemmer `KeywordAttribute.isKeyword()` should be set to `true` in a previous `TokenStream`.

Note: For including the original term as well as the stemmed version, see `KeywordRepeatFilterFactory`

WARNING: This API is experimental and might change in incompatible ways in the next release.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource

  `AttributeSource.State`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.analysis.TokenFilter

  `input`

  ### Fields inherited from class org.apache.lucene.analysis.TokenStream

  `DEFAULT_TOKEN_ATTRIBUTE_FACTORY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HunspellStemFilter(TokenStream input, Dictionary dictionary)`
  Create a `HunspellStemFilter` outputting all possible stems.
  `HunspellStemFilter(TokenStream input, Dictionary dictionary, boolean dedup)`
  Create a `HunspellStemFilter` outputting all possible stems.
  `HunspellStemFilter(TokenStream input, Dictionary dictionary, boolean dedup, boolean longestOnly)`
  Creates a new HunspellStemFilter that will stem tokens from the given TokenStream using affix rules in the provided Dictionary

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `incrementToken()`
  `void`
  `reset()`

  ### Methods inherited from class org.apache.lucene.analysis.TokenFilter

  `close, end, unwrap`

  ### Methods inherited from class org.apache.lucene.util.AttributeSource

  `addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### HunspellStemFilter

    public HunspellStemFilter(TokenStream input, Dictionary dictionary)
    Create a `HunspellStemFilter` outputting all possible stems.
    See Also:
      - `HunspellStemFilter(TokenStream, Dictionary, boolean)`

  - ### HunspellStemFilter

    public HunspellStemFilter(TokenStream input, Dictionary dictionary, boolean dedup)
    Create a `HunspellStemFilter` outputting all possible stems.
    See Also:
      - `HunspellStemFilter(TokenStream, Dictionary, boolean, boolean)`

  - ### HunspellStemFilter

    public HunspellStemFilter(TokenStream input, Dictionary dictionary, boolean dedup, boolean longestOnly)
    Creates a new HunspellStemFilter that will stem tokens from the given TokenStream using affix rules in the provided Dictionary
    Parameters:
      `input` - TokenStream whose tokens will be stemmed
      `dictionary` - HunspellDictionary containing the affix rules and words that will be used to stem the tokens
      `longestOnly` - true if only the longest term should be output.

- ## Method Details

  - ### incrementToken

    public boolean incrementToken() throws IOException
    Specified by:
      `incrementToken` in class `TokenStream`
    Throws:
      `IOException`

  - ### reset

    public void reset() throws IOException
    Overrides:
      `reset` in class `TokenFilter`
    Throws:
      `IOException`