Class HunspellStemmer


  • public class HunspellStemmer
    extends java.lang.Object
    HunspellStemmer uses the affix rules declared in the HunspellDictionary to generate one or more stems for a word. It conforms to the algorithm in the original hunspell algorithm, including recursive suffix stripping.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  HunspellStemmer.Stem
      Stem represents all information known about a stem of a word.
    • Constructor Summary

      Constructors 
      Constructor Description
      HunspellStemmer​(HunspellDictionary dictionary)
      Constructs a new HunspellStemmer which will use the provided HunspellDictionary to create its stems.
      HunspellStemmer​(HunspellDictionary dictionary, int recursionCap)
      Constructs a new HunspellStemmer which will use the provided HunspellDictionary to create its stems
    • Constructor Detail

      • HunspellStemmer

        public HunspellStemmer​(HunspellDictionary dictionary)
        Constructs a new HunspellStemmer which will use the provided HunspellDictionary to create its stems. Uses the default recursion cap of 2 (based on Hunspell documentation).
        Parameters:
        dictionary - HunspellDictionary that will be used to create the stems
      • HunspellStemmer

        public HunspellStemmer​(HunspellDictionary dictionary,
                               int recursionCap)
        Constructs a new HunspellStemmer which will use the provided HunspellDictionary to create its stems
        Parameters:
        dictionary - HunspellDictionary that will be used to create the stems
        recursionCap - maximum level of recursion stemmer can go into
    • Method Detail

      • stem

        public java.util.List<HunspellStemmer.Stem> stem​(java.lang.String word)
        Find the stem(s) of the provided word
        Parameters:
        word - Word to find the stems for
        Returns:
        List of stems for the word
      • stem

        public java.util.List<HunspellStemmer.Stem> stem​(char[] word,
                                                         int length)
        Find the stem(s) of the provided word
        Parameters:
        word - Word to find the stems for
        Returns:
        List of stems for the word
      • uniqueStems

        public java.util.List<HunspellStemmer.Stem> uniqueStems​(char[] word,
                                                                int length)
        Find the unique stem(s) of the provided word
        Parameters:
        word - Word to find the stems for
        Returns:
        List of stems for the word
      • applyAffix

        public java.util.List<HunspellStemmer.Stem> applyAffix​(char[] strippedWord,
                                                               int length,
                                                               HunspellAffix affix,
                                                               int recursionDepth)
        Applies the affix rule to the given word, producing a list of stems if any are found
        Parameters:
        strippedWord - Word the affix has been removed and the strip added
        affix - HunspellAffix representing the affix rule itself
        recursionDepth - Level of recursion this stemming step is at
        Returns:
        List of stems for the word, or an empty list if none are found