Bingsu commited on
Commit
a63ea8e
1 Parent(s): 5f15c9c

feat: python file

Browse files
Files changed (1) hide show
  1. arcalive_220506.py +51 -0
arcalive_220506.py CHANGED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+
3
+ import datasets
4
+
5
+ _DESCRIPTION = """
6
+ [아카라이브 베스트 라이브 채널](https://arca.live/b/live)의 2021년 8월 16일부터 2022년 5월 6일까지의 데이터를 수집하여, 댓글만 골라낸 데이터입니다.
7
+ """
8
+
9
+ _URL = "https://huggingface.co/datasets/Bingsu/arcalive_220506/resolve/main/"
10
+ _URLS = {"train": f"{_URL}live_210816-220506.json"}
11
+
12
+
13
+ class ArcaLiveData(datasets.GeneratorBasedBuilder):
14
+ BUILDER_CONFIGS = [
15
+ datasets.BuilderConfig(
16
+ name="arcalive comments",
17
+ version=datasets.Version("0.1.0"),
18
+ description="아카라이브 스크랩 데이터",
19
+ )
20
+ ]
21
+
22
+ features = datasets.Features({"text": datasets.Value("string")})
23
+
24
+ def _info(self):
25
+ return datasets.DatasetInfo(
26
+ description=_DESCRIPTION,
27
+ features=self.features,
28
+ supervised_keys=None,
29
+ license="cc0-1.0",
30
+ )
31
+
32
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
33
+ downloaded_files = dl_manager.download_and_extract(_URLS)
34
+
35
+ return [
36
+ datasets.SplitGenerator(
37
+ name=datasets.Split.TRAIN,
38
+ gen_kwargs={"filepath": downloaded_files["train"]},
39
+ ),
40
+ ]
41
+
42
+ def _generate_examples(self, filepath: str):
43
+ key = 0
44
+ with open(filepath, "r", encoding="utf-8") as file:
45
+ data = json.load(file)["data"]
46
+
47
+ for info in data:
48
+ for comment in info["comments"]:
49
+ yield key, {"text": comment}
50
+
51
+ key += 1