Craft 4

Beautiful Code
Ka-Ping Yee

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

This assignment will be done individually.

Nerissa: use Chris's program with Calvin's module.
Varun: use Calvin's program with Chris's module.
Thanh: use Nadia's program with Karl's module.
Richard: use Karl's program with Nadia's module.
Jacob: use Jason's program with Thanh's module.
Omair: use Peter's program with Kevin's module.
Jason: use Morgan's program with Michael's module.
Karl: use Michael's program with Morgan's module.
Hunter: use Varun's program with Scott's module.
Jun: use Scott's program with Varun's module.
Morgan: use Rosie's program with Omair's module.
Derek: use Omair's program with Rosie's module.
David: use Adam's program with Nerissa's module.
Scott: use Nerissa's program with Adam's module.
Adam: use Richard's program with Peterson's module.
Kevin: use Peterson's program with Richard's module.
Peterson: use Jacob's program with Derek's module.
Nadia: use Derek's program with Jacob's module.
Rosie: use Jason's program with Thanh's module.
Chris: use Thanh's program with Jason's module.
Peter: use Hunter's program with Jun's module.
Calvin: use Jun's program with Hunter's module.

This week it looks like there are lot of parts, but you won't be writing any new scripts or modules: all you're going to do is read and modify code.

Here's the problem statement again.

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. If the text contains 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.

Første Seksjon

First, have a good look at the two pieces you've been given. Go to the pages for them and add comments on them: find at least one positive thing to say, and make at least one suggestion for improvement.

Then take the two pieces and make them work together. As you do this, keep a record of the integration process. Whenever you decide make a change to the program or module, note in your log the change you made and the reason why you did it. When you discover a bug, note the problem you observed, the cause of the problem, and how you decided to fix it.

Try to make as few changes as possible. Only change as much as is necessary to get the overall program working.

If you find that you have to fill in missing functionality, or you find the functionality is duplicated between the program and the module, you will have to decide where it belongs. To make this decision, think about how generally usable the functionality would be to other users of the dictionary module. Don't leave duplication in your result.

To test your program and module, try this input file with this dictionary. You should get something similar to this output.

Submit your record of changes here.

Annet Seksjon

Submit the working program here.

Tredje Seksjon

Submit the working module here.

Fjerde Seksjon

Extend the program now so that it reports not only how many times each misspelled word occurred, but the number of the line on which it occurred (counting from line 1 at the beginning of the file). The output should now show a list of line numbers in parentheses after each word, instead of the count of occurrences:

aghh (line 8)
aghhhh (line 15)
misspeling (lines 2, 9, 23)

Try to change the smallest amount of code possible to add this feature. Again, keep a record of changes you make as you work. Did you have to change the module as well as the program? If you did, what could have been better designed about the module so that you would only have had to change the program?

When you're done, submit your record of changes here.

Femte Seksjon

Submit the final working program here.

Sjette Seksjon

Submit the final working module here.

When you're all done, submit the assignment:


This assignment is due on Monday 17 February at 6 pm. You get a bonus if the assignment is submitted at least 24 hours early.