File size: 978 Bytes
a1757c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
"""Debug _detect_language_mix function."""
import re
from validator import HINDI_RE, HINGLISH_TOKENS

message = "Dr. Meera, JIDA Oct issue shows fluoride cuts cavities by 38%. Your 124 high-risk patients should know. Want me to draft?"

print("MESSAGE:", message)
print()

# Check for Devanagari script
if HINDI_RE.search(message):
    print("✅ Found Devanagari script")
else:
    print("❌ No Devanagari script found")

print()

# Extract and check Hinglish tokens
tokens = re.findall(r"\b[a-z]+\b", message.lower())
print(f"Extracted tokens: {tokens}")
print()

print("Checking against HINGLISH_TOKENS:")
hits = []
for t in tokens:
    if t in HINGLISH_TOKENS:
        hits.append(t)
        print(f"  ✅ '{t}' found in HINGLISH_TOKENS")

print()
print(f"Total hits: {len(hits)}")
print(f"Needs >= 2 hits to return True, has {len(hits)}")

if len(hits) >= 2:
    print("RESULT: True (has Hindi mix)")
else:
    print("RESULT: False (no Hindi mix)")