bgspaditya commited on
Commit
f1f6712
·
1 Parent(s): dab327a
Files changed (1) hide show
  1. maroondata.py +74 -0
maroondata.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Maroon Indonesian 100k Summarization Dataset."""
2
+
3
+
4
+ import json
5
+ import os
6
+
7
+ import datasets
8
+
9
+ _DESCRIPTION = """\
10
+ Combine IndoSum + Liputan6 in 100k rows.
11
+ """
12
+
13
+ _URL = "https://huggingface.co/datasets/bgspaditya/maroon100k/blob/main/maroondata.tar.bz2"
14
+
15
+ class Maroon100k(datasets.GeneratorBasedBuilder):
16
+ VERSION = datasets.Version("2.0.0")
17
+
18
+ BUILDER_CONFIGS = [
19
+ datasets.BuilderConfig(
20
+ name="Maroon100k",
21
+ version=datasets.Version("2.0.0")
22
+ )
23
+ ]
24
+
25
+ def _info(self):
26
+ return datasets.DatasetInfo(
27
+ description=_DESCRIPTION,
28
+ features=datasets.Features(
29
+ {
30
+ "article": datasets.Value("string"),
31
+ "summary": datasets.Value("string"),
32
+ }
33
+ ),
34
+ supervised_keys=None,
35
+ # citation=_CITATION,
36
+ # license=_LICENSE,
37
+ version=self.VERSION,
38
+ )
39
+
40
+ def _split_generators(self, dl_manager):
41
+ """Returns SplitGenerators."""
42
+ url = _URL
43
+
44
+ data_dir = dl_manager.download_and_extract(url)
45
+ return [
46
+ datasets.SplitGenerator(
47
+ name=datasets.Split.TRAIN,
48
+ gen_kwargs={
49
+ "filepath": os.path.join(data_dir, "train.jsonl"),
50
+ },
51
+ ),
52
+ datasets.SplitGenerator(
53
+ name=datasets.Split.TEST,
54
+ gen_kwargs={
55
+ "filepath": os.path.join(data_dir, "test.jsonl"),
56
+ },
57
+ ),
58
+ datasets.SplitGenerator(
59
+ name=datasets.Split.VALIDATION,
60
+ gen_kwargs={
61
+ "filepath": os.path.join(data_dir, "valid.jsonl"),
62
+ },
63
+ ),
64
+ ]
65
+
66
+ def _generate_examples(self, filepath):
67
+ """Yields examples as (key, example) tuples."""
68
+ with open(filepath, encoding="utf-8") as f:
69
+ for idx_, row in enumerate(f):
70
+ data = json.loads(row)
71
+ yield idx_, {
72
+ "article": data["article"],
73
+ "summary": data["summary"],
74
+ }