(code)
| 22 | return code |
| 23 | |
| 24 | def _clean_python_code_for_sft(code): |
| 25 | code = code.replace("\r", "") |
| 26 | if "```python" in code: |
| 27 | code_start_idx = code.index("```python") |
| 28 | code = code[code_start_idx:].replace("```python", "").strip() |
| 29 | end_idx = code.find("```") if "```" in code else len(code) |
| 30 | code = code[:end_idx].strip() |
| 31 | |
| 32 | return code |
| 33 | |
| 34 | def _truncate_code_at_stopwords(code, stop_words): |
| 35 | min_stop_idx = len(code) |