arcalive_220506 / arcalive_220506.py
Bingsu's picture
feat: python file
a63ea8e
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