JVM
Installing
The ODict JVM SDK can be used with any JVM-based, including Java, Kotlin, Scala, and more. Unfortunately, the library has not yet been published to Maven.
For now, you can refer to the Contribution Guidelines to learn how to build the library from source.
The examples below are in Kotlin, but the API is the same across all languages.
Limitations
As of this writing, the JVM SDK is missing the following functionality:
Reading & writing dictionaries
import org.odict.*
// Compile dictionary from an XML path
val dict1: Dictionary = Dictionary.compile("dictionary.xml")
// Write XML directly to a compiled dictionary
val dict2: Dictionary = Dictionary.write("<dictionary></dictionary>", "dictionary.odict")
Performing lookups
import org.odict.*
// Load the dictionary from disk
val dict = Dictionary("dictionary.odict");
// Lookup entries, following aliases and splitting entries with a threshold of 2 characters
val entries: List<List<Entry>> = dict1.lookup("someone (somebody)", "once", follow = true, split = 2);
Indexing & searching
import org.odict.*
// Load the dictionary from disk
val dict = Dictionary("dictionary.odict");
// Index the dictionary
dict1.lexicon();
// Re-index and search the dictionary
val entries: List<Entry> = dict1.search("told", "me", index = true);
Listing all headwords
import org.odict.*
// Load the dictionary from disk
val dict = Dictionary("dictionary.odict");
// List all headwords
val headwords: List<String> = dict1.lexicon();