Update conversation_logic.py
Browse files- conversation_logic.py +26 -13
conversation_logic.py
CHANGED
|
@@ -222,12 +222,32 @@ def _specific_topic_from_question(question_text: str, fallback_topic: str, class
|
|
| 222 |
return "median"
|
| 223 |
if "range" in q:
|
| 224 |
return "range"
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
return "ratio"
|
|
|
|
| 231 |
if topic == "data" and any(k in q for k in ["dataset", "table", "chart", "graph"]):
|
| 232 |
return "statistics"
|
| 233 |
return topic
|
|
@@ -857,15 +877,8 @@ class ConversationEngine:
|
|
| 857 |
|
| 858 |
if fallback_pack and fallback_pack.get("topic") == "statistics":
|
| 859 |
qlow = (solver_input or "").lower()
|
| 860 |
-
wants_topic = input_type == "topic_query"
|
| 861 |
if any(k in qlow for k in ["variability", "spread", "standard deviation"]):
|
| 862 |
-
if
|
| 863 |
-
fallback_reply_core = (
|
| 864 |
-
"- This is a statistics / data insight question about variability (spread).\n"
|
| 865 |
-
"- Focus on how spread out each dataset is rather than the average.\n"
|
| 866 |
-
"- Compare how far the outer values sit from the middle value in each set."
|
| 867 |
-
)
|
| 868 |
-
elif resolved_help_mode == "answer":
|
| 869 |
fallback_reply_core = (
|
| 870 |
"- Notice this is asking about variability, which means spread, not the mean.\n"
|
| 871 |
"- Compare how far the smallest and largest values sit from the middle value in each dataset.\n"
|
|
|
|
| 222 |
return "median"
|
| 223 |
if "range" in q:
|
| 224 |
return "range"
|
| 225 |
+
|
| 226 |
+
ratio_like = any(
|
| 227 |
+
phrase in q
|
| 228 |
+
for phrase in [
|
| 229 |
+
"ratio",
|
| 230 |
+
"proportion",
|
| 231 |
+
"proportional",
|
| 232 |
+
"part to whole",
|
| 233 |
+
"out of",
|
| 234 |
+
"for every",
|
| 235 |
+
"in the same ratio",
|
| 236 |
+
"in proportion",
|
| 237 |
+
"directly proportional",
|
| 238 |
+
"inversely proportional",
|
| 239 |
+
]
|
| 240 |
+
)
|
| 241 |
+
ratio_like = ratio_like or bool(re.search(r"\b[a-z]\s*/\s*[a-z]\b", q))
|
| 242 |
+
ratio_like = ratio_like or bool(re.search(r"\b\d+\s*/\s*\d+\b", q))
|
| 243 |
+
ratio_like = ratio_like or bool(re.search(r"\b[a-z]\s*:\s*[a-z]\b", q))
|
| 244 |
+
ratio_like = ratio_like or bool(re.search(r"\b\d+\s*:\s*\d+\b", q))
|
| 245 |
+
ratio_like = ratio_like or bool(re.search(r"\b[a-z]+\s+to\s+[a-z]+\b", q))
|
| 246 |
+
ratio_like = ratio_like or bool(re.search(r"\b\d+\s+to\s+\d+\b", q))
|
| 247 |
+
|
| 248 |
+
if ratio_like:
|
| 249 |
return "ratio"
|
| 250 |
+
|
| 251 |
if topic == "data" and any(k in q for k in ["dataset", "table", "chart", "graph"]):
|
| 252 |
return "statistics"
|
| 253 |
return topic
|
|
|
|
| 877 |
|
| 878 |
if fallback_pack and fallback_pack.get("topic") == "statistics":
|
| 879 |
qlow = (solver_input or "").lower()
|
|
|
|
| 880 |
if any(k in qlow for k in ["variability", "spread", "standard deviation"]):
|
| 881 |
+
if resolved_help_mode == "answer":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 882 |
fallback_reply_core = (
|
| 883 |
"- Notice this is asking about variability, which means spread, not the mean.\n"
|
| 884 |
"- Compare how far the smallest and largest values sit from the middle value in each dataset.\n"
|