Ttaw
a piecemeal natural language processing library
Install / Use
/learn @shnewto/TtawREADME
ttaw
talking to a wall, a piecemeal natural language processing library.
Functionality
-
Determine if two words rhyme using the Double Metaphone phonetic encoding
-
Determine if two words rhyme using CMUdict phonetic encoding
-
Determine if two words alliterate using the Double Metaphone phonetic encoding
-
Determine if two words alliterate using CMUdict phonetic encoding
-
Get the CMUdict phonetic encoding of a word
-
Get the Double Metaphone phonetic encoding of a word (port of words/double-metahone library)
Rhyme
extern crate ttaw;
use ttaw;
// Initialize the CmuDict with a path to the existing serialized CMU dictionary
// or a directoy containing it. If the dictionary doesn't exisit, it will be
// downloaded and serialized at the location specified by the path parameter.
let cmudict = ttaw::cmu::CmuDict::new("cmudict.json").unwrap();
assert_eq!(Ok(true), cmudict.rhyme("far", "tar"));
assert_eq!(Ok(true), ttaw::metaphone::rhyme("far", "tar"));
assert_eq!(Ok(false), cmudict.rhyme("shopping", "cart"));
assert_eq!(Ok(false), ttaw::metaphone::rhyme("shopping", "cart"));
// Deviations in cmu and metaphone
assert_eq!(true, ttaw::metaphone::rhyme("hear", "near"));
assert_eq!(Ok(false), cmudict.rhyme("hear", "near"));
Alliteration
extern crate ttaw;
use ttaw;
// Initialize the CmuDict with a path to the existing serialized CMU dictionary
// or a directoy containing it. If the dictionary doesn't exisit, it will be
// downloaded and serialized at the location specified by the path parameter.
let cmudict = ttaw::cmu::CmuDict::new("cmudict.json").unwrap();
assert_eq!(Ok(true), cmudict.alliteration("bounding","bears"));
assert_eq!(true, ttaw::metaphone::alliteration("bounding","bears"));
assert_eq!(Ok(false), cmudict.alliteration("lazy", "dog"));
assert_eq!(false, ttaw::metaphone::alliteration("lazy", "dog"));
CMUdict
extern crate ttaw;
use ttaw;
// Initialize the CmuDict with a path to the existing serialized CMU dictionary
// or a directoy containing it. If the dictionary doesn't exisit, it will be
// downloaded and serialized at the location specified by the path parameter.
let cmudict = ttaw::cmu::CmuDict::new("cmudict.json").unwrap();
assert_eq!(
cmudict.encoding(("unearthed"),
Ok(Some(vec![vec![
"AH0".to_string(),
"N".to_string(),
"ER1".to_string(),
"TH".to_string(),
"T".to_string()
]]))
);
Double Metaphone
extern crate ttaw;
use ttaw;
assert_eq!(ttaw::metaphone::encoding("Arnow").primary, "ARN");
assert_eq!(ttaw::metaphone::encoding("Arnow").secondary, "ARNF");
assert_eq!(
ttaw::metaphone::encoding("detestable").primary,
"TTSTPL"
);
assert_eq!(
ttaw::metaphone::encoding("detestable").secondary,
"TTSTPL"
);
Related Skills
himalaya
345.9kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
taskflow
345.9kname: taskflow description: Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layer
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
