|
import os |
|
|
|
import datasets |
|
import json |
|
import pandas as pd |
|
|
|
_CITATION = """\ |
|
""" |
|
|
|
_DESCRIPTION = """\ |
|
CSAT-QA |
|
""" |
|
|
|
_HOMEPAGE = "https://huggingface.co/HAERAE-HUB" |
|
|
|
_LICENSE = "Proprietary" |
|
|
|
split_names = ['andard_nomenclature', |
|
'correct_definition_matching', |
|
'date_understanding', |
|
'general_knowledge', |
|
'history', |
|
'loan_word', |
|
'lyrics_denoising', |
|
'proverbs_denoising', |
|
'rare_word', |
|
'reading_comprehension'] |
|
|
|
class HRBConfig(datasets.BuilderConfig): |
|
def __init__(self, **kwargs): |
|
super().__init__(version=datasets.Version("1.0.1"), **kwargs) |
|
|
|
|
|
class HRB(datasets.GeneratorBasedBuilder): |
|
BUILDER_CONFIGS = [ |
|
HRBConfig( |
|
name=name, |
|
) |
|
for name in split_names |
|
] |
|
|
|
def _info(self): |
|
features = datasets.Features( |
|
{ |
|
"query": datasets.Value("string"), |
|
"options" : datasets.Value("string"), |
|
"answer": datasets.Value("string"), |
|
"category": datasets.Value("string"), |
|
} |
|
) |
|
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/hrb.v1.1.jsonl") |
|
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 data["category"] == self.config.name: |
|
buffer.append({ |
|
"query": data["query"], |
|
"options" : data["options"], |
|
"answer": data["answer"], |
|
"category": data["category"] |
|
}) |
|
|
|
for idx, dat in enumerate(buffer): |
|
yield idx,dat |
|
|