Update explainers/explainer_percent.py
Browse files- explainers/explainer_percent.py +12 -29
explainers/explainer_percent.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
# explainer_percent.py
|
| 2 |
-
|
| 3 |
import re
|
| 4 |
from models import ExplainerResult
|
| 5 |
|
|
@@ -22,7 +20,7 @@ def explain_percent_question(text: str) -> ExplainerResult | None:
|
|
| 22 |
if percent_matches:
|
| 23 |
givens.append(f"A percentage is given: {', '.join(percent_matches[:3])}")
|
| 24 |
else:
|
| 25 |
-
givens.append("A percent relationship is
|
| 26 |
|
| 27 |
if "of" in t:
|
| 28 |
givens.append("The wording uses an 'of' relationship")
|
|
@@ -32,38 +30,23 @@ def explain_percent_question(text: str) -> ExplainerResult | None:
|
|
| 32 |
|
| 33 |
relationships.append("This is a part-percent-whole relationship")
|
| 34 |
|
| 35 |
-
if "of" in t:
|
| 36 |
-
relationships.append("One quantity is being described as a percent of another quantity")
|
| 37 |
-
|
| 38 |
if "increase" in t:
|
| 39 |
-
relationships.append("
|
| 40 |
|
| 41 |
if "decrease" in t:
|
| 42 |
-
relationships.append("
|
| 43 |
|
| 44 |
-
if "original" in t or "
|
| 45 |
-
constraints.append("
|
| 46 |
|
| 47 |
-
|
| 48 |
-
constraints.append("Watch the comparison wording carefully")
|
| 49 |
-
|
| 50 |
-
asks_for = None
|
| 51 |
-
if "original" in t or "whole" in t:
|
| 52 |
-
asks_for = "the original whole value"
|
| 53 |
-
elif "what percent" in t or "what percentage" in t:
|
| 54 |
-
asks_for = "the missing percent"
|
| 55 |
-
elif "what is" in t or "find" in t or "how much" in t:
|
| 56 |
-
asks_for = "the missing value in the percent relationship"
|
| 57 |
|
| 58 |
trap_notes.extend([
|
| 59 |
"Do not confuse the part with the whole",
|
| 60 |
-
"Check whether you are solving for
|
| 61 |
-
"Make sure the percent is
|
| 62 |
])
|
| 63 |
|
| 64 |
-
if "increase" in t or "decrease" in t:
|
| 65 |
-
trap_notes.append("Do not mix up the original amount and the changed amount")
|
| 66 |
-
|
| 67 |
return ExplainerResult(
|
| 68 |
understood=True,
|
| 69 |
topic="percent",
|
|
@@ -73,10 +56,10 @@ def explain_percent_question(text: str) -> ExplainerResult | None:
|
|
| 73 |
relationships=relationships,
|
| 74 |
needed_concepts=[
|
| 75 |
"percent equation",
|
| 76 |
-
"part
|
| 77 |
-
"
|
| 78 |
],
|
| 79 |
trap_notes=trap_notes,
|
| 80 |
-
strategy_hint="
|
| 81 |
-
plain_english="The question is describing a percent relationship and asking you to identify
|
| 82 |
)
|
|
|
|
|
|
|
|
|
|
| 1 |
import re
|
| 2 |
from models import ExplainerResult
|
| 3 |
|
|
|
|
| 20 |
if percent_matches:
|
| 21 |
givens.append(f"A percentage is given: {', '.join(percent_matches[:3])}")
|
| 22 |
else:
|
| 23 |
+
givens.append("A percent relationship is described")
|
| 24 |
|
| 25 |
if "of" in t:
|
| 26 |
givens.append("The wording uses an 'of' relationship")
|
|
|
|
| 30 |
|
| 31 |
relationships.append("This is a part-percent-whole relationship")
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
if "increase" in t:
|
| 34 |
+
relationships.append("This may involve a percent increase from an original value")
|
| 35 |
|
| 36 |
if "decrease" in t:
|
| 37 |
+
relationships.append("This may involve a percent decrease from an original value")
|
| 38 |
|
| 39 |
+
if "original" in t or "base" in t:
|
| 40 |
+
constraints.append("Identify the original/base value carefully")
|
| 41 |
|
| 42 |
+
asks_for = "the missing value in the percent relationship"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
trap_notes.extend([
|
| 45 |
"Do not confuse the part with the whole",
|
| 46 |
+
"Check whether you are solving for percent, part, or whole",
|
| 47 |
+
"Make sure the percent is applied to the correct base value",
|
| 48 |
])
|
| 49 |
|
|
|
|
|
|
|
|
|
|
| 50 |
return ExplainerResult(
|
| 51 |
understood=True,
|
| 52 |
topic="percent",
|
|
|
|
| 56 |
relationships=relationships,
|
| 57 |
needed_concepts=[
|
| 58 |
"percent equation",
|
| 59 |
+
"part = percent × whole",
|
| 60 |
+
"base value identification",
|
| 61 |
],
|
| 62 |
trap_notes=trap_notes,
|
| 63 |
+
strategy_hint="Translate the sentence into a percent equation before calculating anything.",
|
| 64 |
+
plain_english="The question is describing a percent relationship and asking you to identify a missing value within that structure.",
|
| 65 |
)
|