Question: C++ Functions: Write a program pronounce that Lets the user input a word (lets call the input word W ). We are going to use
C++ Functions:
Write a program pronounce that Lets the user input a word (lets call the input word W).
We are going to use The CMU Pronouncing Dictionary( http://www.speech.cs.cmu.edu/cgi-bin/cmudict ) as our reference. It is available as a simply formatted plain text file, a direct link to it .0.7a (http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict.0.7a). It is required to utilize this file in the program (open, read it )
If the word is not found in the dictionary, print Not found. Otherwise, report:
Programming Task
Write a program pronounce.cpp that
Lets the user input a word (lets call the input word W).If the word is not found in the dictionary, print Not found. Otherwise, report:
Pronunciation: the pronunciation of the word W (as given in the dictionary),
Identical:: other words from the dictionary with the same pronunciation as W,
Add phoneme : words that can be obtained from W by adding one phoneme,
Remove phoneme : words that can be obtained from W by removing one phoneme,
Replace phoneme : words that can be obtained from W by replacing one phoneme.
In linguistics, a phoneme is a perceptually distinct units of sound that distinguishes one word from another, for example p, b, d, and t in the English words pad, pat, bad, and bat. When listing words, include all words from the dictionary that meet the criteria, the order of listed words should be the same as they appear in the dictionary. Your program should expect that the dictionary file cmudict.0.7a is located in the current working directory.
User input should be case-insensitive (accepting donut, DONUT, DOnUt, etc.)Please, dont make complex user interface that allows multiple queries. The program should just ask for one word, report the answer, and exit. See examples below.
DRAFT Pronunciation : D R AE1 F T Identical : DRAUGHT Add phoneme : DRAFT'S DRAFTEE DRAFTER DRAFTS DRAFTY DRAUGHTS Remove phoneme : DAFT RAFT Replace phoneme : CRAFT DRIFT GRAFT KRAFFT KRAFT
I made two functions that do pronunciation and identical already. If you want please make your functions revolving around my functions as they work fine. SO please please help me with add phonme and remove phonme and replace phonme. It is recommendable to use functions and use basic constructs. (maps, pointers cannot be used) DO not worry about running time. Just simple program. I am including my own functions to help you out.
PLease make functions for the rest!
#include
void splitOnSpace(string s, string & before, string & after); //this funcstions splits the string on the first space it sees
string getProunication(string word){//pronouciation works string W=""; for (int i=0; i
string getIdenticial(string word){ //identical works string W=""; for (int i=0; i
void splitOnSpace(string s, string & before, string & after) { // reset strings before = ""; after = ""; // accumulate before space int i = 0; while (i < s.size() && !isspace(s[i])) { before += s[i]; i++; } // skip the space i++; // accumulate after space while (i < s.size()) { after += s[i]; i++; } //cout << "exits" << endl; }
int main(){//show call a word and then print out string word; getline(cin, word); cout< Please solve add, replace, or remove phonme. I did the first two parts above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
