back to projects page

Project 4

Spell Chekcer

Concepts Covered: Binary Search vs. Linear Search, Writing to a File, Spell Checking

Due: Tuesday, March 25 at midnight Tuesday, April 1 at midnight

Files you need: words

Turn In: SpellChecker.java, CheckSpelling.java, Comparison.java, README

Requirements: The SpellChecker.java file is a class that represents a spell checker (it should have a wordlist as an attribute and a method called check that takes in String and returns true if it is spelled correctly). The spelling may be checked by searching the wordlist of the SpellChecker for the word. In addition to implementing a boolean check method, you should implement two other versions of check that return integers. One of these should be implemented as a binary search (as your real check method should be) and the other should be implemented as a linear search. The integer that is returned should represent the number of words that the method had to look at before it determined whether or not the word was spelled correctly. In other words, you should implement the following methods:

Your CheckSpelling.java is a main program that actually checks the spelling of any number of specified files (whose names should be read in from the command line arguments). It should break the file up into words and send each one to the spell checker to see if it is found. If it is not found, it should offer the user the option of ignoring the word, ignoring the word for the rest of the spell check, or manually editing the word.

The program should write the corrected file to a new file called "[original_filename].corrected".

When your CheckSpelling program runs, it should print out the entire contents of the line where the word that is incorrectly spelled is found, and it should mark the word. For example, if

   I don't know how to spll very well.

were a line in your file, your program should stop upon finding the word "spll" and print out something like

   I don't know how to [spll] very well.
   "spll" is not recognized.

along with a list of appropriate actions that may be taken.

At the end of the CheckSpelling program, your code should print out the number of words contained in the file.

In the second part of the project, you should empirically test the differences in your two check methods. There are two different ways of testing the difference. One way is to actually time the method calls (using System.getCurrentTimeMillis()) and the other way is to compare the number of words that each method has to look at before determining whether the word is spelled correctly. Your comparison program should include several cases of both of these testing methods. It should also print out the results as an easily readable chart. Your README file should include a discussion of your results.

Extra Credit 1: You will earn 25 percent extra credit if you implement your spell-checker so it maintains a seperate "custom words" file that can be added. For example, your spell checker will not recognize "Semmy" so it should give an additional option of "adding to custom words list." In this case, your SpellChecker class will need to read both the custom words list and the original words list, and it will need to write the custom words list back out to a file after the spell checking is completed.

Extra Credit 2: You will earn 25 percent extra credit if you suggest words when an unknown word is found. It may be easiest just to suggest the words that would be closest to it in the word list.