import json

# 手动定义待检验文件和标准答案文件路径
test_file_path =        # 待检验文件路径
standard_file_path =   # 标准答案文件路径

def load_json(file_path):
    with open(file_path, 'r', encoding='utf-8') as f:
        return json.load(f)

def evaluate_judge_results(test_data, standard_data):
    # 将标准答案按 id 构建字典，便于快速查找
    standard_dict = {item['id']: item for item in standard_data}

    right_num = 0
    wrong_num = 0

    # 按 id 从 1 开始顺序比较
    for i in range(1, len(test_data) + 1):
        str_id = str(i)

        # 获取待检验项
        test_item = next((item for item in test_data if item['id'] == str_id), None)
        standard_item = standard_dict.get(str_id)

        if test_item is None or standard_item is None:
            print(f"⚠ 警告: 缺少 id={str_id} 的数据，跳过该条")
            continue

        test_judge = test_item.get('judge result')
        standard_label = standard_item.get('label')

        if test_judge == standard_label:
            right_num += 1
        else:
            wrong_num += 1

    total = right_num + wrong_num
    acc = (right_num / total * 100) if total > 0 else 0

    print(f"right number: {right_num}")
    print(f"wrong number: {wrong_num}")
    print(f"total number: {total}")
    print(f"Accuracy: {acc:.2f}%")

if __name__ == "__main__":
    test_json = load_json(test_file_path)
    standard_json = load_json(standard_file_path)
    evaluate_judge_results(test_json, standard_json)
