コード例 #1
0
def get_phonetic_distances():
    pairs = combinations(phonemes.keys(), 2)
    distances = {}
    for pair in pairs:
        char1 = pair[0]
        char2 = pair[1]
        phoneme1 = phonemes[char1]
        phoneme2 = phonemes[char2]

        hamming_distance = EditDistance.get_distance(phoneme1, phoneme2)

        euclidean_distance = EuclideanDistance.get_distance(phoneme1, phoneme2)

        edit_distance = 0

        sum_distance = 0

        for i in range(len(phoneme1)):
            if (phoneme1[i] != phoneme2[i]):
                edit_distance += 1
            sum_distance += abs(phoneme1[i] - phoneme2[i])

        distances[(char1, char2)] = (hamming_distance, euclidean_distance, edit_distance, sum_distance)

    return distances
コード例 #2
0
ファイル: raw.py プロジェクト: WING-NUS/corpSearch
 def score(query, profile, data=None):
     return [EditDistance.between(query, profile.display_name)]
コード例 #3
0
ファイル: raw.py プロジェクト: WING-NUS/corpSearch
 def score(query, profile, data=None):
     return [EditDistance.between(query, profile.handle)]