Phase 3 - Autocorrect
Instructions: https://inst.eecs.berkeley.edu/~cs61a/su19/proj/typing_test/#phase-3-autocorrect
Problem 04: Autocorrect Skeleton
def autocorrect(user_input, words_list, score_function):
if user_input in words_list:
return user_input
score_log = {}
for word in words_list:
score_key = score_function(user_input, word)
if score_key not in score_log:
score_log[score_key] = word
return score_log[min(score_log)]Problem 05: First Score Function
def swap_score(word1, word2):
if len(word1) <= 0 or len(word2) <= 0:
return 0
else:
return (0 if word1[0] == word2[0] else 1) + swap_score(word1[1:], word2[1:])Problem 06: Second Score Function
Problem 07: Accuracy
Problem 08: Efficiency
Last updated