download
raw
5.14 kB
# import json
# def append_dict_to_jsonl(file_path, data_dict):
# with open(file_path, 'a', encoding='utf-8') as f:
# f.write(json.dumps(data_dict, ensure_ascii=False) + '\n')
# """
# #2665. 「NOI2013」树的计数 -- 删除
# #7. Input Test -- 删除
# #10186. 「一本通 5.6 例 3」任务安排 3 -- 删除
# #2590. 「NOIP2009」最优贸易 -- 添加1
# #2573. 「TJOI2018」数学计算 -- 添加1
# #2667. 「NOI2013」矩阵游戏 -- 添加1
# #3022. 「CQOI2017」老 C 的方块 -- 添加2
# #2574. 「TJOI2018」智力竞赛 -- 添加2
# #2668. 「NOI2013」书法家 -- 添加2
# #2588. 「NOIP2009」潜伏者 -- 添加3
# #42181. 「NOI2022」二次整数规划问题 -- 删除
# #140. 最小树形图 -- 添加3
# #41268. 「NOI2021」量子通信 -- 删除
# #3314. 「ZJOI2020」染色游戏 -- 添加1
# #3316. 「ZJOI2020」密码 -- 删除
# #6183. 看无可看 -- 删除
# """
# problem_id = ""
# samples = [
# {
# 'inputData': "5\n6 5 2 2\n1 2 0\n2 3 0\n2 4 0\n3 5 0\n4 6 0\n5 6\n3 4\n6 5 2 2\n1 2 1\n2 3 0\n2 4 0\n3 5 0\n4 6 0\n5 6\n3 4\n5 4 2 2\n1 2 1\n1 3 1\n2 4 0\n3 5 0\n4 5\n2 3\n8 8 1 2\n1 2 2\n2 3 1\n3 4 0\n4 5 0\n5 6 0\n6 7 0\n7 2 1\n5 8 0\n8\n3 7\n8 8 1 2\n1 2 3\n2 3 0\n3 4 0\n4 5 0\n5 6 0\n6 7 0\n7 2 0\n5 8 0\n8\n3 7\n",
# 'outputData': "1\n0\n0\n0\n1"
# },
# ]
# data = {problem_id: samples}
# append_dict_to_jsonl('/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/add_test.jsonl', data)
import json
# def read_json(file_path):
# with open(file_path, "r", encoding="utf-8") as f:
# data = json.load(f)
# return data
# import datetime
# def write_log(message: str, log_file: str = "/home/i-luoxianzhen/data/TestCase-Gen/datasets_log.txt"):
# """
# Append a timestamped log message to a log file.
# Args:
# message (str): The message to log.
# log_file (str): The path to the log file (default is 'log.txt').
# Returns:
# None
# """
# timestamp = datetime.datetime.now().strftime("[%Y-%m-%d %H:%M:%S]")
# with open(log_file, "a", encoding="utf-8") as f:
# f.write(f"{timestamp} {message}\n")
# def contains_html(text):
# # 正则表达式匹配HTML标签
# pattern = r'https?://(?:www\.)?[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(?:/[^\s]*)?'
# return bool(re.search(pattern, text))
# ds_v8 = read_json("/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/datasets_v8.json")
# ds_v9 = read_json("/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/datasets_v9.json")
# ds_v8_dict = {}
# for item in ds_v8:
# ds_v8_dict[item['tcb_id']] = item
# import re
# cnt = 0
# for item in ds_v9:
# # if contains_html(item['query']):
# # print(item['problem_id'])
# # cnt += 1
# # # write_log(item['query'], "/home/i-luoxianzhen/data/TestCase-Gen/data/Ours/txtdata/"+item['problem_id'].replace('/', '=')+".txt")
# if item['query'] != ds_v8_dict[item['tcb_id']]['query']:
# write_log(f"{item['tcb_id']} 删除 这是一道模板题")
# print(cnt)
# 脚本功能:保留含有 "Correct Code" 的行,并输出到 correct_code.txt 文件
# # 输入文件路径
# for i in range(8):
# input_file_path = f'/home/i-luoxianzhen/data/TestCase-Gen/log_dir/log-filter-ht-{i}.txt' # 请替换为你的输入文件路径
# # 输出文件路径
# output_file_path = '/home/i-luoxianzhen/data/TestCase-Gen/methods/correct_code.txt'
# # 打开输入文件读取内容
# with open(input_file_path, 'r', encoding='utf-8') as infile:
# # 打开输出文件准备写入
# with open(output_file_path, 'a', encoding='utf-8') as outfile:
# # 遍历输入文件的每一行
# for line in infile:
# # 如果该行包含 "Correct Code"
# if 'psssed no test' in line:
# # 写入到输出文件
# outfile.write(line)
# print(f"包含 'Correct Code' 的行已被保存到 {output_file_path}")
import json
# 初始化总和
total_gen_nums = 0
total_right_nums = 0
import os
# 读取每个文件,i 从 0 到 7
for i in range(8):
file_path = f"/home/i-luoxianzhen/data/TestCase-Gen/saved_test_filterd/predo/test_pass_rate-{i}.jsonl"
with open(file_path, 'r') as file:
for line in file:
data = json.loads(line.strip()) # 读取并解析每行数据
total_gen_nums += data['gen_nums'] # 累加 gen_nums
total_right_nums += data['right_nums'] # 累加 right_nums
# 计算成功率
if total_gen_nums > 0:
success_rate = (total_right_nums / total_gen_nums) * 100
else:
success_rate = 0
# 输出结果
print(f"Total gen_nums: {total_gen_nums}")
print(f"Total right_nums: {total_right_nums}")
print(f"Success rate: {success_rate:.2f}%")
# crux
# Total gen_nums: 63342
# Total right_nums: 20962
# 33.10%
# ht
# Total gen_nums: 47569
# Success rate: 79.62%
# lcb
# Total gen_nums: 46581
# Total right_nums: 37010
# Success rate: 79.45%
#

Xet Storage Details

Size:
5.14 kB
·
Xet hash:
aa2c06f420e2eb8c0049f5aceecbd7a8ba822e596566f1d283b411392fd82af9

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