def total_distance(observed_sentence, corrected_sentence):
"""Calculates the total distance between the two given sentences.
Args:
observed_sentence: Observed sentence.
corrected_sentence: Corrected sentence.
Returns:
Total Levenshtein distance between the two sentences.
"""
total_distance = 0
observed_words = list(observed_sentence)
corrected_words = list(corrected_sentence)
for i in range(len(observed_words)):
comparable_words = observed_words[i], corrected_words[i]
total_distance += editdistance.eval(*comparable_words)
return total_distance
corrector.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录