5 releases
Uses new Rust 2024
| 0.9.5 | Jul 11, 2025 |
|---|---|
| 0.9.4 | Jul 6, 2025 |
#2455 in Data structures
268 downloads per month
66KB
1.5K
SLoC
POETRIE
Poetrie means poetic trie. Poetrie is designated for searching common suffixes of words.
Basic Usage
classic use case
let mut poetrie = Poetrie::nw();
let words = ["analytics", "metrics", "ethics", "Acoustics"]
.map(|x| Entry::new_from_str(x).unwrap());
for w in words {
poetrie.it(&w);
}
let probe = Entry::new_from_str("lyrics").unwrap();
let matchee = poetrie.sx(&probe);
assert_eq!(Ok(String::from("metrics")), matchee);
let probe = Entry::new_from_str("solemn").unwrap();
assert_eq!(Err(FindErr::NoJointSuffix), poetrie.sx(&probe));
handy use case
Thinking about what could be good rhyming with word of choice, simple try search for that suffix directly. Let say, having "lyrics" as word without match, thinking it should rhyme with something ending with "ynx".
let mut poetrie = Poetrie::nw();
let words = ["lynx", "index"].map(|x| Entry::new_from_str(x).unwrap());
for w in words {
poetrie.it(&w);
}
let probe = Entry::new_from_str("ynx").unwrap();
let matchee = poetrie.sx(&probe);
assert_eq!(Ok(String::from("lynx")), matchee);
Now, one goes: "As the paws in a snow,
laid down by lightening lynx,
my word goes there and forth,
composing the aerial lyrics.".