Educational goals of this lab - verify that every student can
INSTRUCTIONS:
(80 points) Team Problem: Done during lab on Monday April 26
Yes, true spellchecking is much more complicated. How does the program figure out what word is probably what you meant and offer alternatives? How can the search be sped up? since it is what takes most of the time of checking. How can different forms of the same word (plurals, past tenses) be handled efficiently in the dictionary instead of just listing them all? You don't have to deal with any of these!
Sample runs: Example dictionary.txt
shark ocean teeth the building door window people through from awayExample story1.txt
A shark was chasing a fish through the ocean The ocean was next to a building The people ran away from the shark
Enter a filename to check: story1.txt Misspelled words: chasing fish next There were 3 misspelled words.
Description | Input (dictionary.txt file comma is newline) | Expected Output (return) |
---|---|---|
Dictionary with one word per line | angle, right, triangle, leg, longer, square | ['angle','right','triangle','leg','longer','square'] |
Dictionary with multiple words per line | castle tower, dragon knight sword, with | ['castle','tower','dragon','knight','sword','with'] |
Dictionary that is empty | just a blank line | [] |
Description | Input (dictionary.txt, story.txt file) | Expected Output (return) |
---|---|---|
Multiple misspelled words (one upper case) | angle, right, triangle, side, longer, square
Each leg of a right triangle is shorter than the hypotenuse | Misspelled words: each, shorter, than, hypotenuse, There were 4 misspelled words. |
One misspelled word | castle tower, dragon knight sword, with
The knight ran after the dragon | Misspelled words: after, There were 1 misspelled words. |
Empty dictionary, story file not empty | just a blank line
green eggs and ham | Misspelled words: green, eggs, There were 2 misspelled words. |
No misspelled words | four, guys, lived, town, small Four guys lived in a small town | There were 0 misspelled words. |
(15 points) Design
main function get the dictionary file (call the function below) ask the user for the filename to spell check open it turn the words in the file into a list of strings, one word per string close it for all the words in that list of words force the word to be lowercase if the word is more than 3 characters long and is not in the dictionary list report it as misspelled and count it report the count of misspelled words ---------------------------------------- function get the dictionary file preconditions - nothing postconditions - returns the list of good words from dictionary file assume dictionary file is called "dictionary.txt" open dictionary file read the file into one string split the string into words in a list (goodlist) close dictionary file return goodlist -----------------------------------------
(55 points) Implement this program.