Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Expected Behavior As in assignment 3. Your program should be in a file rhymes-oo.py . Errors Note: The specification has changed from Assignment 3 handle

Expected Behavior

As in assignment 3. Your program should be in a file rhymes-oo.py.

Errors

Note: The specification has changed from Assignment 3 handle the following errors.

The pronunciation dictionary cannot be read. (Use a try statement to detect this.)

Program behavior: Give an error message and quit.

Error message: "ERROR: Could not open file " + filename

Some word in the pronunciation dictionary has a pronunciation with more than one primary stress.

Program behavior: Give an error message, discard the offending pronunciation, and continue processing.

The input word (for which the program is to find rhymes) is not in the pronunciation dictionary. (Use an assert statement to detect this.) Error message modified on 3/12/2017 to match the tester output.

Program behavior: Give an error message and quit.

Error message: "ERROR: " + word + " is not in the pronuciation dictionary"

Input format

As in assignment 3.

Output format

As in assignment 3.

Programming Requirements

Your program should implement the following classes:

class Word

An instance of this class represents a word.

Attributes: These should include:

the string that makes up the word;

a collection (e.g., list, set, or dictionary) of pronunciations for the word;

Methods: These should include:

methods to initialize, access, and (where appropriate) update the attributes specified above;

methods defined such that, given two Word objects w1 and w2, the expression

w1 == w2

is True if and only if w1 and w2 form a perfect rhyme.

__init__() and __str__() methods; and, optionally, a __repr__() method.

class WordMap

An instance of this class represents data structures and methods to associate words (strings) with the corresponding Word objects.

Attributes: These should include:

A dictionary that takes strings to the corresponding Word objects.

Methods: These should include:

a method to read in a pronunciation dictionary and use this to set the mapping from strings to Word objects;

a method to read in a word (string) and print out the words that rhyme with it.

__init__() and __str__() methods; and, optionally, a __repr__() method.

What to submit

For each of the two long problems, put all five black-box inputs into a single text file, named dates-tests.txt and rhymes-oo-tests.txt respectively.

Within each file, organize the tests as follows:

# Test ID. (a number for identification purposes, plus an indication of whether it is a regular/edge case/error test) # What aspect of the program's behavior this is testing # (English prose, one or two sentences). The test input (keep it as short as you can while meeting the test goals) # End of test

In some situations, it may be impossible to provide an actual test input (e.g., if the test input involves a nonexistent or unreadable file). In this case, provide a short English description (one or two sentences) of the test.

Submit at most two normal-behavior tests and at most two error-behavior tests. The fifth test can be either a normal-behavior test or an error-behavior test.

Grading criteria

The test cases you submit will be graded using the following criteria:

Do they test different things? Having a lot of tests that test the same thing is not useful.

Are they meaningful? Do they test some aspect of the program's behavior that makes sense to test given the assignment spec?

When to submit

The submission deadline is 7PM on Tues Oct 10.

Where to submit

Submit your files at http://gradeit.cs.arizona.edu/gradeit-v1/public/120/18sp/homework/turnin/hw06-bb.html.

Example

Here is an example of a black-box test file in the format described above.

# Test 1 (error) # This tests whether the program can handle radioactivity in the input The input is a large lump of Uranium-238 # End of test # Test 2 (error) # This tests whether the program handles negative numbers -27 # End of test # Test 3 (edge case) # This tests whether the program can handle an empty list as input [] # End of test # Test 4 (regular) # This tests the program's behavior on a non-empty list of numbers [1, 2, 3, 4] # End of test # Test 5 (regular) # This tests the program's behavior on a non-empty list of strings ['aaa', 'bbb', 'ccc'] # End of test

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_2

Step: 3

blur-text-image_3

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