File size: 1,462 Bytes
6733714
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
import re


def classify_intent(question: str) -> dict:
    q = question.lower()

    # --- CHEQUE BOUNCE (AAR) ---
    if "cheque bounce" in q or "cheque dishonour" in q:
        return {"intent": "aar_lookup", "confidence": 0.95}

    # --- JOB WORK RATE ---
    if "job work" in q and ("rate" in q or "%" in q):
        return {"intent": "jobwork_rate", "confidence": 0.9}

    # --- FORM LOOKUP ---
    if re.search(r"\b(form|apl-\d+|gst apl)\b", q):
        return {"intent": "form_lookup", "confidence": 0.95}

    # --- RATE COMPARISON ---
    if any(word in q for word in ["difference", "compare", "vs", "versus"]):
        if "%" in q or "percent" in q or re.search(r"\b\d{1,2}%\b", q):
            return {"intent": "rate_comparison", "confidence": 0.9}

    # --- RATE LOOKUP ---
    if any(word in q for word in ["rate", "gst rate", "%", "percent"]):
        return {"intent": "rate_lookup", "confidence": 0.85}

    # --- AAR / ADVANCE RULING ---
    if any(word in q for word in ["aar", "advance ruling"]):
        return {"intent": "aar_lookup", "confidence": 0.9}

    # --- ACT / SECTION LOOKUP ---
    if re.search(r"\bsection\s+\d+", q):
        return {"intent": "act_section_lookup", "confidence": 0.9}

    # --- PROCEDURE ---
    if any(word in q for word in ["how to", "procedure", "process", "steps"]):
        return {"intent": "procedure", "confidence": 0.8}

    # --- FALLBACK ---
    return {"intent": "general", "confidence": 0.5}