Crate webster

Source
Expand description

§webster-rs

A Rust library containing an offline version of webster’s dictionary.

Add to Cargo.toml

webster = 0.3.0

Simple example:

fn main() {
    let word = "silence";

    let definition = webster::dictionary(word).unwrap();

    println!("{} definition: {}", word, definition);
}

The definitions are not great but they’ll do for simple projects if you need an open source local dictionary API.

§Runtime Decompression

In an effort to reduce binary size (naive storage weighs 9mb), the dictionary is stored in a compressed binary format in the executable (4mb) and then decompressed upon runtime access. The runtime container provides O(log n) access complexity and access time (anecdotally) faster than a BTreeMap.

Functions§

  • Translate a word. O(log n).
  • Decompress the binary-encoded dictionary ahead of time, so that all calls to dictionary are fast. The dictionary loading is managed for you, you don’t need to call this to use webster-rs.