Datasets:
skt
/

Modalities:
Text
Formats:
json
Languages:
Korean
ArXiv:
Libraries:
Datasets
pandas
License:
korca commited on
Commit
088a242
1 Parent(s): 100a53b

update data loader

Browse files
Files changed (2) hide show
  1. README.md +104 -3
  2. kobest_v1.py +32 -44
README.md CHANGED
@@ -65,15 +65,116 @@ Boolean Question Answering, Choice of Plausible Alternatives, Words-in-Context,
65
 
66
  ### Data Instances
67
 
68
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  ### Data Fields
71
 
72
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  ### Data Splits
75
 
76
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  ## Dataset Creation
79
 
 
65
 
66
  ### Data Instances
67
 
68
+ #### KB-BoolQ
69
+ An example of a data point looks as follows.
70
+ ```
71
+ {'paragraph': '두아 리파(Dua Lipa, 1995년 8월 22일 ~ )는 잉글랜드의 싱어송라이터, 모델이다. BBC 사운드 오브 2016 명단에 노미닛되었다. 싱글 "Be the One"가 영국 싱글 차트 9위까지 오르는 등 성과를 보여주었다.',
72
+ 'question': '두아 리파는 영국인인가?',
73
+ 'label': 1}
74
+ ```
75
+
76
+ #### KB-COPA
77
+ An example of a data point looks as follows.
78
+ ```
79
+ {'premise': '물을 오래 끓였다.',
80
+ 'question': '결과',
81
+ 'alternative_1': '물의 양이 늘어났다.',
82
+ 'alternative_2': '물의 양이 줄어들었다.',
83
+ 'label': 1}
84
+ ```
85
+
86
+ #### KB-WiC
87
+ An example of a data point looks as follows.
88
+ ```
89
+ {'word': '양분',
90
+ 'context_1': '토양에 [양분]이 풍부하여 나무가 잘 자란다. ',
91
+ 'context_2': '태아는 모체로부터 [양분]과 산소를 공급받게 된다.',
92
+ 'label': 1}
93
+ ```
94
+
95
+ #### KB-HellaSwag
96
+ An example of a data point looks as follows.
97
+ ```
98
+ {'context': '모자를 쓴 투수가 타자에게 온 힘을 다해 공을 던진다. 공이 타자에게 빠른 속도로 다가온다. 타자가 공을 배트로 친다. 배트에서 깡 소리가 난다. 공이 하늘 위로 날아간다.',
99
+ 'ending_1': '외야수가 떨어지는 공을 글러브로 잡는다.',
100
+ 'ending_2': '외야수가 공이 떨어질 위치에 자리를 잡는다.',
101
+ 'ending_3': '심판이 아웃을 외친다.',
102
+ 'ending_4': '외야수가 공을 따라 뛰기 시작한다.',
103
+ 'label': 3}
104
+ ```
105
+
106
+ #### KB-SentiNeg
107
+ An example of a data point looks as follows.
108
+ ```
109
+ {'sentence': '택배사 정말 마음에 듬',
110
+ 'label': 1}
111
+ ```
112
 
113
  ### Data Fields
114
 
115
+ ### KB-BoolQ
116
+ + `paragraph`: a `string` feature
117
+ + `question`: a `string` feature
118
+ + `label`: a classification label, with possible values `False`(0) and `True`(1)
119
+
120
+
121
+ ### KB-COPA
122
+ + `premise`: a `string` feature
123
+ + `question`: a `string` feature
124
+ + `alternative_1`: a `string` feature
125
+ + `alternative_2`: a `string` feature
126
+ + `label`: an answer candidate label, with possible values `alternative_1`(0) and `alternative_2`(1)
127
+
128
+
129
+ ### KB-WiC
130
+ + `target_word`: a `string` feature
131
+ + `context_1`: a `string` feature
132
+ + `context_2`: a `string` feature
133
+ + `label`: a classification label, with possible values `False`(0) and `True`(1)
134
+
135
+ ### KB-HellaSwag
136
+ + `target_word`: a `string` feature
137
+ + `context_1`: a `string` feature
138
+ + `context_2`: a `string` feature
139
+ + `label`: a classification label, with possible values `False`(0) and `True`(1)
140
+
141
+ ### KB-SentiNeg
142
+ + `sentence`: a `string` feature
143
+ + `label`: a classification label, with possible values `Negative`(0) and `Positive`(1)
144
+
145
 
