| import json | |
| # 读取JSON文件 | |
| with open('autodl-tmp/ms-swift/dataset_10k/test/merged_test_list.json', 'r', encoding='utf-8') as f: | |
| data = json.load(f) | |
| # 遍历并修改 | |
| for item in data: | |
| if 'correct' in item.get('audio_url', ''): | |
| item['solution'] = 2 | |
| else: | |
| item['solution'] = 1 | |
| # 保存到新文件(或覆盖原文件) | |
| with open('autodl-tmp/ms-swift/dataset_10k/test/merged_test_list2.json', 'w', encoding='utf-8') as f: | |
| json.dump(data, f, ensure_ascii=False, indent=2) | |