public class DidYouMean
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
DidYouMean.AddingOneLetter
DidYouMean's producer thread that adds missing letters (e.g.
|
class |
DidYouMean.ChangingOneLetter
DidYouMean's producer thread that changes one letter (e.g.
|
private class |
DidYouMean.DeletingOneLetter
DidYouMean's producer thread that deletes extra letters (e.g.
|
private static class |
DidYouMean.headMatchingComparator
headMatchingComparator is used to sort results in such a way that words that match with the given words are sorted first
|
private class |
DidYouMean.ReversingTwoConsecutiveLetters
DidYouMean's producer thread that reverses any two consecutive letters (e.g.
|
private static class |
DidYouMean.wordLengthComparator
wordLengthComparator is used by DidYouMean to order terms by the term length
This is the default order if the indexSizeComparator is not used
|
Modifier and Type | Field and Description |
---|---|
private char[] |
alphabet |
private static char[] |
ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part1 |
private static char[] |
ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part2 |
private static char[] |
ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part3 |
private static char[] |
ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part4 |
private static char[] |
ALPHABET_HIRAGANA |
private static char[] |
ALPHABET_KANJI |
private static char[] |
ALPHABET_KATAKANA |
private static char[] |
ALPHABET_LATIN |
private static char[][] |
ALPHABETS |
static int |
AVAILABLE_CPU |
private boolean |
endsWithSpace |
private static int |
MinimumInputWordLength |
private static int |
MinimumOutputWordLength |
private boolean |
more |
private java.util.SortedSet<java.lang.StringBuilder> |
resultSet |
private Segment |
segment |
private long |
timeLimit |
private java.lang.StringBuilder |
word |
private static DidYouMean.wordLengthComparator |
WORD_LENGTH_COMPARATOR |
private int |
wordLen |
Constructor and Description |
---|
DidYouMean(Segment segment,
java.lang.String word0) |
Modifier and Type | Method and Description |
---|---|
private java.util.Collection<java.lang.StringBuilder> |
getSuggestions(long timeout,
boolean askIndex)
This method triggers the producer and consumer threads of the DidYouMean object.
|
java.util.Collection<java.lang.StringBuilder> |
getSuggestions(long timeout,
int preSortSelection,
boolean askIndex)
get suggestions for a given word.
|
private static java.util.Collection<java.lang.StringBuilder> |
getSuggestions(java.lang.String head,
java.lang.String tail,
long timeout,
int preSortSelection,
Segment segment)
return a string that is a suggestion list for the list of given words
|
private static boolean |
isAlphabet(char[] alpha,
char testchar) |
void |
reset() |
private void |
test(java.lang.StringBuilder s) |
private static final int MinimumInputWordLength
private static final int MinimumOutputWordLength
private static final char[] ALPHABET_LATIN
private static final char[] ALPHABET_KANJI
private static final char[] ALPHABET_HIRAGANA
private static final char[] ALPHABET_KATAKANA
private static final char[] ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part1
private static final char[] ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part2
private static final char[] ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part3
private static final char[] ALPHABET_CJK_UNIFIED_IDEOGRAPHS_Part4
private static final char[][] ALPHABETS
public static final int AVAILABLE_CPU
private static final DidYouMean.wordLengthComparator WORD_LENGTH_COMPARATOR
private final Segment segment
private final java.lang.StringBuilder word
private final boolean endsWithSpace
private final int wordLen
private long timeLimit
private final java.util.SortedSet<java.lang.StringBuilder> resultSet
private char[] alphabet
private boolean more
public DidYouMean(Segment segment, java.lang.String word0)
index
- a termIndex - most likely retrieved from a switchboard object.sort
- true/false - sorts the resulting TreeSet by index.count(); Warning: this causes heavy i/o.private static final boolean isAlphabet(char[] alpha, char testchar)
public void reset()
public java.util.Collection<java.lang.StringBuilder> getSuggestions(long timeout, int preSortSelection, boolean askIndex)
word0
- timeout
- preSortSelection
- the number of words that participate in the IO-intensive sortprivate static java.util.Collection<java.lang.StringBuilder> getSuggestions(java.lang.String head, java.lang.String tail, long timeout, int preSortSelection, Segment segment)
head
- - the sequence of words before the last space in the sequence, fixed (not to be corrected); possibly emptytail
- - the word after the last space, possibly empty or misspelledtimeout
- for operationpreSortSelection
- - number of suggestions to be computedprivate java.util.Collection<java.lang.StringBuilder> getSuggestions(long timeout, boolean askIndex)
word
- a String with a single wordtimeout
- execution time in ms.private void test(java.lang.StringBuilder s)