File size: 601 Bytes
c3c3a5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d3d2211
 
 
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)


# 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, transcription)
    phonetic = phonetic_match(original, transcription)
    return sequence, phonetic