A spell checking program
Due: 16 Oct 2014
Educational objectives: Experience implementing a self-organizing linked list and solving problems using the above class.
Statement of work: (i) Implement a linked list class that self-organizes as specified below and (ii) implement a simple spell checking program, which is a modification of that in assignment 1, but using the container you implemented to store the dictionary.
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/DS14/HWinstructions.html.Requirements:
- Create a subdirectory called
proj3
.
- 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 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 and the user dictionary in separate objects of the self organizing linked list class that you created. (The standard dictionary includes strings that don't meet our requirements for a
word
. However, you may include these in your linked list if you wish to.) Each time it encounters a word in the file being checked, it should first check to see if that word is present in the standard dictionary. If the word is present in the standard dictionary and the word has been encountered at least 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:
Error: 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:
s corrected-word
Replacewrong-word
withcorrected-word
.S 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. Output the time taken, in seconds, to store the contents of the standard dictionary in the linked list. Then output the first three words in the self-organizing linked list for the standard dictionary before quitting.Sample file and executable: A sample executable and input files are available at
~cop4530/fall14/solutions/proj3
onlinprog
. Copy these to your directory and run./Spell test.txt
and enterq
on the first error message to see a sample output. The first person to find errors in our program will get a bonus point!Notes:
- Your program should not have any output other than those specified above.
- You should not use the STL
list
class. You may use thestring
class. Please get my permission before using any other STL feature.Copyright: Ashok Srinivasan, Florida State University.
Last modified: 30 Sep 2014