| import re | |
| def classify_question(question_text: str, category: str) -> dict: | |
| q = question_text.lower() | |
| if category == "Quantitative": | |
| if "percent" in q or "%" in q: | |
| if "then" in q: | |
| return {"topic": "percent", "type": "successive_percent"} | |
| return {"topic": "percent", "type": "percent_change"} | |
| if "ratio" in q: | |
| return {"topic": "ratio", "type": "ratio_total"} | |
| if "probability" in q or "chosen at random" in q: | |
| return {"topic": "probability", "type": "simple_probability"} | |
| if "divisible" in q or "remainder" in q: | |
| return {"topic": "number_theory", "type": "divisibility"} | |
| if "|" in q: | |
| return {"topic": "algebra", "type": "absolute_value"} | |
| if "circle" in q or "radius" in q or "circumference" in q: | |
| return {"topic": "geometry", "type": "circle_geometry"} | |
| if "average" in q or "mean" in q: | |
| return {"topic": "statistics", "type": "average"} | |
| if "sequence" in q: | |
| return {"topic": "sequence", "type": "geometric_sequence"} | |
| if "=" in q: | |
| return {"topic": "algebra", "type": "equation"} | |
| return {"topic": "quant", "type": "general"} | |
| if category == "DataInsight": | |
| if "percent" in q: | |
| return {"topic": "percent", "type": "percent_change"} | |
| if "mean" in q or "median" in q: | |
| return {"topic": "statistics", "type": "distribution"} | |
| if "correlation" in q or "scatter" in q: | |
| return {"topic": "statistics", "type": "correlation"} | |
| return {"topic": "data", "type": "general"} | |
| if category == "Verbal": | |
| if "meaning" in q: | |
| return {"topic": "vocabulary", "type": "definition"} | |
| if "grammatically" in q: | |
| return {"topic": "grammar", "type": "sentence_correction"} | |
| if "argument" in q or "author" in q: | |
| return {"topic": "reasoning", "type": "argument_analysis"} | |
| return {"topic": "verbal", "type": "general"} | |
| return {"topic": "unknown", "type": "unknown"} |