Class GeneratingSuggester
java.lang.Object
org.apache.lucene.analysis.hunspell.GeneratingSuggester
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceprivate static classGeneratingSuggester.Weighted<T extends Comparable<T>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Dictionaryprivate final SuggestibleEntryCacheprivate static final intprivate static final intprivate static final intprivate static final intprivate final Hunspell -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate intaffixStripLength(int affixId) private static intanyMismatchNgram(int n, String s1, String s2, boolean weighted) private static intcalcThreshold(String word) private booleancheckAffixCondition(int suffixId, char[] word, int offset, int length) private static intcommonCharacterPositionScore(String s1, String s2) (package private) static intcommonPrefix(CharSequence s1, CharSequence s2) expandRoot(Root<String> root, String misspelled) private List<GeneratingSuggester.Weighted<String>> expandRoots(String misspelled, List<GeneratingSuggester.Weighted<Root<String>>> roots) private List<GeneratingSuggester.Weighted<Root<String>>> findSimilarDictionaryEntries(String word, WordCase originalCase) getMostRelevantSuggestions(TreeSet<GeneratingSuggester.Weighted<String>> bySimilarity, Set<Suggestion> prevSuggestions) private booleanhasCompatibleFlags(Root<?> root, int affixId) private static intindexOfSubstring(String haystack, int haystackPos, String needle, int needlePos, int len) private static booleanisWorseThan(int score, CharsRef candidate, GeneratingSuggester.Weighted<Root<String>> root) private static intprivate static intlongerWorsePenalty(int length1, int length2) (package private) static intngramScore(int n, String s1, String s2, boolean weighted) private voidprocessAffixes(boolean prefixes, String word, GeneratingSuggester.AffixProcessor processor) private voidprocessAffixIds(int affixLength, IntsRef affixIds, GeneratingSuggester.AffixProcessor processor) private voidprocessSuggestibleWords(int minLength, int maxLength, BiConsumer<CharsRef, Supplier<IntsRef>> processor) private TreeSet<GeneratingSuggester.Weighted<String>> rankBySimilarity(String word, List<GeneratingSuggester.Weighted<String>> expanded) suggest(String word, WordCase originalCase, Set<Suggestion> prevSuggestions)
-
Field Details
-
MAX_ROOTS
private static final int MAX_ROOTS- See Also:
-
MAX_WORDS
private static final int MAX_WORDS- See Also:
-
MAX_GUESSES
private static final int MAX_GUESSES- See Also:
-
MAX_ROOT_LENGTH_DIFF
private static final int MAX_ROOT_LENGTH_DIFF- See Also:
-
dictionary
-
speller
-
entryCache
-
-
Constructor Details
-
GeneratingSuggester
GeneratingSuggester(Hunspell speller, SuggestibleEntryCache entryCache)
-
-
Method Details
-
suggest
-
findSimilarDictionaryEntries
-
isWorseThan
private static boolean isWorseThan(int score, CharsRef candidate, GeneratingSuggester.Weighted<Root<String>> root) -
processSuggestibleWords
private void processSuggestibleWords(int minLength, int maxLength, BiConsumer<CharsRef, Supplier<IntsRef>> processor) -
expandRoots
private List<GeneratingSuggester.Weighted<String>> expandRoots(String misspelled, List<GeneratingSuggester.Weighted<Root<String>>> roots) -
calcThreshold
-
expandRoot
-
processAffixes
private void processAffixes(boolean prefixes, String word, GeneratingSuggester.AffixProcessor processor) -
processAffixIds
private void processAffixIds(int affixLength, IntsRef affixIds, GeneratingSuggester.AffixProcessor processor) -
hasCompatibleFlags
-
checkAffixCondition
private boolean checkAffixCondition(int suffixId, char[] word, int offset, int length) -
affixStripLength
private int affixStripLength(int affixId) -
rankBySimilarity
private TreeSet<GeneratingSuggester.Weighted<String>> rankBySimilarity(String word, List<GeneratingSuggester.Weighted<String>> expanded) -
getMostRelevantSuggestions
private List<String> getMostRelevantSuggestions(TreeSet<GeneratingSuggester.Weighted<String>> bySimilarity, Set<Suggestion> prevSuggestions) -
commonPrefix
-
ngramScore
-
longerWorsePenalty
private static int longerWorsePenalty(int length1, int length2) -
anyMismatchNgram
-
indexOfSubstring
-
lcs
-
commonCharacterPositionScore
-