Update solver_ratio.py
Browse files- solver_ratio.py +7 -2
solver_ratio.py
CHANGED
|
@@ -44,11 +44,16 @@ def solve_ratio(text: str) -> Optional[SolverResult]:
|
|
| 44 |
],
|
| 45 |
)
|
| 46 |
|
| 47 |
-
# Pattern 2: "a:b = 2:3 and total is 40"
|
| 48 |
m = re.search(
|
| 49 |
-
r"(\d+)\s*:\s*(\d+).*?(?:
|
| 50 |
lower,
|
| 51 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
if m:
|
| 53 |
a = float(m.group(1))
|
| 54 |
b = float(m.group(2))
|
|
|
|
| 44 |
],
|
| 45 |
)
|
| 46 |
|
| 47 |
+
# Pattern 2: "a:b = 2:3 and total is 40" / "there are 40 students in total"
|
| 48 |
m = re.search(
|
| 49 |
+
r"(\d+)\s*:\s*(\d+).*?(?:total|sum)\s*(?:is|of)?\s*(\d+(?:\.\d+)?)",
|
| 50 |
lower,
|
| 51 |
)
|
| 52 |
+
if not m:
|
| 53 |
+
m = re.search(
|
| 54 |
+
r"(\d+)\s*:\s*(\d+).*?(\d+(?:\.\d+)?).*?(?:in total|total)",
|
| 55 |
+
lower,
|
| 56 |
+
)
|
| 57 |
if m:
|
| 58 |
a = float(m.group(1))
|
| 59 |
b = float(m.group(2))
|