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

Function extract_program

Evaluation/PAL-Math/utils/parser.py:207–224  ·  view source on GitHub ↗

extract the program after "```python", and before "```"

(result: str, last_only=True)

Source from the content-addressed store, hash-verified

205
206
207def extract_program(result: str, last_only=True):
208 """
209 extract the program after "```python", and before "```"
210 """
211 program = ""
212 start = False
213 for line in result.split("\n"):
214 if line.startswith("```python"):
215 if last_only:
216 program = "" # only extract the last program
217 else:
218 program += "\n# ========\n"
219 start = True
220 elif line.startswith("```"):
221 start = False
222 elif start:
223 program += line + "\n"
224 return program
225
226
227def extract_program_output(pred_str):

Callers 1

run_executeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected