def check_spelling(checked_word, dist, word_list):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    s_m = student.build_scoring_matrix(alphabet, 2, 1, 0)
    result = []
    for word in word_list:
        a_m = student.compute_alignment_matrix(checked_word, word, s_m, True)
        score = student.compute_global_alignment(checked_word, word, s_m, a_m)
        changes = len(checked_word) + len(word) - score[0]
        if changes <= dist:
            result.append(word)
            print score[1], score[2]
    return result
def check_spelling(checked_word, dist, word_list):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    s_m = student.build_scoring_matrix(alphabet, 2, 1, 0)
    result = []
    for word in word_list:
        a_m = student.compute_alignment_matrix(checked_word, word, s_m, True)
        score = student.compute_global_alignment(checked_word, word, s_m, a_m)
        changes = len(checked_word) + len(word) - score[0]
        if changes <= dist:
            result.append(word)
            print score[1], score[2]
    return result
Exemplo n.º 3
0
def distance(word1, word2, s_m):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    a_m = student.compute_alignment_matrix(word1, word2, s_m, True)
    score = student.compute_global_alignment(word1, word2, s_m, a_m)
    changes = len(word1) + len(word2) - score[0]
    return changes
def distance(word1, word2, s_m):
    alphabet = "abcdefghijklmnopqrstuvwxyz"
    a_m = student.compute_alignment_matrix(word1, word2, s_m, True)
    score = student.compute_global_alignment(word1, word2, s_m, a_m)
    changes = len(word1) + len(word2) - score[0]
    return changes