Spaces:
Runtime error
Runtime error
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -11,18 +11,24 @@ def translate(input:str) -> str:
|
|
| 11 |
def run_ag():
|
| 12 |
subprocess.run(["ag4masses/utils/run.sh"])
|
| 13 |
def read_solution():
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def run_ag():
|
| 12 |
subprocess.run(["ag4masses/utils/run.sh"])
|
| 13 |
def read_solution():
|
| 14 |
+
if os.path.exists('ag4mout/solution.out'):
|
| 15 |
+
with open('ag4mout/solution.out', 'r', encoding='utf-8') as f:
|
| 16 |
+
lines = f.readlines()
|
| 17 |
+
paragraphs = ''.join(lines).split('\n\n')
|
| 18 |
+
theorem_premises = paragraphs[0].strip()
|
| 19 |
+
auxiliary_constructions = paragraphs[1].strip()
|
| 20 |
+
proof_steps = paragraphs[2].strip()
|
| 21 |
+
proof_steps = re.sub(r'\d+\. ', '- Ta có:\n', proof_steps)
|
| 22 |
+
proof_steps = re.sub(r' & ', '\n', proof_steps)
|
| 23 |
+
proof_steps = re.sub(r' ⇒ ', '\n⇒ ', proof_steps)
|
| 24 |
+
result = {
|
| 25 |
+
theorem_premises.split('\n')[0]: GoogleTranslator(target='vi').translate(text='\n'.join(theorem_premises.split('\n')[1:])),
|
| 26 |
+
auxiliary_constructions.split('\n')[0]: GoogleTranslator(target='vi').translate(text='\n'.join(auxiliary_constructions.split('\n')[1:])),
|
| 27 |
+
proof_steps.split('\n')[0]: GoogleTranslator(target='vi').translate(text='\n'.join(proof_steps.split('\n')[1:]))
|
| 28 |
+
}
|
| 29 |
+
return result
|
| 30 |
+
else:
|
| 31 |
+
return {"key_1": "Bài toán không thể giải được/Đề bài bị lỗi",
|
| 32 |
+
"key_2": "Bài toán không thể giải được/Đề bài bị lỗi",
|
| 33 |
+
"key_3": "Bài toán không thể giải được/Đề bài bị lỗi",
|
| 34 |
+
}
|