j-js commited on
Commit
309127c
·
verified ·
1 Parent(s): c763529

Update conversation_logic.py

Browse files
Files changed (1) hide show
  1. conversation_logic.py +72 -21
conversation_logic.py CHANGED
@@ -117,27 +117,42 @@ def _normalize_classified_topic(
117
  q = (question_text or "").lower()
118
  c = (category or "").strip()
119
 
120
- if t in {"general_quant", "general", "unknown", ""}:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  if c == "Quantitative":
122
- if "%" in q or "percent" in q:
123
- return "percent"
124
- if "ratio" in q:
125
- return "ratio"
126
- if "probability" in q or "chosen at random" in q:
127
- return "probability"
128
- if "divisible" in q or "remainder" in q or "prime" in q:
129
- return "number_theory"
130
- if "circle" in q or "triangle" in q or "perimeter" in q or "area" in q:
131
- return "geometry"
132
- if "=" in q or "what is x" in q or "what is y" in q:
133
- return "algebra"
134
- return "quant"
135
-
136
- if c == "DataInsight":
137
- return "data"
138
-
139
- if c == "Verbal":
140
- return "verbal"
141
 
142
  return topic
143
 
@@ -450,12 +465,48 @@ class ConversationEngine:
450
  question_text=solver_input,
451
  category=category,
452
  )
453
- inferred_category = classification.get("category") or category
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454
  question_topic = _normalize_classified_topic(
455
  classification.get("topic"),
456
  inferred_category,
457
  solver_input,
458
  )
 
459
  question_type = classification.get("type")
460
 
461
  resolved_intent = intent or detect_intent(user_text, help_mode)
 
117
  q = (question_text or "").lower()
118
  c = (category or "").strip()
119
 
120
+ if t not in {"general_quant", "general", "unknown", ""}:
121
+ return topic
122
+
123
+ if "%" in q or "percent" in q:
124
+ return "percent"
125
+
126
+ if "ratio" in q or ":" in q:
127
+ return "ratio"
128
+
129
+ if "probability" in q or "chosen at random" in q:
130
+ return "probability"
131
+
132
+ if "divisible" in q or "remainder" in q or "prime" in q or "factor" in q:
133
+ return "number_theory"
134
+
135
+ if "circle" in q or "triangle" in q or "perimeter" in q or "area" in q or "circumference" in q:
136
+ return "geometry"
137
+
138
+ if "mean" in q or "median" in q or "average" in q or "sales" in q or "revenue" in q:
139
  if c == "Quantitative":
140
+ return "statistics"
141
+ return "data"
142
+
143
+ if "=" in q or "what is x" in q or "what is y" in q or "integer" in q:
144
+ return "algebra"
145
+
146
+ if c == "DataInsight":
147
+ return "data"
148
+
149
+ if c == "Verbal":
150
+ return "verbal"
151
+
152
+ if c == "Quantitative":
153
+ return "quant"
154
+
155
+ return "general"
 
 
 
156
 
157
  return topic
158
 
 
465
  question_text=solver_input,
466
  category=category,
467
  )
468
+ inferred_category = classification.get("category") or category
469
+
470
+ if not inferred_category:
471
+ q = solver_input.lower()
472
+ if any(
473
+ k in q
474
+ for k in [
475
+ "percent",
476
+ "%",
477
+ "ratio",
478
+ "divisible",
479
+ "remainder",
480
+ "probability",
481
+ "circle",
482
+ "triangle",
483
+ "=",
484
+ ]
485
+ ):
486
+ inferred_category = "Quantitative"
487
+ elif any(
488
+ k in q
489
+ for k in [
490
+ "sales",
491
+ "revenue",
492
+ "median",
493
+ "mean",
494
+ "chart",
495
+ "table",
496
+ "scatter",
497
+ "distribution",
498
+ ]
499
+ ):
500
+ inferred_category = "DataInsight"
501
+ else:
502
+ inferred_category = "General"
503
+
504
  question_topic = _normalize_classified_topic(
505
  classification.get("topic"),
506
  inferred_category,
507
  solver_input,
508
  )
509
+ )
510
  question_type = classification.get("type")
511
 
512
  resolved_intent = intent or detect_intent(user_text, help_mode)