public abstract class Lookup extends Object
CharSequence
suggestions.Modifier and Type | Class and Description |
---|---|
static class |
Lookup.LookupPriorityQueue
A
PriorityQueue collecting a fixed size of high priority Lookup.LookupResult |
static class |
Lookup.LookupResult
Result of a lookup.
|
Modifier and Type | Field and Description |
---|---|
static Comparator<CharSequence> |
CHARSEQUENCE_COMPARATOR
A simple char-by-char comparator for
CharSequence |
Constructor and Description |
---|
Lookup() |
Modifier and Type | Method and Description |
---|---|
void |
build(Dictionary dict)
Build lookup from a dictionary.
|
abstract void |
build(TermFreqIterator tfit)
Builds up a new internal
Lookup representation based on the given TermFreqIterator . |
abstract boolean |
load(InputStream input)
Discard current lookup data and load it from a previously saved copy.
|
abstract List<Lookup.LookupResult> |
lookup(CharSequence key,
boolean onlyMorePopular,
int num)
Look up a key and return possible completion for this key.
|
abstract boolean |
store(OutputStream output)
Persist the constructed lookup data to a directory.
|
public static final Comparator<CharSequence> CHARSEQUENCE_COMPARATOR
CharSequence
public void build(Dictionary dict) throws IOException
SortedTermFreqIteratorWrapper
or
UnsortedTermFreqIteratorWrapper
in such case.IOException
public abstract void build(TermFreqIterator tfit) throws IOException
Lookup
representation based on the given TermFreqIterator
.
The implementation might re-sort the data internally.IOException
public abstract List<Lookup.LookupResult> lookup(CharSequence key, boolean onlyMorePopular, int num)
key
- lookup key. Depending on the implementation this may be
a prefix, misspelling, or even infix.onlyMorePopular
- return only more popular resultsnum
- maximum number of results to returnpublic abstract boolean store(OutputStream output) throws IOException
output
- OutputStream
to write the data to.IOException
- when fatal IO error occurs.public abstract boolean load(InputStream input) throws IOException
input
- the InputStream
to load the lookup data.IOException
- when fatal IO error occurs.