Assignment 3 - A Spell Checker using string and istringstream
due October 15
This assignment is, for the most part, a repeat of the first assignment, using the string and istringstream classes.
Your program should adhere to the following specifications:
- All char arrays must be replaced by string objects. You are to use string functions, no functions from <cstring> (in, fact, there is no need to include this header file).
- You will not need a "Word" class. This is to be replaced by the string class.
- In your Dictionary class you should read in the words just like before, using your addWordToDictionary() and resize() functions.
- The Dictionary::find() should work logically, just as it did before, but, of course, you are dealing with strings.
- To perform the "spell checking", your approach will be different. You will read one line at a time from the input document (Martin Luther King's "I have a Dream" speech.). You need an istringstream object here. Each input line should be "parsed" to extract one word at a time for spell checking.
- You will remove leading and trailing punctuation, just as before, but, of course, you are using string functions to do this.
- There are additional "spell checking" requirements.
- If a word is not found in the Dictionary and it ends in s, then strip off the s, and check again, the rest of the word. For example, if "frogs" is not found in the Dictionary, then try "frog" before you state that the word in not in the dictionary.
- If a word is not found in the Dictionary and it ends in 's, then strip off the 's, and check again, the rest of the word. For example, if "nation's" is not found in the Dictionary, then try "nation" before you state that the word in not in the dictionary.
- If a word is not found in the Dictionary and it ends in ed, then strip off the ed, and check again, the rest of the word. For example, if "wanted" is not found in the Dictionary, then try "want" before you state that the word in not in the dictionary. Note, this approach will not word for word like "liked" or "cried", but don't worry about it.
- When you declare that a word is not in the Dictionary, you must identify what line the misspelled word occurs on. (see output below)
- At the end of you output, you must print an overall count of the number of misspelled words. (Hint: you should be between 50 and 70).
- Note: Use the input files provided (there is a new "word" file.
Program output
Dictionary resized to capacity: 16
Dictionary resized to capacity: 32
Dictionary resized to capacity: 64
Dictionary resized to capacity: 128
Dictionary resized to capacity: 256
Dictionary resized to capacity: 512
Dictionary resized to capacity: 1024
Dictionary resized to capacity: 2048
Dictionary resized to capacity: 4096
Dictionary resized to capacity: 8192
Dictionary resized to capacity: 16384
Dictionary resized to capacity: 32768
Spell checking /deanza/data/IHaveADream.txt
Line 4: withering not in the Dictionary
Line 5: captivity not in the Dictionary
Line 7: sadly not in the Dictionary
...
Line 97: beautiful not in the Dictionary
Line 107: heightening not in the Dictionary
Line 107: alleghenies not in the Dictionary
Line 108: snowcapped not in the Dictionary
There are ?? in the document. <--- You figure out this number
ftp "word" file and "ihaveadream.txt" (this is a zip file)
Note: if you are unable to ftp these files, request them from the instructor via email.