import json

def evaluate_judge_result(test_file_path, standard_file_path):
    # 加载待检验文件
    with open(test_file_path, 'r', encoding='utf-8') as f:
        test_data = json.load(f)
    
    # 加载标准答案文件
    with open(standard_file_path, 'r', encoding='utf-8') as f:
        standard_data = json.load(f)

    # 将标准答案数据转成 id: 数据 的字典，方便快速查找
    standard_dict = {item['id']: item for item in standard_data}

    right_num = 0
    wrong_num = 0

    for item in test_data:
        id_ = item['id']
        judge_result = item.get('judge result')
        standard_item = standard_dict.get(id_)

        if not standard_item:
            print(f"Warning: id {id_} 在标准答案文件中未找到，跳过该项。")
            continue

        label = standard_item.get('label')

        if judge_result == label:
            right_num += 1
        elif label == 'A=B':
            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_file_path = 
    standard_file_path = 

    evaluate_judge_result(test_file_path, standard_file_path)
