Class GeneratingSuggester
- java.lang.Object
-
- org.apache.lucene.analysis.hunspell.GeneratingSuggester
-
class GeneratingSuggester extends java.lang.ObjectA 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 Classes Modifier and Type Class Description private static interfaceGeneratingSuggester.AffixProcessorprivate static classGeneratingSuggester.EntryFilterprivate static classGeneratingSuggester.Weighted<T extends java.lang.Comparable<T>>
-
Field Summary
Fields Modifier and Type Field Description private Dictionarydictionaryprivate static intMAX_GUESSESprivate static intMAX_ROOT_LENGTH_DIFFprivate static intMAX_ROOTSprivate static intMAX_WORDSprivate Hunspellspeller
-
Constructor Summary
Constructors Constructor Description GeneratingSuggester(Hunspell speller)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private intaffixStripLength(int affixId)private static intanyMismatchNgram(int n, java.lang.String s1, java.lang.String s2, boolean weighted)private static intcalcThreshold(java.lang.String word)private booleancheckAffixCondition(int suffixId, char[] word, int offset, int length)private static intcommonCharacterPositionScore(java.lang.String s1, java.lang.String s2)(package private) static intcommonPrefix(java.lang.CharSequence s1, java.lang.CharSequence s2)private java.util.List<java.lang.String>expandRoot(Root<java.lang.String> root, java.lang.String misspelled)private java.util.List<GeneratingSuggester.Weighted<java.lang.String>>expandRoots(java.lang.String misspelled, java.util.List<GeneratingSuggester.Weighted<Root<java.lang.String>>> roots)private java.util.List<GeneratingSuggester.Weighted<Root<java.lang.String>>>findSimilarDictionaryEntries(java.lang.String word, WordCase originalCase)private java.util.List<java.lang.String>getMostRelevantSuggestions(java.util.TreeSet<GeneratingSuggester.Weighted<java.lang.String>> bySimilarity, java.util.Set<Suggestion> prevSuggestions)private booleanhasCompatibleFlags(Root<?> root, int affixId)private static intindexOfSubstring(java.lang.String haystack, int haystackPos, java.lang.String needle, int needlePos, int len)private static intlcs(java.lang.String s1, java.lang.String s2)private static intlongerWorsePenalty(int length1, int length2)(package private) static intngramScore(int n, java.lang.String s1, java.lang.String s2, boolean weighted)private voidprocessAffixes(boolean prefixes, java.lang.String word, GeneratingSuggester.AffixProcessor processor)private voidprocessAffixIds(int affixLength, IntsRef affixIds, GeneratingSuggester.AffixProcessor processor)private java.util.TreeSet<GeneratingSuggester.Weighted<java.lang.String>>rankBySimilarity(java.lang.String word, java.util.List<GeneratingSuggester.Weighted<java.lang.String>> expanded)(package private) java.util.List<java.lang.String>suggest(java.lang.String word, WordCase originalCase, java.util.Set<Suggestion> prevSuggestions)
-
-
-
Field Detail
-
MAX_ROOTS
private static final int MAX_ROOTS
- See Also:
- Constant Field Values
-
MAX_WORDS
private static final int MAX_WORDS
- See Also:
- Constant Field Values
-
MAX_GUESSES
private static final int MAX_GUESSES
- See Also:
- Constant Field Values
-
MAX_ROOT_LENGTH_DIFF
private static final int MAX_ROOT_LENGTH_DIFF
- See Also:
- Constant Field Values
-
dictionary
private final Dictionary dictionary
-
speller
private final Hunspell speller
-
-
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)
-
findSimilarDictionaryEntries
private java.util.List<GeneratingSuggester.Weighted<Root<java.lang.String>>> findSimilarDictionaryEntries(java.lang.String word, WordCase originalCase)
-
expandRoots
private java.util.List<GeneratingSuggester.Weighted<java.lang.String>> expandRoots(java.lang.String misspelled, java.util.List<GeneratingSuggester.Weighted<Root<java.lang.String>>> roots)
-
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)
-
processAffixes
private void processAffixes(boolean prefixes, java.lang.String word, GeneratingSuggester.AffixProcessor processor)
-
processAffixIds
private void processAffixIds(int affixLength, IntsRef affixIds, GeneratingSuggester.AffixProcessor processor)
-
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)
-
rankBySimilarity
private java.util.TreeSet<GeneratingSuggester.Weighted<java.lang.String>> rankBySimilarity(java.lang.String word, java.util.List<GeneratingSuggester.Weighted<java.lang.String>> expanded)
-
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)
-
-