Class GeneratingSuggester


  • class GeneratingSuggester
    extends java.lang.Object
    A class that traverses the entire dictionary and applies affix rules to check if those yield correct suggestions similar enough to the given misspelled word
    • Constructor Detail

      • GeneratingSuggester

        GeneratingSuggester​(Hunspell speller)
    • Method Detail

      • suggest

        java.util.List<java.lang.String> suggest​(java.lang.String word,
                                                 WordCase originalCase,
                                                 java.util.Set<Suggestion> prevSuggestions)
      • calcThreshold

        private static int calcThreshold​(java.lang.String word)
      • expandRoot

        private java.util.List<java.lang.String> expandRoot​(Root<java.lang.String> root,
                                                            java.lang.String misspelled)
      • hasCompatibleFlags

        private boolean hasCompatibleFlags​(Root<?> root,
                                           int affixId)
      • checkAffixCondition

        private boolean checkAffixCondition​(int suffixId,
                                            char[] word,
                                            int offset,
                                            int length)
      • affixStripLength

        private int affixStripLength​(int affixId)
      • getMostRelevantSuggestions

        private java.util.List<java.lang.String> getMostRelevantSuggestions​(java.util.TreeSet<GeneratingSuggester.Weighted<java.lang.String>> bySimilarity,
                                                                            java.util.Set<Suggestion> prevSuggestions)
      • commonPrefix

        static int commonPrefix​(java.lang.CharSequence s1,
                                java.lang.CharSequence s2)
      • ngramScore

        static int ngramScore​(int n,
                              java.lang.String s1,
                              java.lang.String s2,
                              boolean weighted)
      • longerWorsePenalty

        private static int longerWorsePenalty​(int length1,
                                              int length2)
      • anyMismatchNgram

        private static int anyMismatchNgram​(int n,
                                            java.lang.String s1,
                                            java.lang.String s2,
                                            boolean weighted)
      • indexOfSubstring

        private static int indexOfSubstring​(java.lang.String haystack,
                                            int haystackPos,
                                            java.lang.String needle,
                                            int needlePos,
                                            int len)
      • lcs

        private static int lcs​(java.lang.String s1,
                               java.lang.String s2)
      • commonCharacterPositionScore

        private static int commonCharacterPositionScore​(java.lang.String s1,
                                                        java.lang.String s2)