Craft 3

Beautiful Code
Ka-Ping Yee

Make sure you understand the material in Explore 3 before you do this assignment.

This assignment will be done in partners:

Chris — Calvin
Nadia — Karl
Kevin — Peter
Morgan — Michael
Varun — Scott
Rosie — Omair
Adam — Nerissa
Richard — Peterson
Jacob — Derek
Jason — Thanh
Hunter — Jun

Here we go!

The Problem

The overall goal is to check the spelling of words in a text file. The input file will contain punctuation; you should ignore all punctuation except apostrophes. A valid, checkable word starts with a letter and contains only letters and apostrophes. Some words may be capitalized; these should be checked as is. The dictionary will contain both capitalized and uncapitalized words.

Part Uno

Do this part separately.

Have a look at your partner's Assignment 2, Part 3. Assume that all the functions in the speling module have been implemented exactly according to your partner's specifications.

Write a program that will read a text file named input.txt and print a list of all the misspelled words. The misspelled words should be printed in alphabetical order, and each word should be printed once, followed by the number of occurrences in parentheses:

aghh (1)
aghhhh (1)
misspeling (5)

Here is an example of an input file, and here is the corresponding output.

Your program should import the speling module and use only whatever functions are necessary to accomplish the task. Avoid writing duplicate code for any work that can be done using functions in the module.

Of course, you won't be able to completely test this program because the module hasn't been written yet. But do the best you can to try to produce a program that you are reasonably sure will work, as long as the speling module is implemented correctly. For example, you can comment out parts of your program or substitute dummy routines for the missing functions, so that you can test the rest of your program.

Part Dos

Did you have to make any assumptions about the behaviour of the speling module in order to write your program? If any parts of the interface were underspecified or ambiguous, describe them here, and explain the assumptions you made.

Submit the first two parts before proceeding: .

Part Tres

Prepare a list of which module functions you used in your program. Meet with your partner in person. Bring the list of functions but do not bring your program or show your program to your partner. Give your partner the list of functions, and explain the assumptions you had to make while writing your program. Work together to refine your partner's module specification.

Part Cuatro

Implement your speling module according to your (possibly revised) specifications, but you can skip functions that your partner did not list. The module should read its dictionary from a text file called dict.txt that contains a list of the valid words, one word on each line. Here is an example of a dictionary file.

Work on your own, from your specifications only. Your partner should not have given you their program.

Some of you included functions for suggesting corrected words in your modules. This is a pretty hard general problem; you can try to implement this for fun if you like, but you don't have to. (In most cases, this should not be among the functions that your partner has listed for you to write, since the program does not need to use such a feature.)

The dictionary will contain both capitalized and uncapitalized words. If you encounter a capitalized word and the uncapitalized form is in the dictionary, that's okay. If a word is capitalized in the dictionary but appears uncapitalized in the text, consider that a spelling mistake.

Upload your module here.

Part Cinco

Did you have to change your specifications when you met with your partner? Did you have to change them in order to successfully implement your module? If you did, what changes did you have to make, and why did you make them?

When you're done, submit these last two parts: .

This assignment is due on Monday 10 February at 6 pm. Both partners will get a bonus if either partner completes the assignment at least 24 hours early. Share the love.