|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractSet<DictionaryEntry<C>>
com.aliasi.dict.AbstractDictionary<C>
com.aliasi.dict.TrieDictionary<C>
C - the type of object stored in this dictionarypublic class TrieDictionary<C>
A 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 Summary | |
|---|---|
TrieDictionary()
Construct a trie-based dictionary. |
|
| Method Summary | |
|---|---|
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. |
DictionaryEntry<C>[] |
phraseEntries(String phrase)
Deprecated. |
Iterator<DictionaryEntry<C>> |
phraseEntryIt(String phrase)
Returns an iterator over the dictionary entries with the specified phrase. |
| Methods inherited from class com.aliasi.dict.AbstractDictionary |
|---|
categoryEntries, categoryEntryIt, categoryEntryList, entries, entryList, phraseEntryList, size |
| Methods inherited from class java.util.AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
|---|
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
|---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray |
| Constructor Detail |
|---|
public TrieDictionary()
| Method Detail |
|---|
@Deprecated public DictionaryEntry<C>[] phraseEntries(String phrase)
AbstractDictionaryImplementation Note: This implementation buffers the
results of AbstractDictionary.phraseEntryIt(String) in a collection and
then converts it to an array.
phraseEntries in interface Dictionary<C>phraseEntries in class AbstractDictionary<C>phrase - The phrase to look up.
public 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||