Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HELP PLEASE 3 Program Requirements Write a program, named rhymes.py . Prompt the user four times (don't print out any prompt text). Use the first

HELP PLEASE

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

3 Program Requirements Write a program, named rhymes.py . Prompt the user four times (don't print out any prompt text). Use the first as a filename; open the requested file, and read the contents; store it into a Python dictionary. Once you have read the contents of the pronunciation dictionary (and stored it into some internal data structure), look up all three of the words that you've been given. For each one, find the pronunciation of that word. Then, find all of the other words in the dictionary that rhyme with it. Print out all such words. Of course, since you are given three different words to search for, you will print out three very different sets of rhymes. These searches are entirely inde- pendent of each other; don't try to link them in any way. NOTE: You may assume that all 3 of the words that the user enters are in your pronunciation dictionary. However, it is conceivable that some of them might not have any rhymes. (See below for how to print that.) 3.1 Output For each of the words that you are given, print out the word, and then the list of all of its rhymes (one per line, and sorted alphabetically), followed by a blank line. For example, if your three words are silly, sour, and four," your output might be: Rhymes for: SILLY CHILE CHILI LILLY Rhymes for: SOUR DOUR OVERPOWER SHOWER THREE-HOUR TOWER Rhymes for: FOUR BOER DOOR STORE (If, during any search, you find the same word twice, only print it once. However, if you find the same word as rhymes of multiple user requests, print it out in every applicable rhyme-list.) If a word doesn't have any rhymes, then print the line -- none found -- in place of any words: Rhymes for: DIFFICULT -- none found -- 3.2 Case Sensitivity Throughout this program, all data (read from the pronunciation dictionary, or words-to-search provided by the user) should be treated as case insensitive. However, in order to make it possible to auto-grade this assignment, you must print out your results in ALL CAPS (except as shown in the example above). 3.3 Multiple Pronunciations Some words have multiple pronunciations in the dictionary. Some of these are simply different pronunciations of the same word, like necessity:" NECESSITY NAHO S EH1 S AHO T IYO NECESSITY NAHO S EH1 S IHO T IYO Others, of course, are homonyms, like "read: READ REH1 D READ RIY1 D When you encounter this, you must record all versions of each such word, and your search must consider all of them. That is, if the user types read at the input, then you must list both EMBED and NEED as rhymes, since you don't know which pronunciation of "read the user intended. Likewise, if the user types "need, you must print out READ (since "need rhymes with one of the pronunciations of read); you must also print out "READ if they ask for "embed. 2.2 How Phonemes Work The pronunciation dictionaries used in this assignment are based on the system used in the Carnegie Mellon Pronunciation Dictionary. Basically, they have build a list of all of the sounds used in English, and have built a very long list of words, along with the pronunciation(s) for each word. (Some words have multiple pronunciations.) The pronunciation is broken into "phonemes," which are basic units of sound; each possible phoneme is represented by a string of letters. For instance, the "uh" sound in hut is represented by AH. In the pronunciation dictionary, the entry for "hut looks like this: HUT HH AH T which means that the word is made up of three phonemes. (Note that phonemes are not the same as syllables: a syllable can contain many phonemes.) 2.3 Accents In most (not all) words, some of the phonemes have "stress - meaning that they are emphasized more than the rest. There are three possible types of stress; each is represented by a number attached to the phoneme: 0: no stress 1: primary stress 2 : secondary stress For instance, consider the words weekly and computerize. The primary stress is on the second, and the sixth, phonemes, respectively: WEEKLY W IY1 K L IYO COMPUTERIZE K AHO M P Y UW1 T ERO AY2 Z 3 Program Requirements Write a program, named rhymes.py . Prompt the user four times (don't print out any prompt text). Use the first as a filename; open the requested file, and read the contents; store it into a Python dictionary. Once you have read the contents of the pronunciation dictionary (and stored it into some internal data structure), look up all three of the words that you've been given. For each one, find the pronunciation of that word. Then, find all of the other words in the dictionary that rhyme with it. Print out all such words. Of course, since you are given three different words to search for, you will print out three very different sets of rhymes. These searches are entirely inde- pendent of each other; don't try to link them in any way. NOTE: You may assume that all 3 of the words that the user enters are in your pronunciation dictionary. However, it is conceivable that some of them might not have any rhymes. (See below for how to print that.) 3.1 Output For each of the words that you are given, print out the word, and then the list of all of its rhymes (one per line, and sorted alphabetically), followed by a blank line. For example, if your three words are silly, sour, and four," your output might be: Rhymes for: SILLY CHILE CHILI LILLY Rhymes for: SOUR DOUR OVERPOWER SHOWER THREE-HOUR TOWER Rhymes for: FOUR BOER DOOR STORE (If, during any search, you find the same word twice, only print it once. However, if you find the same word as rhymes of multiple user requests, print it out in every applicable rhyme-list.) If a word doesn't have any rhymes, then print the line -- none found -- in place of any words: Rhymes for: DIFFICULT -- none found -- 3.2 Case Sensitivity Throughout this program, all data (read from the pronunciation dictionary, or words-to-search provided by the user) should be treated as case insensitive. However, in order to make it possible to auto-grade this assignment, you must print out your results in ALL CAPS (except as shown in the example above). 3.3 Multiple Pronunciations Some words have multiple pronunciations in the dictionary. Some of these are simply different pronunciations of the same word, like necessity:" NECESSITY NAHO S EH1 S AHO T IYO NECESSITY NAHO S EH1 S IHO T IYO Others, of course, are homonyms, like "read: READ REH1 D READ RIY1 D When you encounter this, you must record all versions of each such word, and your search must consider all of them. That is, if the user types read at the input, then you must list both EMBED and NEED as rhymes, since you don't know which pronunciation of "read the user intended. Likewise, if the user types "need, you must print out READ (since "need rhymes with one of the pronunciations of read); you must also print out "READ if they ask for "embed. 2.2 How Phonemes Work The pronunciation dictionaries used in this assignment are based on the system used in the Carnegie Mellon Pronunciation Dictionary. Basically, they have build a list of all of the sounds used in English, and have built a very long list of words, along with the pronunciation(s) for each word. (Some words have multiple pronunciations.) The pronunciation is broken into "phonemes," which are basic units of sound; each possible phoneme is represented by a string of letters. For instance, the "uh" sound in hut is represented by AH. In the pronunciation dictionary, the entry for "hut looks like this: HUT HH AH T which means that the word is made up of three phonemes. (Note that phonemes are not the same as syllables: a syllable can contain many phonemes.) 2.3 Accents In most (not all) words, some of the phonemes have "stress - meaning that they are emphasized more than the rest. There are three possible types of stress; each is represented by a number attached to the phoneme: 0: no stress 1: primary stress 2 : secondary stress For instance, consider the words weekly and computerize. The primary stress is on the second, and the sixth, phonemes, respectively: WEEKLY W IY1 K L IYO COMPUTERIZE K AHO M P Y UW1 T ERO AY2 Z

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions