コード例 #1
0
def test_levenshtein_lcs(text1, text2, expected_result):
    levenshtein_distance = char_metrics.Levenshtein()
    err = levenshtein_distance.calculate(text1, text2, "lcs") - expected_result
    assert -1e-5 < err < 1e-5
コード例 #2
0
def test_levenshtein_osa(text1, text2, expected_result):
    levenshtein_distance = char_metrics.Levenshtein()
    assert levenshtein_distance.calculate(text1, text2,
                                          osa=True) == expected_result