File size: 1,364 Bytes
78dd5ab
 
 
 
fb4253b
78dd5ab
fb4253b
78dd5ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import subprocess, os
import regex as re
from deep_translator import GoogleTranslator
def get_grog_api():
    return os.get_env("GROQ_API_KEY")
def get_github_token():
    return os.get_env("GITHUB_TOKEN")
def translate(input:str) -> str:
    translated = GoogleTranslator(source='vi', target='en').translate(text=input)
    return translated
def run_ag():
    subprocess.run(["ag4masses/utils/run.sh"])
def read_solution():
    with open('ag4mout/solution.out', 'r', encoding='utf-8') as f:
        lines = f.readlines()
        paragraphs = ''.join(lines).split('\n\n')
        theorem_premises = paragraphs[0].strip()
        auxiliary_constructions = paragraphs[1].strip()
        proof_steps = paragraphs[2].strip()
        proof_steps = re.sub(r'\d+\. ', '- Ta có:\n', proof_steps)
        proof_steps = re.sub(r' & ', '\n', proof_steps)
        proof_steps = re.sub(r' ⇒ ', '\n⇒ ', proof_steps)
        result = {
            theorem_premises.split('\n')[0]: GoogleTranslator(target='vi').translate(text='\n'.join(theorem_premises.split('\n')[1:])),
            auxiliary_constructions.split('\n')[0]: GoogleTranslator(target='vi').translate(text='\n'.join(auxiliary_constructions.split('\n')[1:])),
            proof_steps.split('\n')[0]: GoogleTranslator(target='vi').translate(text='\n'.join(proof_steps.split('\n')[1:]))
        }
    return result