代码拉取完成,页面将自动刷新
import os
import json
from tqdm import trange
def save_info(data_dir, data, desc):
with open(os.path.join(data_dir, f'{desc}.json'), 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
def convert_test_data_to_json(test_dir, save_dir):
test_examples = []
# process test examples
for i in trange(1500, 1997):
with open(os.path.join(test_dir, f'{i}.txt'), encoding='utf-8') as f:
text = f.read()
test_examples.append({'id': i,
'text': text})
save_info(save_dir, test_examples, 'test')
if __name__ == '__main__':
test_dir = './tcdata/juesai'
save_dir = './data/raw_data_random'
convert_test_data_to_json(test_dir, save_dir)
print('测试数据转换完成')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。