super_tweeteval / process /tweet_qa.py
asahi417's picture
fix dataset
7d44973
raw
history blame
857 Bytes
import os
import json
from datasets import load_dataset
os.makedirs("data/tweet_qa", exist_ok=True)
data = load_dataset("lmqg/qg_tweetqa")
def process(tmp):
tmp = [i.to_dict() for _, i in tmp.iterrows()]
for i in tmp:
i.pop('paragraph_question')
i['text'] = i.pop("paragraph")
i['context'] = i.pop("question")
i['gold_label_str'] = i.pop("answer")
return tmp
train = process(data["train"].to_pandas())
val = process(data["validation"].to_pandas())
test = process(data["test"].to_pandas())
with open("data/tweet_qa/train.jsonl", "w") as f:
f.write("\n".join([json.dumps(i) for i in train]))
with open("data/tweet_qa/validation.jsonl", "w") as f:
f.write("\n".join([json.dumps(i) for i in val]))
with open("data/tweet_qa/test.jsonl", "w") as f:
f.write("\n".join([json.dumps(i) for i in test]))