Crate wordnet_morphy

Crate wordnet_morphy 

Source
Expand description

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;

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);
}

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

Structs§

LemmaCandidate
A lemma candidate paired with its POS and provenance.
Morphy
Minimal morphy implementation parameterised by caller-provided existence checks.

Enums§

CandidateSource
Where a candidate lemma originated.