lab_dict
Devious Dictionaries: Cleverness Through Association
 All Classes Namespaces Files Functions Variables
PronounceDict Class Reference

PronounceDict class. More...

#include <pronounce_dict.h>

Collaboration diagram for PronounceDict:
[legend]

Public Member Functions

 PronounceDict (const std::string &pronun_dict_filename)
 Constructs a PronounceDict from a CMU pronunciation dictionary file. More...
 
 PronounceDict (const std::map< std::string, std::vector< std::string >> &pronun_dict)
 Constructs a PronounceDict from a CMU std::map mapping the word to a vector of strings which represent the pronunciation. More...
 
bool homophones (const std::string &word1, const std::string &word2) const
 Uses the dictionary to determine if the two words are homophones. More...
 

Private Attributes

std::map< std::string,
std::vector< std::string > > 
dict
 

Detailed Description

PronounceDict class.

Provides an interface for finding the pronunciation of a given word based on a pronunciation dictionary provided at construction. Also provides an interface for determining if two word share a pronunciation (they are homophones).

Author
Matt Joras
Date
Winter 2013

Constructor & Destructor Documentation

PronounceDict::PronounceDict ( const std::string pronun_dict_filename)

Constructs a PronounceDict from a CMU pronunciation dictionary file.

See http://www.speech.cs.cmu.edu/cgi-bin/cmudict .

Parameters
pronun_dict_filenameFilename of the CMU pronunciation dictionary.
PronounceDict::PronounceDict ( const std::map< std::string, std::vector< std::string >> &  pronun_dict)

Constructs a PronounceDict from a CMU std::map mapping the word to a vector of strings which represent the pronunciation.

Parameters
pronun_dictMaps a string word to a vector of strings representing its pronunciation.

Member Function Documentation

bool PronounceDict::homophones ( const std::string word1,
const std::string word2 
) const

Uses the dictionary to determine if the two words are homophones.

Parameters
word1First word to be tested.
word2Second word to be tested.
Returns
true if the two words are homophones, false otherwise (or one or both words weren't in the dictionary). Note: The word keys in the dictionary are stored in uppercase.

The documentation for this class was generated from the following files: