File size: 1,570 Bytes
a63ea8e |
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 |
import json
import datasets
_DESCRIPTION = """
[아카라이브 베스트 라이브 채널](https://arca.live/b/live)의 2021년 8월 16일부터 2022년 5월 6일까지의 데이터를 수집하여, 댓글만 골라낸 데이터입니다.
"""
_URL = "https://huggingface.co/datasets/Bingsu/arcalive_220506/resolve/main/"
_URLS = {"train": f"{_URL}live_210816-220506.json"}
class ArcaLiveData(datasets.GeneratorBasedBuilder):
BUILDER_CONFIGS = [
datasets.BuilderConfig(
name="arcalive comments",
version=datasets.Version("0.1.0"),
description="아카라이브 스크랩 데이터",
)
]
features = datasets.Features({"text": datasets.Value("string")})
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=self.features,
supervised_keys=None,
license="cc0-1.0",
)
def _split_generators(self, dl_manager: datasets.DownloadManager):
downloaded_files = dl_manager.download_and_extract(_URLS)
return [
datasets.SplitGenerator(
name=datasets.Split.TRAIN,
gen_kwargs={"filepath": downloaded_files["train"]},
),
]
def _generate_examples(self, filepath: str):
key = 0
with open(filepath, "r", encoding="utf-8") as file:
data = json.load(file)["data"]
for info in data:
for comment in info["comments"]:
yield key, {"text": comment}
key += 1
|