Tsukihjy/testcase / testcase-data /Ours /update_fixed_wrong_code_v23.py
Tsukihjy's picture
download
raw
3.61 kB
import json
# new_wrong_code = json.load(open("/home/luoxianzhen/yang/data/Ours/wrong-code-to-fix-v23-sections2-fixed.json", "r", encoding="utf-8"))
# base_code = json.load(open("/home/luoxianzhen/yang/data/Ours/TestcaseBench-v23-Wrong_code_new.json", "r", encoding="utf-8"))
# base_code_dict = {}
# for item in base_code:
# base_code_dict[item['tcb_id']] = item
# for item in new_wrong_code:
# tcb_id = item['tcb_id']
# base_code_dict[tcb_id]['wrong_code'][item['code_id']]['code'] = item['code']
# tcb_bench = json.load(open("/home/luoxianzhen/yang/data/Ours/TestcaseBench-v23.json", "r", encoding="utf-8"))
# transformer_tcb_id = {}
# for item in tcb_bench:
# transformer_tcb_id[item['tcb_id']] = item['wrong_code'][0]['problem']
# add_wrong_code = json.load(open("/home/luoxianzhen/yang/download_cache/data/Ours/balance_v1.0.dev.0903_with_code.json", "r", encoding="utf-8"))
# ## 更新 add_wrong_code
# rest_code_count = 0
# for item in base_code:
# tcb_id = item['tcb_id']
# to_update_codes = add_wrong_code[transformer_tcb_id[tcb_id]]['cowrong_codes']
# code_id_list = [code['id'] for code in item['wrong_code']]
# for new_wrong_code in to_update_codes:
# if new_wrong_code['id'] not in code_id_list:
# rest_code_count += 1
# item['wrong_code'].append(new_wrong_code)
# print(f"rest_code_count: {rest_code_count}")
# update_count = 0
# for item in tcb_bench:
# tcb_id = item['tcb_id']
# if tcb_id in base_code_dict.keys():
# update_count += 1
# code_id_list = [code['id'] for code in base_code_dict[tcb_id]['wrong_code']]
# wrong_code_dict = {}
# for wrong in item['wrong_code']:
# if wrong['id'] in code_id_list:
# wrong_code_dict[wrong['id']] = wrong
# for wrong in base_code_dict[tcb_id]['wrong_code']:
# if wrong['id'] in code_id_list and wrong['id'] not in wrong_code_dict.keys():
# wrong_code_dict[wrong['id']] = wrong
# item['wrong_code'] = list(wrong_code_dict.values())
# print(f"update items {update_count}")
# json.dump(tcb_bench, open(f"/home/luoxianzhen/yang/data/Ours/TestcaseBench-v24.json", "w", encoding="utf-8"), indent=4, ensure_ascii=False)
# upudate_file = "/home/luoxianzhen/yang/eval/To-fix-wrong-code-v24.json"
# new_wrong_code = json.load(open(upudate_file, "r", encoding="utf-8"))
# tcb_bench = json.load(open("/home/luoxianzhen/yang/data/Ours/TestcaseBench-v25.json", "r", encoding="utf-8"))
# print(len(tcb_bench))
# for repalce_code in new_wrong_code:
# tcb_id = repalce_code['tcb_id']
# print(tcb_id)
# code = [item for item in tcb_bench if item["tcb_id"] == tcb_id][0]
# code['wrong_code'][repalce_code['code_id']]['code'] = repalce_code['code']
# json.dump(tcb_bench, open(f"/home/luoxianzhen/yang/data/Ours/TestcaseBench-v26.json", "w", encoding="utf-8"), indent=4, ensure_ascii=False)
## 移除无法修复的代码
upudate_file = "/home/luoxianzhen/yang/eval/To-fix-wrong-code-v26-EXE.json"
new_wrong_code = json.load(open(upudate_file, "r", encoding="utf-8"))
tcb_bench = json.load(open("/home/luoxianzhen/yang/data/Ours/TestcaseBench-v26.json", "r", encoding="utf-8"))
print(len(tcb_bench))
for repalce_code in new_wrong_code:
tcb_id = repalce_code['tcb_id']
print(tcb_id)
code = [item for item in tcb_bench if item["tcb_id"] == tcb_id][0]
del code['wrong_code'][repalce_code['code_id']]
json.dump(tcb_bench, open(f"/home/luoxianzhen/yang/data/Ours/TestcaseBench-v27.json", "w", encoding="utf-8"), indent=4, ensure_ascii=False)

Xet Storage Details

Size:
3.61 kB
·
Xet hash:
bf465ab95d60e92d741429a6b845c2a9df403038969720ee1d30e75eb94d8d72

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.