22C:21 Project 1 Guide
This is a sequence of 5 steps you might want to take to completing
Project 1.
At the end of each step you will have a program (or programs) that compiles
and correctly does what is expected in that step.
You are not required to follow these guidelines, but I believe
that following these will help you complete your project more quickly.
The grading of Project 1 will follow these rules:
The sequence of 5 steps
- Solve Problem 1 in Problem Set 6. This is the beginning of the
program SpellCheck.java.
- Write a program that reads a text file (for example, one of the
novels made available for Project 1) and produces as output a list
of all distinct words in the file.
The output should be written into a file called words.dat
and should contain one word per line.
With minor changes, you can use the classes
Record.java and
DynamicRecordDB.java
as the data structure for storing and searching for words.
This is the beginning of the program BuildDict.java.
- Extend the program written in Part 2 to be able to read from multiple
text files (as described in Project 1). Now the program has exactly the
functionality of buildDict.java, except that it is not using
a hash table to store and search for words.
Extend the program written in Part 1 to (i) read the list of words stored in
words.dat into a data structure, (ii) read a text file and check
for words that are mispelled, and (iii) output the text file with each
mispelled word flagged with a "*" following it.
In this step, you can use the classes
Record.java and
DynamicRecordDB.java
as the data structure for the spell checker.
Also, make sure that if the name of text file that you are
spellchecking is "foo" then the output is "foo.out."
At this stage we have a program that builds a dictionary and a program
that checks spellings.
- Now replace the DynamicRecordDB.java data structure by a hash table in buildDict.java as well as in
spellCheck.java.
Use hashing with chaining, as described in Project 1 handout.
You will have to slightly modify Lafore's linked list classes,
Link.java and
LinkList.java, for this.
Basically, the Link class needs to change so that each Link
object consists of a String and a pointer to the next Link.
Also, extend the functionality of the spelling checker to interact with
the user as described in Project 1 handout.
Do not bother to implement the P and N prompts at this
stage.
- Finally, implement the P and N prompts also.
This will involve modifying the hash table data structure to
accomodate a record with two strings.
Again, it is the Link class that
needs to change so that each Link
object consists of two String objects and a pointer to the next Link.
Additional Information: Based on questions that students have asked
me and the TAs, here are some additional notes on Project 1.
- There is some confusion with regards to how to deal with the
possibility that words will contain letters in lower case, upper case,
or both. Here are some rules to help you.
- BuildDict produces a list of lower case words.
- SpellCheck converts each word to lower case before looking
for it in the dictionary.
- If a word is spelled correctly, it should appear in the output file,
exactly as it appears in the input file.
- If a word is spelled incorrectly, and the user suggests a
replacement, then we use exactly what the user suggested (in whatever case).
This includes "replace all" as well.
It is therefore the user's responsibility to be careful when using replace all.
- When the user types A for Abort, your program should
not produce any output file.
Since this may happen after your program has already started writing into
an output file, it should close and delete this file before ending.
- In addition to the files you were asked to submit in Project 1 handout,
you should submit Record.java.
This is a simple class whose objects contain two strings.