146
  ### Data Splits
147
 
148
+ #### KB-BoolQ
149
+
150
+ + train: 3,665
151
+ + dev: 700
152
+ + test: 1,404
153
+
154
+ #### KB-COPA
155
+
156
+ + train: 3,076
157
+ + dev: 1,000
158
+ + test: 1,000
159
+
160
+ #### KB-WiC
161
+
162
+ + train: 3,318
163
+ + dev: 1,260
164
+ + test: 1,260
165
+
166
+ #### KB-HellaSwag
167
+
168
+ + train: 3,665
169
+ + dev: 700
170
+ + test: 1,404
171
+
172
+ #### KB-SentiNeg
173
+
174
+ + train: 3,649
175
+ + dev: 400
176
+ + test: 397
177
+ + test_originated: 397 (Corresponding training data where the test set is originated from.)
178
 
179
  ## Dataset Creation
180
 
kobest_v1.py CHANGED
@@ -34,6 +34,7 @@ _DATA_URLS = {
34
  "train": _URL + "/v1.0/SentiNeg/train.tsv",
35
  "dev": _URL + "/v1.0/SentiNeg/dev.tsv",
36
  "test": _URL + "/v1.0/SentiNeg/test.tsv",
 
37
  },
38
  "hellaswag": {
39
  "train": _URL + "/v1.0/HellaSwag/train.tsv",
@@ -69,26 +70,6 @@ class KoBESTConfig(datasets.BuilderConfig):
69
  self.url = url
70
 
71
 
72
- # class KoBESTConfig(datasets.BuilderConfig):
73
- # """BuilderConfig for KoTEST."""
74
- #
75
- # def __init__(
76
- # self,
77
- # features,
78
- # data_url,
79
- # file_map,
80
- # url,
81
- # **kwargs,
82
- # ):
83
- # """BuilderConfig for KoTEST."""
84
- #
85
- # super(KoBESTConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
86
- # self.features = features
87
- # self.data_url = data_url
88
- # self.file_map = file_map
89
- # self.url = url
90
-
91
-
92
  class KoBEST(datasets.GeneratorBasedBuilder):
93
  BUILDER_CONFIGS = [
94
  KoBESTConfig(name=name, description=_DESCRIPTION, data_url=_DATA_URLS[name], citation=_CITATAION, url=_URL)
@@ -144,6 +125,16 @@ class KoBEST(datasets.GeneratorBasedBuilder):
144
  dev = dl_manager.download_and_extract(self.config.data_url["dev"])
145
  test = dl_manager.download_and_extract(self.config.data_url["test"])
146
 
 
 
 
 
 
 
 
 
 
 
147
  return [
148
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train, "split": "train"}),
149
  datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": dev, "split": "dev"}),
@@ -195,16 +186,6 @@ class KoBEST(datasets.GeneratorBasedBuilder):
195
  df = df.dropna()
196
  df = df[['context', 'choice1', 'choice2', 'choice3', 'choice4', 'label']]
197
 
198
- # for id_, row in df.iterrows():
199
- # yield id_, {
200
- # "context": str(row["context"]),
201
- # "ending_1": str(row["choice1"]),
202
- # "ending_2": str(int(row["choice2"])),
203
- # "ending_3": str(int(row["choice3"])),
204
- # "ending_4": str(int(row["choice4"])),
205
- # "label": str(row["label"]),
206
- # }
207
- #
208
  df = df.rename(columns={
209
  'context': 'context',
210
  'choice1': 'ending_1',
@@ -217,18 +198,21 @@ class KoBEST(datasets.GeneratorBasedBuilder):
217
  elif self.config.name == "sentineg":
218
  df = pd.read_csv(filepath, sep="\t")
219
  df = df.dropna()
220
- df = df[['Text', 'Label']]
221
 
222
- # for id_, row in df.iterrows():
223
- # yield id_, {
224
- # "sentence": str(row["Text"]),
225
- # "label": str(int(row["Label"])),
226
- # }
227
 
228
- df = df.rename(columns={
229
- 'Text': 'sentence',
230
- 'Label': 'label',
231
- })
 
 
 
 
 
 
 
232
 
233
  else:
234
  raise NotImplementedError
@@ -239,8 +223,12 @@ class KoBEST(datasets.GeneratorBasedBuilder):
239
 
240
 
241
  if __name__ == "__main__":
242
- for task in ['boolq', 'copa', 'wic', 'hellaswag', 'sentineg']:
243
- dataset = datasets.load_dataset("kobest_v1.py", task, ignore_verifications=True)
244
- print(dataset)
245
- print(dataset['train']['label'])
 
 
 
 
246
 
 
34
  "train": _URL + "/v1.0/SentiNeg/train.tsv",
35
  "dev": _URL + "/v1.0/SentiNeg/dev.tsv",
36
  "test": _URL + "/v1.0/SentiNeg/test.tsv",
37
+ "test_originated": _URL + "/v1.0/SentiNeg/test.tsv",
38
  },
39
  "hellaswag": {
40
  "train": _URL + "/v1.0/HellaSwag/train.tsv",
 
70
  self.url = url
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  class KoBEST(datasets.GeneratorBasedBuilder):
74
  BUILDER_CONFIGS = [
75
  KoBESTConfig(name=name, description=_DESCRIPTION, data_url=_DATA_URLS[name], citation=_CITATAION, url=_URL)
 
125
  dev = dl_manager.download_and_extract(self.config.data_url["dev"])
126
  test = dl_manager.download_and_extract(self.config.data_url["test"])
127
 
128
+ if self.config.data_url.get("test_originated"):
129
+ test_originated = dl_manager.download_and_extract(self.config.data_url["test_originated"])
130
+
131
+ return [
132
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train, "split": "train"}),
133
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": dev, "split": "dev"}),
134
+ datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test, "split": "test"}),
135
+ datasets.SplitGenerator(name="test_originated", gen_kwargs={"filepath": test_originated, "split": "test_originated"}),
136
+ ]
137
+
138
  return [
139
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train, "split": "train"}),
140
  datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": dev, "split": "dev"}),
 
