Expand description
Load WordNet dictionaries with full fidelity and zero-copy text.
This crate ingests the canonical data.*/index.* files, preserves every
field (lex_id, ss_type, pointer source/target indices, verb frames),
and exposes borrowed &str slices for all text. Callers choose between
memory-mapped files or owned buffers at runtime via LoadMode.
Public access is intentionally read-only (no pub fields), leaving room to
evolve internal storage while keeping a stable API surface.
§Features
- Zero-copy text: lemmas, pointer symbols, glosses, and indices borrow from the original bytes.
- Full-fidelity parsing: retains raw offsets, satellite adjectives, frames, and pointer source/target indices.
- Runtime backing choice: switch between mmap and owned buffers with
LoadMode::Mmap/LoadMode::Owned. - Convenience lookups: lemma existence, index entries, synset fetching, and a streaming iterator over all synsets.
§Example
use wordnet_db::{LoadMode, WordNet};
use wordnet_types::Pos;
let wn = WordNet::load_with_mode("/path/to/wordnet", LoadMode::Mmap)?;
let dog_index = wn.index_entry(Pos::Noun, "dog").expect("dog in index");
println!("dog synsets: {:?}", dog_index.synset_offsets);
for sid in wn.synsets_for_lemma(Pos::Noun, "dog") {
let syn = wn.get_synset(*sid).unwrap();
println!("{}: {}", syn.id.offset, syn.gloss.definition);
}For a runnable demo, see cargo run -p wordnet-db --example stats -- <dict>.
Structs§
- WordNet
- In-memory view of a WordNet dictionary backed by mmap or owned buffers.
Enums§
- Load
Mode - Strategy for loading dictionary files.