MCPcopy Create free account
hub / github.com/deepseek-ai/DeepSeek-Coder / extract_python_code

Function extract_python_code

Evaluation/LeetCode/evaluate_leetcode.py:11–19  ·  view source on GitHub ↗
(generation: str)

Source from the content-addressed store, hash-verified

9DATA_DIR = Path(__file__).parent / "data"
10
11def extract_python_code(generation: str):
12 generation = generation.replace("[PYTHON]", '```python').replace("[/PYTHON]", '```')
13 if '```python' in generation:
14 p_code = re.compile(r'```python\n(.*?)\n```', flags=re.DOTALL)
15 code_block = p_code.findall(generation)[0]
16 return code_block
17 else:
18 codelist = re.split("\ndef|\nclass|\nif|\n#|\nprint", generation)
19 return codelist[0]
20
21def evaluate_main(generation_path: str, result_path: str, temp_dir: str):
22 problem_path = (DATA_DIR / f"{version}.jsonl").as_posix()

Callers 1

evaluate_mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected