Downloading Dictionaries
ODict can load dictionaries from the remote registry as well as from local files. Remote names use the form dictionary/language, for example wiktionary/eng.
Download with the CLI
Section titled “Download with the CLI”odict download wiktionary/engBy default, downloaded dictionaries are cached in ODict’s config directory under dictionaries/<dictionary>/. The command stores the downloaded file as <language>.odict.
Use --output to choose a directory:
odict download wiktionary/eng --output ./dictionariesUse --no-cache when you always want a fresh copy:
odict download wiktionary/eng --no-cacheUse --retries to control retry behavior for remote loads:
odict download wiktionary/eng --retries 5Load remote dictionaries in code
Section titled “Load remote dictionaries in code”use odict::OpenDictionary;
#[tokio::main]async fn main() -> odict::Result<()> { let dictionary = OpenDictionary::load("wiktionary/eng").await?; println!("{:?}", dictionary.path()); Ok(())}from theopendictionary import OpenDictionary
dictionary = await OpenDictionary.load("wiktionary/eng")print(dictionary.lexicon()[:10])import { OpenDictionary } from "@odict/node";
const dictionary = await OpenDictionary.load("wiktionary/eng");console.log(dictionary.lexicon().slice(0, 10));Cache and retry options
Section titled “Cache and retry options”use odict::{ download::DictionaryDownloader, LoadOptions, OpenDictionary,};
let downloader = DictionaryDownloader::default() .with_caching(false) .with_out_dir("./dictionaries") .with_retries(5);
let dictionary = OpenDictionary::load_with_options( "wiktionary/eng", LoadOptions::default().with_downloader(downloader),).await?;from theopendictionary import ( LoadOptions, OpenDictionary, RemoteLoadOptions,)
dictionary = await OpenDictionary.load( "wiktionary/eng", LoadOptions( remote=RemoteLoadOptions( out_dir="./dictionaries", caching=False, retries=5, ) ),)const dictionary = await OpenDictionary.load("wiktionary/eng", { remote: { outDir: "./dictionaries", caching: false, retries: 5, },});