def suggest(word, cutoff=0.77):
"""
Given a domain and a cutoff heuristic, suggest an alternative or return the
original domain if no suggestion exists.
"""
if word in LOOKUP_TABLE:
return LOOKUP_TABLE[word]
guess = difflib.get_close_matches(word, MOST_COMMON_DOMAINS, n=1, cutoff=cutoff)
if guess and len(guess) > 0:
return guess[0]
return word
评论列表
文章目录