import json import re import os input_path = "/root/test/weitiao/data_process_bq/data/train01_hg2chatml_p2r.json" output_path = "/root/test/weitiao/data_process_bq/data/train01_chatml_p2r_closed.json" dropped_path = "/root/test/weitiao/data_process_bq/data/train01_chatml_p2r_unclosed.json" def is_balanced(text: str): """检查 text 内部的特殊字符是否成对出现""" if text.count('*') % 2 != 0: return False, "unmatched *" if re.search(r'(?