Class CompoundAwareHunspellRule


  • public abstract class CompoundAwareHunspellRule
    extends HunspellRule
    A spell checker that combines Hunspell und Morfologik spell checking to support compound words and offer fast suggestions for some misspelled compound words.
    • Method Detail

      • filterForLanguage

        protected abstract void filterForLanguage​(java.util.List<java.lang.String> suggestions)
      • getSuggestions

        public java.util.List<java.lang.String> getSuggestions​(java.lang.String word)
                                                        throws java.io.IOException
        As a hunspell-based approach is too slow, we use Morfologik to create suggestions. As this won't work for compounds not in the dictionary, we split the word and also get suggestions on the compound parts. In the end, all candidates are filtered against Hunspell again (which supports compounds).
        Overrides:
        getSuggestions in class HunspellRule
        Throws:
        java.io.IOException
      • handleWordEndPunctuation

        private void handleWordEndPunctuation​(java.lang.String punct,
                                              java.lang.String word,
                                              java.util.List<java.lang.String> noSplitSuggestions)
      • getCandidates

        protected java.util.List<java.lang.String> getCandidates​(java.lang.String word)
        Find potential corrections - it's okay if some of these are not valid words, this list will be filtered against the spellchecker before being returned to the user.
      • getCandidates

        protected java.util.List<java.lang.String> getCandidates​(java.util.List<java.lang.String> parts)
      • sortSuggestionByQuality

        protected java.util.List<java.lang.String> sortSuggestionByQuality​(java.lang.String misspelling,
                                                                           java.util.List<java.lang.String> suggestions)
        Overrides:
        sortSuggestionByQuality in class HunspellRule
      • getCorrectWords

        private java.util.List<java.lang.String> getCorrectWords​(java.util.List<java.lang.String> wordsOrPhrases)
      • getFilteredSuggestions

        protected java.util.List<java.lang.String> getFilteredSuggestions​(java.util.List<java.lang.String> wordsOrPhrases)
        Since:
        4.7