186
  df = df.dropna()
187
  df = df[['context', 'choice1', 'choice2', 'choice3', 'choice4', 'label']]
188
 
 
 
 
 
 
 
 
 
 
 
189
  df = df.rename(columns={
190
  'context': 'context',
191
  'choice1': 'ending_1',
 
198
  elif self.config.name == "sentineg":
199
  df = pd.read_csv(filepath, sep="\t")
200
  df = df.dropna()
 
201
 
202
+ if split == "test_originated":
203
+ df = df[['Text_origin', 'Label_origin']]
 
 
 
204
 
205
+ df = df.rename(columns={
206
+ 'Text_origin': 'sentence',
207
+ 'Label_origin': 'label',
208
+ })
209
+ else:
210
+ df = df[['Text', 'Label']]
211
+
212
+ df = df.rename(columns={
213
+ 'Text': 'sentence',
214
+ 'Label': 'label',
215
+ })
216
 
217
  else:
218
  raise NotImplementedError
 
223
 
224
 
225
  if __name__ == "__main__":
226
+ dataset = datasets.load_dataset("kobest_v1.py", 'sentineg', ignore_verifications=True)
227
+ ds = dataset['test_originated']
228
+ print(ds)
229
+
230
+ # for task in ['boolq', 'copa', 'wic', 'hellaswag', 'sentineg']:
231
+ # dataset = datasets.load_dataset("kobest_v1.py", task, ignore_verifications=True)
232
+ # print(dataset)
233
+ # print(dataset['train']['label'])
234