Datasets:
Upload csatqa.py
Browse files
csatqa.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import datasets
|
| 5 |
+
import json
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
_CITATION = """\
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
_DESCRIPTION = """\
|
| 12 |
+
CSAT-QA
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
_HOMEPAGE = "https://huggingface.co/HAERAE-HUB"
|
| 16 |
+
|
| 17 |
+
_LICENSE = "Proprietary"
|
| 18 |
+
|
| 19 |
+
split_names = ["WR", "GR", "RCS", "RCSS", "RCH", "LI"]
|
| 20 |
+
|
| 21 |
+
class CSATQAConfig(datasets.BuilderConfig):
|
| 22 |
+
def __init__(self, **kwargs):
|
| 23 |
+
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class CSATQA(datasets.GeneratorBasedBuilder):
|
| 27 |
+
BUILDER_CONFIGS = [
|
| 28 |
+
CSATQAConfig(
|
| 29 |
+
name=name,
|
| 30 |
+
)
|
| 31 |
+
for name in split_names
|
| 32 |
+
]
|
| 33 |
+
|
| 34 |
+
def _info(self):
|
| 35 |
+
features = datasets.Features(
|
| 36 |
+
{
|
| 37 |
+
"question": datasets.Value("string"),
|
| 38 |
+
"option#1": datasets.Value("string"),
|
| 39 |
+
"option#2": datasets.Value("string"),
|
| 40 |
+
"option#3": datasets.Value("string"),
|
| 41 |
+
"option#4": datasets.Value("string"),
|
| 42 |
+
"option#5": datasets.Value("string"),
|
| 43 |
+
"gold": datasets.Value("int8"),
|
| 44 |
+
}
|
| 45 |
+
)
|
| 46 |
+
return datasets.DatasetInfo(
|
| 47 |
+
description=_DESCRIPTION,
|
| 48 |
+
features=features,
|
| 49 |
+
homepage=_HOMEPAGE,
|
| 50 |
+
license=_LICENSE,
|
| 51 |
+
citation=_CITATION,
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
def _split_generators(self, dl_manager):
|
| 55 |
+
data_dir = "HAERAE-HUB/CSAT-QA"
|
| 56 |
+
return [
|
| 57 |
+
datasets.SplitGenerator(
|
| 58 |
+
name=datasets.Split.TEST,
|
| 59 |
+
gen_kwargs={
|
| 60 |
+
"filepath": os.path.join(data_dir, "data", "data.jsonl"),
|
| 61 |
+
},
|
| 62 |
+
),
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
def _generate_examples(self, filepath):
|
| 66 |
+
with open(filepath, encoding="utf-8") as f:
|
| 67 |
+
for key, row in enumerate(f):
|
| 68 |
+
data = json.loads(row)
|
| 69 |
+
if data["split"] == self.config.name:
|
| 70 |
+
data["gold"] = int(data["gold"]) - 1
|
| 71 |
+
data.pop("split")
|
| 72 |
+
yield key, data
|