Struct cmudict::Cmudict
[−]
[src]
pub struct Cmudict { /* fields omitted */ }
A dictionary containing words & their pronunciations
Methods
impl Cmudict
[src]
pub fn new<P: AsRef<Path>>(dict: P) -> Result<Cmudict>
[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")?;
pub fn download() -> Result<Cmudict>
[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()?;
pub fn get(&self, s: &str) -> Option<Rule>
[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] );