Datasets:
File size: 3,367 Bytes
47620ab b0dec8d 47620ab 939175d 47620ab 54d0d74 47620ab 54d0d74 7a5ec2e 47620ab 6ff60f7 47620ab c8f8435 56fd8de 27570d7 83884fc 927f55d 47620ab c8f8435 e2e0f48 2970c73 cccb20f 47620ab 939175d 74315b5 7a5ec2e 7ff25ef 939175d ff114f8 7a5ec2e 7ff25ef 54d0d74 cccb20f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
import os
import datasets
import json
import pandas as pd
_CITATION = """\
"""
_DESCRIPTION = """\
CSAT-QA
"""
_HOMEPAGE = "https://huggingface.co/HAERAE-HUB"
_LICENSE = "Proprietary"
split_names = ["full","WR", "GR", "RCS", "RCSS", "RCH", "LI"]
class CSATQAConfig(datasets.BuilderConfig):
def __init__(self, **kwargs):
super().__init__(version=datasets.Version("1.0.0"), **kwargs)
class CSATQA(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
CSATQAConfig(
name=name,
)
for name in split_names
]
def _info(self):
features = datasets.Features(
{
"question": datasets.Value("string"),
"context" : datasets.Value("string"),
"option#1": datasets.Value("string"),
"option#2": datasets.Value("string"),
"option#3": datasets.Value("string"),
"option#4": datasets.Value("string"),
"option#5": datasets.Value("string"),
"gold": datasets.Value("int8"),
"category": datasets.Value("string"),
"human_performance": datasets.Value("float32"),
}
)
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=features,
homepage=_HOMEPAGE,
license=_LICENSE,
citation=_CITATION,
)
def _split_generators(self, dl_manager):
train_path = dl_manager.download_and_extract("./data/csatqa.json")
return [
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"filepath": train_path,
},
),
]
def _generate_examples(self, filepath):
with open(filepath, encoding="utf-8") as f:
buffer = []
for key, row in enumerate(f):
data = json.loads(row)
if self.config.name == "full":
buffer.append({
"question": data["question"],
"context" : data["context"],
"option#1": data["option#1"],
"option#2": data["option#2"],
"option#3": data["option#3"],
"option#4": data["option#4"],
"option#5": data["option#5"],
"gold": data["gold"],
"category":"N/A",
"human_performance":0.0
})
elif data["Category"] == self.config.name:
buffer.append({
"question": data["question"],
"context" : data["context"],
"option#1": data["option#1"],
"option#2": data["option#2"],
"option#3": data["option#3"],
"option#4": data["option#4"],
"option#5": data["option#5"],
"gold": data["gold"],
"category": data["Category"],
"human_performance": data["Human_Peformance"]
})
for idx, dat in enumerate(buffer):
yield idx,dat
|