''' 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 text = url.get_contents( SPELLING_LIST_URL ) # Get all the words on the webpage as a large string spellings = text.split() # Get a list of words by splitting the string of words # get the user text as a list of words reply = input( "Enter text: " ) reply = reply.lower() words = reply.split() # consider the words one by one -- determine whether current word is misspelled. # Keep in mind we have a list of spellings that we want to check each word from our words list against to see if # it's spelled corectly (aka if it's in that list of spellings) - how might we do this? for word in words: # Look at each word one by one # if ( word in spellings ): # if the word is in the list spellings (list of correctly spelled words) # pass # else: # if word is not in spellings # print( word ) if ( word not in spellings ): # if the word is not in our list of correctly spelled words, it's misspelled print( '*' + word + '*', end=' ' ) # print out the misspelled word else: # if the word is spelled correctly (it is in spellings) print( word, end=' ' ) # print the word as is print() # all done