Struct cmudict::Cmudict [] [src]

pub struct Cmudict { /* fields omitted */ }

A dictionary containing words & their pronunciations

Methods

impl Cmudict
[src]

[src]

Takes a path to a cmudict file and tries to construct a Cmudict struct

Example

extern crate cmudict;
use cmudict::Cmudict;

let dict = Cmudict::new("./resources/cmudict.dict")?;

[src]

Downloads the latest cmudict from https://raw.githubusercontent.com/cmusphinx/cmudict/master/cmudict.dict and uses it to construct a new Cmudict struct

NB: this will create a temporary directory (using https://crates.io/crates/tempdir) to place the dictionary in

Example

extern crate cmudict;
use cmudict::Cmudict;

let dict = Cmudict::download()?;

[src]

Look for a word in the dictionary, and retrieve it's pronunciation

Example

extern crate cmudict;

use cmudict::{Cmudict, Symbol, Stress};

let dict = Cmudict::new("./resources/cmudict.dict")?;
let rust = dict.get("rust");

assert!(rust.is_some());
assert_eq!(
    rust.unwrap().pronunciation(),
    &[Symbol::R,
      Symbol::AH(Stress::Primary),
      Symbol::S,
      Symbol::T]
);

Trait Implementations

impl Debug for Cmudict
[src]

[src]

Formats the value using the given formatter.