corrector.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:markov-sentence-correction 作者: anassinator 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号