talking to a wall, a piecemeal natural language processing library.
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
```rust 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();
asserteq!(Ok(true), cmudict.rhyme("far", "tar")); asserteq!(Ok(true), ttaw::metaphone::rhyme("far", "tar"));
asserteq!(Ok(false), cmudict.rhyme("shopping", "cart")); asserteq!(Ok(false), ttaw::metaphone::rhyme("shopping", "cart"));
// Deviations in cmu and metaphone asserteq!(true, ttaw::metaphone::rhyme("hear", "near")); asserteq!(Ok(false), cmudict.rhyme("hear", "near")); ```
```rust 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();
asserteq!(Ok(true), cmudict.alliteration("bounding","bears")); asserteq!(true, ttaw::metaphone::alliteration("bounding","bears"));
asserteq!(Ok(false), cmudict.alliteration("lazy", "dog")); asserteq!(false, ttaw::metaphone::alliteration("lazy", "dog")); ```
```rust 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();
asserteq!( cmudict.encoding(("unearthed"), Ok(Some(vec![vec![ "AH0".tostring(), "N".tostring(), "ER1".tostring(), "TH".tostring(), "T".tostring() ]])) ); ```
```rust extern crate ttaw; use ttaw; asserteq!(ttaw::metaphone::encoding("Arnow").primary, "ARN"); asserteq!(ttaw::metaphone::encoding("Arnow").secondary, "ARNF");
asserteq!( ttaw::metaphone::encoding("detestable").primary, "TTSTPL" ); asserteq!( ttaw::metaphone::encoding("detestable").secondary, "TTSTPL" ); ```