Build Status Coverage Status Crates.io Version Crates.io LICENSE

ttaw

talking to a wall, a piecemeal natural language processing library.

A couple caveats

Functionality

Rhyme

```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")); ```

Alliteration

```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")); ```

CMUdict

```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() ]])) ); ```

Double Metaphone

```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" ); ```