Spaces:
Runtime error
Runtime error
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, transcription) | |
phonetic = phonetic_match(original, transcription) | |
return sequence, phonetic | |