A spell checking program
Due: 3 Feb 2009
Educational objectives: Experience implementing a self-organizing linked list and a simple vector class, solving problems using the above classes, and implementing and using templates.
Statement of work: (i) Implement a linked list class that self-organizes as specified below and (ii) a templated vector class. (iii) Implement a simple spell checking program, which is a modification of that in assignment 1, but using the containers you implemented, instead of using STL containers.
Deliverables: Turn in a
makefile
and all header (*.h) and cpp (*.cpp) files that are needed to build your software. Turn in your development log too, which should be a plain ASCII text file calledLOG.txt
in your project directory. You will submit all of these as described in www.cs.fsu.edu/~asriniva/courses/DS09/HWinstructions.html.Requirements:
- Create a subdirectory called
proj2
.
- You will need to have a
makefile
in this directory. In addition, all the header and cpp files needed to build your software must be present here, as well as theLOG.txt
file.
- You should implement appropriate classes for the software. Your code should be well designed and object oriented.
- You should implement a templated
Vector
class in the file Vector.h (note the capitalization of the first letter inVector
). The following features must be implemented:(i) a default constructor that initializes an array of size 4, (ii) a destructor, (iii) void push_back(const T &e), (iv) the operator[], (v) int size( ) const, and (vi) void pop_back(). You may implement additional features, if you wish to. If you do not implement a copy constructor and an assignment operator, then you should prevent their use by making them private.
- You should implement a doubly-linked list class that self-organizes as described below. You must use this class to store words from the standard Unix dictionary mentioned below. Your implementation may be specific for this requirement, instead of being a generic templated class. You are free to choose the specific features you wish to implement, but they should be reasonable. For example, you will certainly need to implement a method that lets you add words into the list, and a method that lets you search for a word in the list.
- Your software will check the spellings of words in an input document, and enable a user to correct errors. The software is run by the user on the command line as follows:
Spell Filename
, whereFilename
is the name of the file whose spelling should be checked. Note that the first letter ofSpell
is capitalized.
- The software checks the spelling of each word in the file, starting from the first word and ending at the last word. (A suitable error message should be given if the file does not exist.) A word is defined as follows. A potential word is defined as a sequences of adjacent characters in the input file, separated by any of the following delimiters: whitespace (blanks, tabs, and newlines) or any of the following
! ( ) - : ; " , . ? /
. (A delimiter cannot be a part of a potential word). A word is defined as a potential word that contains only alphabetic characters or apostrophe. For example, consider the following line of text:It is easy to find words, and also potential words. "asd34" files's
. The following are words:It is easy to find words and also potential words files's
. The following is a potential word, but not a word:asd34
.
- A word is considered valid if it occurs in either (i) the standard dictionary
/usr/share/dict/words
(assuming you are running on the machinelinprog
) or (ii) in the user dictionary_Dictionary
in the user's home directory, if the latter exists. Note that a word should be considered correct if is identical to one in the above dictionaries, except that its first letter may be capitalized. However, capitalization differences at other locations should not be accepted. For example, the wordAbandon
should be considered correct if the dictionary containsabandon
. However,abAndon
should not be considered correct, unless one of the above dictionary contains the exact wordabAndon
.
- The software should store words from the standard dictionary in an object of the self organizing linked list class that you created. It should store words from the user dictionary in a
Vector
object. Each time it encounters a word, it should first check if that word is present in the standard dictionary (that is, in the linked list). If the word is present in the standard dictionary and the word has been encountered four times in the file (including the current instance), then that word should be moved to the front of the list. (This defines the self-organization operation.) If the word is not present in the standard dictionary, then the user dictionary is checked.
- Each time an incorrect word is encountered, the software presents the word to the user in the following format:
Wrong spelling: wrong-word
wherewrong-word
is the wrongly spelled word, and waits for a user response. The user may respond as given below, and the software should take the actions as specified below. Once all words have been processed, the software saves the corrected file, over-writing the original file. (Note that the corrected version is written back to disk only at this point, or if the user terminates the spell check, as described below.) The software should preserve the delimiters and potential words as they were in the original document, unless the user had them corrected.Possible user responses:
r corrected-word
Replacewrong-word
withcorrected-word
.R corrected-word
Replace the current and all future occurrences ofwrong-word
withcorrected-word
.i
Ignore wrong-word (that is, treat it as correct) for the current occurrence alone.I
Ignore wrong-word (that is, treat it as correct) for the current occurrence and all future ones.a
Add wrong-word to_Dictionary
in the user's home directory, creating this file if it is not already present. Also, treatwrong-word
as correct.q
Quit the spell check. Save the corrected file, including all corrections until this point. All words not checked should be assumed to be correct. Also, print the first three words in the self-organizing linked list before quitting.Sample input file and executable: A sample executable and input files will be provided later. The first person to find errors in our program will get a bonus point!
Bonus points (5):
You may get up to 5 additional points for significant extra work, such as implementing more features, or providing a GUI interface. Please obtain feedback from us prior to doing this. If you wish to get bonus points, then please submit your work as usual, but send an email to the TA. The TA will schedule a meeting with you, and you can demonstrate the special features of your software then.
Notes:
- Your program should not have any output other than those specified above.
- You should not use the STL
list
orvector
classes. You may use thestring
class. Please get my permission before using any other STL feature.- We will test your
Vector
class on an entirely different application. So it is important for this class to be generic and exactly as specified.
Last modified: 29 Jan 2009