public interface IDictionary
extends java.lang.AutoCloseable
Each dictionary format reader should implement this interface. Each instance of this interface represents one dictionary.
Implementers are encouraged to use DictionaryData
to store their
data. A simple implementation can just load its entire data at once, but we
don't recommend it because it's very memory-intensive.
Instead we recommend that you read the dictionary's index (article titles)
and store some short data, like article offsets into the dictionary file, as
the value. In your implementation of the readArticles*
methods
you can use these offsets to actually load the content from disk. The OS will
cache dictionary file against slow access.
See StarDict
for an example of the recommended deferred-loading
implementation, and LingvoDSL
for an example of an simpler, up-front
loading implementation.
Modifier and Type | Method and Description |
---|---|
default void |
close()
Dispose IDictionary.
|
java.util.List<DictionaryEntry> |
readArticles(java.lang.String word)
Read article's text.
|
default java.util.List<DictionaryEntry> |
readArticlesPredictive(java.lang.String word)
Read article's text.
|
java.util.List<DictionaryEntry> readArticles(java.lang.String word) throws java.lang.Exception
word
- The word to look up in the dictionaryjava.lang.Exception
default java.util.List<DictionaryEntry> readArticlesPredictive(java.lang.String word) throws java.lang.Exception
readArticles(String)
for
backwards compatibility.word
- The word to look up in the dictionaryjava.lang.Exception
default void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
java.io.IOException