Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ In linguistics, a phoneme is a perceptually distinct units of sound that distinguish one word from another, for example p, b, d, and t

C++

In linguistics, a phoneme is a perceptually distinct units of sound that distinguish one word from another, for example p, b, d, and t in the English words pad, pat, bad, and bat

Programming Task

Write a program pronounce.cpp 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 is: cmudict.0.7a (http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict.0.7a).

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.

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.

Examples:

> accord Pronunciation : AH0 K AO1 R D Identical : ACORD Add phoneme : ACCORD'S ACCORDS MCCORD RECORD Remove phoneme : CHORD CORD Replace phoneme : ABOARD ADORED AFFORD AWARD SCORED

Thank you for help.

Please keep in mind to use basic constructs (loops, void functions, references, anything can be used, etc)

However we have not learned structures and classes and stuff like that.

The question and a basic function is given in this prompt. To make things easier here is a function that can be used for dividing a string into words, we can give you a helper function, which receives a string argument s, and splits it into two strings on the very first space it finds within the string s:

Example: "Fortune favors the bold" "Fortune" and "favors the bold".

void splitOnSpace(string s, string & before, string & after) { // reset strings before = ""; after = ""; // accumulate before space int i = 0; while (i < s.size() && not isspace(s[i])) { before += s[i]; i++; } // skip the space i++; // accumulate after space while (i < s.size()) { after += s[i]; i++; } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions