| 20 | |
| 21 | # get result |
| 22 | def get_input_data(test_file_path,filename): |
| 23 | _hint = f'There is a single choice question about {filename.replace("_test.csv", " ")}. Answer the question by replying A, B, C or D.' |
| 24 | df = pd.read_csv(os.path.join(test_file_path,filename),header=None,names=["input","A","B","C","D","answer"]) |
| 25 | data = [] |
| 26 | for i in range(len(df)): |
| 27 | line = df.iloc[i] |
| 28 | input = f"{_hint}\nQuestion: {line['input']}\nA. {line['A']}\nB. {line['B']}\nC. {line['C']}\nD. {line['D']}\nAnswer: " |
| 29 | target = line["answer"] |
| 30 | data.append({"input":input,"target":target}) |
| 31 | return data |
| 32 | # post process |
| 33 | def get_capital_answer(text): |
| 34 | patterns = [ |