| 110 | DATA_DIR = Path(__file__).parent / "data" |
| 111 | |
| 112 | def extract_python_code(generation: str): |
| 113 | generation = generation.replace("[PYTHON]", '```python').replace("[/PYTHON]", '```') |
| 114 | if '```python' in generation: |
| 115 | p_code = re.compile(r'```python\n(.*?)\n```', flags=re.DOTALL) |
| 116 | code_block = p_code.findall(generation)[0] |
| 117 | return code_block |
| 118 | else: |
| 119 | codelist = re.split("\ndef|\nclass|\nif|\n#|\nprint", generation) |
| 120 | return codelist[0] |
| 121 | |
| 122 | def evaluate_main(generation_path: str, result_path: str, temp_dir: str): |
| 123 | problem_path = args.input_data |