C - the type of object stored in this dictionarypublic class TrieDictionary<C> extends AbstractDictionary<C> implements Serializable, Compilable
TrieDictionary stores a dictionary using a character
trie structure. This requires a constant amount of space for each
entry and each prefix of an entry's string. Lookups take an amount
of time proportional to the length of the string being looked up,
with each character requiring a lookup in a map. The lookup is
done with binary search in this implementation in time proportional
to the log of the number of characters, for a total lookup time
of O(n log c) where n is the
number of characters in the string being looked up and c
is the number of charactes.
Tries are a popular data structure; see the Wikipedia Trie topic for
examples and references. Tries are also used in the language model
classes TrieCharSeqCounter and TrieIntSeqCounter and the compiled forms of all of
the language models.
Serializable
and LingPipe Compilable interfaces to write the contents
of a trie dictionary to an object output. Both approaches produce
the same result and the dictionary read back in will be an instance
of TrieDictionary and equivalent to the dictionary that
was serialized or compiled.| Constructor and Description |
|---|
TrieDictionary()
Construct a trie-based dictionary.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEntry(DictionaryEntry<C> entry)
Equal entries will be ignored.
|
void |
compileTo(ObjectOutput out)
Compile the entries in this dictionary to the specified object output.
|
Iterator<DictionaryEntry<C>> |
iterator()
Returns an iterator over all of the dictionary entries
for this dictioniary.
|
Iterator<DictionaryEntry<C>> |
phraseEntryIt(String phrase)
Returns an iterator over the dictionary entries with the
specified phrase.
|
categoryEntryIt, categoryEntryList, entryList, phraseEntryList, sizeequals, hashCode, removeAlladd, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toStringpublic Iterator<DictionaryEntry<C>> phraseEntryIt(String phrase)
AbstractDictionaryImplementation Note: This implementation filters the
result of AbstractCollection.iterator() for entries with a matching
phrase.
phraseEntryIt in interface Dictionary<C>phraseEntryIt in class AbstractDictionary<C>phrase - The phrase to look up.public void addEntry(DictionaryEntry<C> entry)
addEntry in interface Dictionary<C>addEntry in class AbstractDictionary<C>entry - Dictionary entry to add.public Iterator<DictionaryEntry<C>> iterator()
iterator in interface Iterable<DictionaryEntry<C>>iterator in interface Collection<DictionaryEntry<C>>iterator in interface Set<DictionaryEntry<C>>iterator in class AbstractCollection<DictionaryEntry<C>>public void compileTo(ObjectOutput out) throws IOException
compileTo in interface CompilablecompileTo in class AbstractDictionary<C>out - Object output to which to write the dictionary.IOException - If there is an underlying I/O error during
the write.Copyright © 2016 Alias-i, Inc.. All rights reserved.