You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB
Python

import pandas as pd
# 读取CSV文件
df = pd.read_csv("data/val/car_use_val.csv")
correct_num = 0
total_num = 0
# 遍历每一行并生成选择题文本
for index, row in df.iterrows():
question_text = row['question']
options = [row['A'], row['B'], row['C'], row['D']]
answer = row['answer']
# 生成选择题文本
question_text = f"{question_text}\n"
for i, option in enumerate(options):
question_text += f"{chr(65 + i)}. {option}\n"
# 打印生成的选择题
print(f"问题 {index + 1}:")
print(question_text)
user_answer = input("请输入你的答案: ")
df.loc[index, 'user_answer'] = user_answer
print(f"答案: {answer}\n")
total_num += 1
if user_answer == answer:
print("回答正确!\n")
correct_num += 1
else:
print("回答错误!\n")
# 计算正确率
correct_ratio = 100 * correct_num / total_num
print(f"正确率: {correct_ratio}%")
#结果保存到文件
df.to_csv("logs/car_use_val_gpt3.5_" + str(correct_ratio) + ".csv")