File size: 639 Bytes
fe79a8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc08b68
 
fe79a8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import difflib
from fuzzywuzzy import fuzz


# Custom phonetic matching function
def phonetic_match(word1, word2):
    """
    Compares two words based on their phonetic similarity.
    """
    return fuzz.ratio(word1, word2) / 100


# Custom sequence matching function
def sequence_match(a, b):
    """
    Uses sequence matching to compare two sequences of words.
    """
    return difflib.SequenceMatcher(None, a, b).ratio()


def match(original, transcription):
    sequence = sequence_match(original.lower(), transcription.lower())
    phonetic = phonetic_match(original.lower(), transcription.lower())
    return sequence, phonetic