In: Computer Science
Write a program in python that corrects misspelled words. The input for the program is either a string or a list of strings. The output should be a string or a list depending on the input and should have the spellings corrected. The speller should be able to correct at least the words listed below. You are free to use any data structures we have covered so far including lists and dictionaries. Your program should be in autocorrect.py. Here is a list of words that are commonly misspelled: • acquire – aquire, adquire • acquit – aquit • beautiful – beatuful • guarantee – garantee, garentee, garanty • professor – professer • repetition – repitition • until – untill
Explanation:
here is the code which has the dictionary of incorrect to correct words.
Then it asks the user to enter a string or multiple strings separated by comma.
Then, each word is taken one by one and the correct word corressponding to it is printed on the screen.
Code:
words = {
"aquire": "acquire",
"adquire": "acquire",
"aquit": "acquit",
"beatuful": "beautiful",
"garantee": "guarantee",
"garentee": "guarantee",
"garanty": "guarantee",
"professer": "professor",
"repitition": "repetition",
"untill": "until"
}
strings = input("Enter a string or multiple strings separated by
comma: ")
strs = strings.split(",")
for i in range(len(strs)):
strs[i] = strs[i].strip()
print(strs[i],'-->', words[strs[i]])
output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!