Assignment 9
- Due Jul 25, 2017 by 11:59am
- Points 5
- Submitting a file upload
Spell Checker
Your assignment is to write a simple spell checker. I will suggest several enhancements, but the key idea is the following.
The user supplies a word and a dictionary on the command line. If the word is not in the dictionary, your program should suggest some likely alternatives. The alternatives should include
Legal words you can reach by changing a single letter
Legal words you can reach by adding a single letter
Legal words you can reach by removing a single letter
Legal words you can reach by exchanging two adjacent letters, like thsi.
Your suggestions should appear in lexicographic order.
Extensions:
We have not considered the possibility that the writer hasrun two words together. Add that to your algorithm.
Take a text file and our dictionary as input. Print each word in the text file that is not in the dictionary, and make suggestions.
Using the text for Emma, count the number of times Austin uses the words in our dictionary, and order your suggested corrections by popularity.
Sample Output
$ python spellcheck.py thme ../words.txt
Saw 9 suggestions
tame
thae
the
thee
them
theme
thyme
time
tome
$ python spellcheck.py ther ../words.txt
Saw 15 suggestions
ether
her
ither
other
the
thee
their
them
then
there
therm
thew
they
thir
tier
$ python spellcheck.py "" ../words.txt
Saw 0 suggestions
% python spellcheck.py abcdefghijklmnoprstuvwxyz ../words.txt
Saw 0 suggestions