Project 5 - A Spell Checker
Due - Thursday, May 17, 2007
The goal of this project is to give you more experience with
trees. For this project, you will write a spell checker. Your
program will read from a file a dictionary of words and store them
in a Binary Search Tree (BST). You will be responsible for
building the BST. Next, you will open a text file containing the
text to be spell checked. For each word in the file, you will
determine whether it exists in the BST. If so, you will assume
the word is spelled correctly. If not, you will provide the user
with several choices for a replacement using the algorithm below.
The user can either select one of the choices you provide, or
enter a new word. If the user chooses to enter a new word, you
must spell check that word as well. When your program has checked
the entire document, you will save the corrected text to the
original file.
For full credit, your BST will support (at least) the methods
insert, delete, and find. Note that you
need to support delete even though you may not use it for this
particular application.
The spell check algorithm you will use will work as follows. You
will use all of the strategies listed below to modify the
original, misspelled word. For each modified word, you will
determine whether it exists in the dictionary. If so, you will
provide the modified word as a choice.
- Strategy 1: Transpose every adjacent pair of letters in the word. For example, given the misspelled word cta, you would produce tca and cat. cat appears in the dictionary, so you would provide it as a choice for replacement.
- Strategy 2: Generate every sequence of characters with 1 letter removed. For example, given the misspelled work czat, you would produce zat, cat, czt, and cza.
- Strategy 3: Generate every possible sequence where a single letter is added. Try every possible letter in the alphabet for each position. For example, given ct, you would generate act, bct and so on, then cat, cbt, etc.
Download and use the dictionary available here OR the this dictionary .
For full credit on this assignment, you must come up with a strategy
for avoiding a running time of O(N) for the find operation. Hint: you
do not want to insert elements into a BST in sorted order.
Due 5:00PM, Thursday May 17, 2007
- Complete and submit your working code. Turn in a hard copy in class and place a copy of your .java files in /home/submit/cs112-s07/username.
- Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
- Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other
source including another text book, a web page, or another
student (current or former). You must provide citations for any
sources you have used in designing and implementing your program.
Sami Rollins