Spaces:
Sleeping
Sleeping
Fix prompts and utils
Browse files- audio_tool.py +13 -3
- deterministic_solvers.py +1 -1
audio_tool.py
CHANGED
|
@@ -44,8 +44,18 @@ import re
|
|
| 44 |
|
| 45 |
|
| 46 |
def extract_page_numbers(text: str) -> str:
|
| 47 |
-
|
| 48 |
|
| 49 |
-
|
| 50 |
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
def extract_page_numbers(text: str) -> str:
|
| 47 |
+
text = text.lower()
|
| 48 |
|
| 49 |
+
matches = []
|
| 50 |
|
| 51 |
+
# page 245 / page 197
|
| 52 |
+
matches.extend(re.findall(r"\bpage\s+(\d+)\b", text))
|
| 53 |
+
|
| 54 |
+
# pages 132, 133 and 134
|
| 55 |
+
plural_blocks = re.findall(r"\bpages\s+([0-9,\sand]+)", text)
|
| 56 |
+
for block in plural_blocks:
|
| 57 |
+
matches.extend(re.findall(r"\d+", block))
|
| 58 |
+
|
| 59 |
+
nums = sorted(set(int(x) for x in matches))
|
| 60 |
+
return ",".join(str(n) for n in nums)
|
| 61 |
+
|
deterministic_solvers.py
CHANGED
|
@@ -20,7 +20,7 @@ def solve_reverse_text(question: str) -> str:
|
|
| 20 |
|
| 21 |
if 'opposite of the word "left"' in reversed_question or "opposite" in reversed_question:
|
| 22 |
if "left" in reversed_question:
|
| 23 |
-
return "
|
| 24 |
|
| 25 |
return ""
|
| 26 |
|
|
|
|
| 20 |
|
| 21 |
if 'opposite of the word "left"' in reversed_question or "opposite" in reversed_question:
|
| 22 |
if "left" in reversed_question:
|
| 23 |
+
return "Right"
|
| 24 |
|
| 25 |
return ""
|
| 26 |
|