Interface IDictionary
- All Superinterfaces:
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.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Dispose IDictionary.readArticles(String word) Read article's text.default List<DictionaryEntry>readArticlesPredictive(String word) Read article's text.default List<DictionaryEntry>retrieveArticles(Collection<String> words) default List<DictionaryEntry>
-
Method Details
-
readArticles
Read article's text.- Parameters:
word- The word to look up in the dictionary- Returns:
- List of entries. May be empty, but cannot be null.
- Throws:
Exception
-
readArticlesPredictive
Read article's text. Matching is predictive, so e.g. supplying "term" will return articles for "term", "terminology", "termite", etc. The default implementation simply callsreadArticles(String)for backwards compatibility.- Parameters:
word- The word to look up in the dictionary- Returns:
- List of entries. May be empty, but cannot be null.
- Throws:
Exception
-
retrieveArticles
- Throws:
Exception
-
retrieveArticlesPredictive
- Throws:
Exception
-
close
Dispose IDictionary. Default is no action.- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-