I just made a small program to spell check a provided sentence and point errors in the sentence. Actually, the program creates a list by reading data from text file which contains dictionary words and from there it tells whether the inputted word/s are in dictionary or not. I would like to extend my program further by also adding a suggestion list to suggest user words similar to the incorrect word/s they entered so that they can modify their sentence accordingly. How would i be able to suggest similar words?
Here is the code snippet:-
def check(): print '*'*8+" Program to check spelling errors in a sentence you entered "+'*'*8 print "write some text in english" text=raw_input("Start: ") tex=text.lower() print tex textcheck=tex.split(' ') dic=open('D:\Mee Utkarsh\Code\Python\DictionaryE.txt','r') origdic=dic.read() origdicf=origdic.split('\n') errorlist= correctwordlist= for words in textcheck: if words in origdicf: correctwordlist.append(words) elif words not in origdicf: errorlist.append(words) else: pass for x in textcheck: if x.isdigit(): correctwordlist.append(x) errorlist.remove(x) print '-'*50 print 'Error words list' a=1 while a==1: if errorlist==: print 'No Error!' a=a+1 else: for x in errorlist: print '\b',x,' ' a+=1 print '-'*50 y=1 print 'Correct Words list' while y==1: if correctwordlist==: print 'Sentence Full of Errors' y=y+1 else: for x in correctwordlist: print '\b',x,' ' y=y+1 print '-'*50