audio-service / app /services /matching_service.py
uncertainrods's picture
init
fdec215
raw
history blame contribute delete
720 Bytes
from rapidfuzz import fuzz
def fuzzy_match(target: str, text: str) -> float:
return fuzz.partial_ratio(target, text)
def check_presence(transcript: str, name: str, dob: str, gotra: str):
# Name uses substring matching
name_present = name in transcript
# DOB and Gotra use fuzzy matching
dob_score = fuzzy_match(dob, transcript)
gotra_score = fuzzy_match(gotra, transcript)
result = {
"name_present": name_present,
"dob_present": dob_score > 80,
"gotra_present": gotra_score > 80,
"confidence_scores": {
"name": 100 if name_present else 0,
"dob": dob_score,
"gotra": gotra_score
}
}
return result