|
import json |
|
import csv |
|
|
|
csvin = 'C:/Users/94427/kashiwa/DISC-Assignment/Experiment/TriviaQA/val_triviaqa.csv' |
|
|
|
|
|
|
|
|
|
import csv |
|
|
|
|
|
with open(csvin, newline='',encoding='utf-8') as csvfile: |
|
reader = csv.DictReader(csvfile) |
|
|
|
|
|
|
|
files = 'C:/Users/94427/kashiwa/DISC-Assignment/Experiment/TriviaQA/TriviaQA_test_format1k.jsonl' |
|
with open(files, 'w', newline='',encoding='utf-8') as outfile: |
|
messages = [] |
|
|
|
for index,row in enumerate(reader): |
|
if index<=1000: |
|
context = row['context'] |
|
question = row['question'] |
|
answers = row['answers'] |
|
|
|
message = { |
|
"Data": |
|
{ |
|
"Answer":answers, |
|
"Question":question, |
|
"Context":context, |
|
}, |
|
} |
|
|
|
messages.append(message) |
|
|
|
for message in messages: |
|
outfile.write(json.dumps(message, ensure_ascii=False) + '\n') |