Update context_parser.py
Browse files- context_parser.py +8 -9
context_parser.py
CHANGED
|
@@ -9,7 +9,6 @@ def detect_intent(text: str) -> str:
|
|
| 9 |
if not t:
|
| 10 |
return "answer"
|
| 11 |
|
| 12 |
-
# definition
|
| 13 |
if (
|
| 14 |
re.search(r"\bdefine\b", t)
|
| 15 |
or re.search(r"\bdefinition\b", t)
|
|
@@ -18,20 +17,18 @@ def detect_intent(text: str) -> str:
|
|
| 18 |
):
|
| 19 |
return "definition"
|
| 20 |
|
| 21 |
-
# hint
|
| 22 |
if re.search(r"\bhint\b", t) or re.search(r"\bclue\b", t) or re.search(r"\bnudge\b", t):
|
| 23 |
return "hint"
|
| 24 |
|
| 25 |
-
# step/instruction
|
| 26 |
if (
|
| 27 |
re.search(r"\bfirst step\b", t)
|
| 28 |
or re.search(r"\bnext step\b", t)
|
| 29 |
or re.search(r"\bwhat should i do first\b", t)
|
| 30 |
or re.search(r"\bgive me the first step\b", t)
|
|
|
|
| 31 |
):
|
| 32 |
return "instruction"
|
| 33 |
|
| 34 |
-
# walkthrough / step-by-step
|
| 35 |
if (
|
| 36 |
re.search(r"\bwalk ?through\b", t)
|
| 37 |
or re.search(r"\bstep by step\b", t)
|
|
@@ -40,24 +37,26 @@ def detect_intent(text: str) -> str:
|
|
| 40 |
):
|
| 41 |
return "walkthrough"
|
| 42 |
|
| 43 |
-
# explain
|
| 44 |
if re.search(r"\bexplain\b", t) or re.search(r"\bwhy\b", t):
|
| 45 |
return "explain"
|
| 46 |
|
| 47 |
-
# method
|
| 48 |
if (
|
| 49 |
re.search(r"\bmethod\b", t)
|
| 50 |
or re.search(r"\bapproach\b", t)
|
| 51 |
or re.search(r"\bhow do i solve\b", t)
|
| 52 |
or re.search(r"\bhow to solve\b", t)
|
|
|
|
| 53 |
):
|
| 54 |
return "method"
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
return "concept"
|
| 59 |
|
| 60 |
-
# plain answer / direct solve
|
| 61 |
if (
|
| 62 |
re.search(r"\bsolve\b", t)
|
| 63 |
or re.search(r"\bwhat is\b", t)
|
|
|
|
| 9 |
if not t:
|
| 10 |
return "answer"
|
| 11 |
|
|
|
|
| 12 |
if (
|
| 13 |
re.search(r"\bdefine\b", t)
|
| 14 |
or re.search(r"\bdefinition\b", t)
|
|
|
|
| 17 |
):
|
| 18 |
return "definition"
|
| 19 |
|
|
|
|
| 20 |
if re.search(r"\bhint\b", t) or re.search(r"\bclue\b", t) or re.search(r"\bnudge\b", t):
|
| 21 |
return "hint"
|
| 22 |
|
|
|
|
| 23 |
if (
|
| 24 |
re.search(r"\bfirst step\b", t)
|
| 25 |
or re.search(r"\bnext step\b", t)
|
| 26 |
or re.search(r"\bwhat should i do first\b", t)
|
| 27 |
or re.search(r"\bgive me the first step\b", t)
|
| 28 |
+
or re.search(r"\bspecific step\b", t)
|
| 29 |
):
|
| 30 |
return "instruction"
|
| 31 |
|
|
|
|
| 32 |
if (
|
| 33 |
re.search(r"\bwalk ?through\b", t)
|
| 34 |
or re.search(r"\bstep by step\b", t)
|
|
|
|
| 37 |
):
|
| 38 |
return "walkthrough"
|
| 39 |
|
|
|
|
| 40 |
if re.search(r"\bexplain\b", t) or re.search(r"\bwhy\b", t):
|
| 41 |
return "explain"
|
| 42 |
|
|
|
|
| 43 |
if (
|
| 44 |
re.search(r"\bmethod\b", t)
|
| 45 |
or re.search(r"\bapproach\b", t)
|
| 46 |
or re.search(r"\bhow do i solve\b", t)
|
| 47 |
or re.search(r"\bhow to solve\b", t)
|
| 48 |
+
or re.search(r"\bhow do i do this\b", t)
|
| 49 |
):
|
| 50 |
return "method"
|
| 51 |
|
| 52 |
+
if (
|
| 53 |
+
re.search(r"\bconcept\b", t)
|
| 54 |
+
or re.search(r"\bprinciple\b", t)
|
| 55 |
+
or re.search(r"\brule\b", t)
|
| 56 |
+
or re.search(r"\bwhat is the idea\b", t)
|
| 57 |
+
):
|
| 58 |
return "concept"
|
| 59 |
|
|
|
|
| 60 |
if (
|
| 61 |
re.search(r"\bsolve\b", t)
|
| 62 |
or re.search(r"\bwhat is\b", t)
|