wordnet-morphy 0.1.2

WordNet morphology rules and lookup helpers for lemmas and inflections.
Documentation

WordNet-style morphological processing (morphy).

Faithful to the classic morphy algorithm: check exceptions, apply suffix rules, and verify candidates via a caller-provided lemma existence predicate. The crate is intentionally decoupled from any particular loader; it only depends on Pos and the callback you supply.

How it works

  1. Emit the surface form if it exists.
  2. Check exceptions (*.exc files).
  3. Apply POS-specific suffix rules.
  4. Deduplicate while preserving provenance (Surface, Exception, Rule).

Example

use wordnet_db::{LoadMode, WordNet};
use wordnet_morphy::Morphy;
use wordnet_types::Pos;

# fn main() -> anyhow::Result<()> {
let dict = "/path/to/wordnet";
let wn = WordNet::load_with_mode(dict, LoadMode::Mmap)?;
let morph = Morphy::load(dict)?;
let exists = |pos, lemma: &str| wn.lemma_exists(pos, lemma);

let cands = morph.lemmas_for(Pos::Verb, "running", exists);
for cand in cands {
    println!("{:?}: {}", cand.source, cand.lemma);
}
# Ok(()) }

For a runnable demo, see cargo run -p wordnet-morphy --example lookup -- <dict> [--demo|<word>].