File size: 3,783 Bytes
4a9457b f652a24 4a9457b f336688 c0da60a f336688 4a9457b 29f90a0 4a9457b f652a24 4a9457b f652a24 4a9457b |
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 |
import datasets
import csv
_CITATION = """\
@misc{park2021klue,
title={KLUE: Korean Language Understanding Evaluation},
author={Sungjoon Park and Jihyung Moon and Sungdong Kim and Won Ik Cho and Jiyoon Han and Jangwon Park and Chisung Song and Junseong Kim and Yongsook Song and Taehwan Oh and Joohong Lee and Juhyun Oh and Sungwon Lyu and Younghoon Jeong and Inkwon Lee and Sangwoo Seo and Dongjun Lee and Hyunwoo Kim and Myeonghwa Lee and Seongbo Jang and Seungwon Do and Sunkyoung Kim and Kyungtae Lim and Jongwon Lee and Kyumin Park and Jamin Shin and Seonghyun Kim and Lucy Park and Alice Oh and Jungwoo Ha and Kyunghyun Cho},
year={2021},
eprint={2105.09680},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
"""
_LICENSE = "CC-BY-SA-4.0"
_DESCRIPTION = "klue YNAT dataset for boostcamp AI Tech data-centric project"
_DATA_URLS = {
"train": "https://huggingface.co/datasets/KimuGenie/YNAT/resolve/main/train.csv",
"test": "https://huggingface.co/datasets/KimuGenie/YNAT/resolve/main/test.csv",
}
_VERSION = "0.0.0"
class YNATConfig(datasets.BuilderConfig):
def __init__(self, data_url, **kwargs):
super().__init__(version=datasets.Version(_VERSION), **kwargs)
self.data_url = data_url
class YNAT(datasets.GeneratorBasedBuilder):
DEFAULT_CONFIG_NAME = "YNAT"
BUILDER_CONFIGS = [
YNATConfig(
name="YNAT",
data_url=_DATA_URLS,
)
]
def _info(self):
return datasets.DatasetInfo(
features=datasets.Features(
{
"ID": datasets.Value("string")
,"input_text": datasets.Value("string")
,"label_text": datasets.Value("string")
,"target": datasets.Value("int32")
,"predefined_news_category": datasets.Value("string")
,"annotations": {
"annotators": [datasets.Value("int32")],
"annotations": {
"first-scope": [datasets.Value("string")],
"second-scope": [datasets.Value("string")],
"third-scope": [datasets.Value("string")],
}
}
,"url": datasets.Value("string")
,"date": datasets.Value("string")
}
),
description=_DESCRIPTION,
citation=_CITATION,
license=_LICENSE,
)
def _split_generators(
self,
dl_manager: datasets.DownloadManager):
data_file = dl_manager.download_and_extract(self.config.data_url)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={
"data_file": data_file["train"],
"split": "train",
},
),
datasets.SplitGenerator(
name=datasets.Split.TEST,
gen_kwargs={
"data_file": data_file["test"],
"split": "test",
},
),
]
def _generate_examples(self, data_file: str, split: str):
with open(data_file, newline='', encoding="UTF-8") as csvfile:
reader = csv.reader(csvfile, delimiter=",")
feature_names = next(reader)
idx = 0
for row in reader:
features = {
"input_text": row[1],
}
if split != "test":
features["label_text"] = row[2]
yield idx, features
idx += 1 |