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
- Emit the surface form if it exists.
- Check exceptions (
*.excfiles). - Apply POS-specific suffix rules.
- 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>].