MCPcopy Create free account
hub / github.com/PRIME-RL/PRIME / extract_python_code

Function extract_python_code

eval/Coding/leetcode/evaluate_leetcode.py:112–120  ·  view source on GitHub ↗
(generation: str)

Source from the content-addressed store, hash-verified

110DATA_DIR = Path(__file__).parent / "data"
111
112def 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
122def evaluate_main(generation_path: str, result_path: str, temp_dir: str):
123 problem_path = args.input_data

Callers 1

evaluate_mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected