asahi417 commited on
Commit
aceb9a7
1 Parent(s): 140e6d4

fix dataset

Browse files
Files changed (2) hide show
  1. process/tweet_qa.py +9 -8
  2. 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/tweet_qa", 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['text'] = i.pop('paragraph_question')
13
- i['gold_label_str'] = i.pop('answer')
14
- i.pop("paragraph")
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/tweet_qa/train.jsonl", "w") as f:
22
  f.write("\n".join([json.dumps(i) for i in train]))
23
- with open("data/tweet_qa/validation.jsonl", "w") as f:
24
  f.write("\n".join([json.dumps(i) for i in val]))
25
- with open("data/tweet_qa/test.jsonl", "w") as f:
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'] = f"context: {i.pop('paragraph')}, answer:{i.pop('answer')}"
14
- i['gold_label_str'] = i.pop('question')
 
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