fix dataset
Browse files- process/tweet_qa.py +9 -8
- process/tweet_qg.py +3 -2
process/tweet_qa.py
CHANGED
@@ -2,27 +2,28 @@ import os
|
|
2 |
import json
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
-
os.makedirs("data/
|
6 |
data = load_dataset("lmqg/qg_tweetqa")
|
7 |
|
8 |
|
9 |
def process(tmp):
|
10 |
tmp = [i.to_dict() for _, i in tmp.iterrows()]
|
11 |
for i in tmp:
|
12 |
-
i
|
13 |
-
i['
|
14 |
-
i.pop("
|
15 |
-
i.pop("question")
|
16 |
return tmp
|
17 |
|
|
|
18 |
train = process(data["train"].to_pandas())
|
19 |
val = process(data["validation"].to_pandas())
|
20 |
test = process(data["test"].to_pandas())
|
21 |
-
with open("data/
|
22 |
f.write("\n".join([json.dumps(i) for i in train]))
|
23 |
-
with open("data/
|
24 |
f.write("\n".join([json.dumps(i) for i in val]))
|
25 |
-
with open("data/
|
26 |
f.write("\n".join([json.dumps(i) for i in test]))
|
27 |
|
28 |
|
|
|
2 |
import json
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
+
os.makedirs("data/tweet_qg", exist_ok=True)
|
6 |
data = load_dataset("lmqg/qg_tweetqa")
|
7 |
|
8 |
|
9 |
def process(tmp):
|
10 |
tmp = [i.to_dict() for _, i in tmp.iterrows()]
|
11 |
for i in tmp:
|
12 |
+
i.pop('paragraph_question')
|
13 |
+
i['text'] = i.pop("paragraph")
|
14 |
+
i['gold_label_str'] = i.pop("answer")
|
15 |
+
i['context'] = i.pop("question")
|
16 |
return tmp
|
17 |
|
18 |
+
|
19 |
train = process(data["train"].to_pandas())
|
20 |
val = process(data["validation"].to_pandas())
|
21 |
test = process(data["test"].to_pandas())
|
22 |
+
with open("data/tweet_qg/train.jsonl", "w") as f:
|
23 |
f.write("\n".join([json.dumps(i) for i in train]))
|
24 |
+
with open("data/tweet_qg/validation.jsonl", "w") as f:
|
25 |
f.write("\n".join([json.dumps(i) for i in val]))
|
26 |
+
with open("data/tweet_qg/test.jsonl", "w") as f:
|
27 |
f.write("\n".join([json.dumps(i) for i in test]))
|
28 |
|
29 |
|
process/tweet_qg.py
CHANGED
@@ -10,8 +10,9 @@ def process(tmp):
|
|
10 |
tmp = [i.to_dict() for _, i in tmp.iterrows()]
|
11 |
for i in tmp:
|
12 |
i.pop('paragraph_question')
|
13 |
-
i['text'] =
|
14 |
-
i['
|
|
|
15 |
return tmp
|
16 |
|
17 |
|
|
|
10 |
tmp = [i.to_dict() for _, i in tmp.iterrows()]
|
11 |
for i in tmp:
|
12 |
i.pop('paragraph_question')
|
13 |
+
i['text'] = i.pop("paragraph")
|
14 |
+
i['context'] = i.pop("answer")
|
15 |
+
i['gold_label_str'] = i.pop("question")
|
16 |
return tmp
|
17 |
|
18 |
|