Python - Spell Checker
► Problem Description:
For this problem, you'll first need to write code to read in the
list of english words from the text file: words.txt. It is
more than 40,000 lines long with no repeated words.
Next, you'll need to write two functions. The first should
be called 'isValidWord', you'll pass it a string (the potential word)
along with the list of words we acquired from 'words.txt', the function
will return 'true' if our word list did contain the string (so, it was
a valid word) or 'false' if it did not.
Finally, you'll write a function that accepts two arguments: The
misspelled word and the list of words from 'words.txt'. This function
should return back a list of possible words from the 'words.txt' file
that could be the word (or words) that the user was trying to spell. Call
this function 'getAlternatives'. Here are the typos/misspellings to look for:
► Example Output:
testing appears to be spelled correctly Could not find: 'dgo' in the dictionary, but here are some similar words: 1) dog 2) do 3) go 4) ago 5) duo 6) ego Could not find: 'ct' in the dictionary, but here are some similar words: 1) act 2) cat 3) cot 4) cut 5) at 6) it Could not find: 'berd' in the dictionary, but here are some similar words: 1) beard 2) bred 3) bed 4) bard 5) bead 6) bend 7) bird 8) herd 9) nerd Could not find: 'frabbit' in the dictionary, but here are some similar words: 1) rabbit Could not find: 'energyturtle' in the dictionary, but here are some similar words: 1) energy turtle Could not find: 'ttestingg' in the dictionary, and no similar words were found
► Source Code
All files (zip file)