''' Purpose: spell check a line of input ''' # import get module for url supoprt import url # define link for spelling dictionary WORDS_FOLDER_URL = 'http://www.cs.virginia.edu/~cs1112/datasets/words/' SPELLING_LIST_URL = WORDS_FOLDER_URL + 'most-common' # get the spelling list as a list of words spellings = url.get_text( SPELLING_LIST_URL ) spellings = spellings.split() # get the user text as a list of words reply = input( 'Enter text: ' ) reply = reply.lower() words = reply.split() # consider the user words one by -- determine whether word is misspelled. #we have a list of correct spellings and a list of inputed words... now whats next? #see if the words are the same as the correct spelled words - compare each word to the list of spellings - compare to most similar #we arent tring to find the "correct" word - we are just trying to see if it is correct or not #look at the current word and see if it is in spellings #for s in spellings : #^^ this is really messy - what will you do with each correctly spelled word - complicated - should check each word not the spellings for word in words : #look at each word and see if it is correctly spelled #see if the word is in spellings - how do we do that? if ( word in spellings ) : #for word in words - in a for statement the "in" is a sequence #but the "in" spellings is checking/operator #we are checking to see if the word is spelled correctly - we dont want to do anything (pass) pass else : #the word has been misspelled/ is not in the list of correctly spelled words print ( word ) if ( ( word in spellings ) == False ) : print ( word ) #this is another way to do it, if you dont want to use a pass #if it isnt in the word is spellings you want to print it if ( word not in spellings ) : print ( word ) #this works too! they would all get full credit #this one kinda reads the best # all done