joshuasiagian commited on
Commit
f106b75
1 Parent(s): 3c9bc95
Files changed (6) hide show
  1. .DS_Store +0 -0
  2. LICENSE +1 -0
  3. README.md +78 -0
  4. __init__.py +0 -0
  5. indosum.py +208 -0
  6. requirements.txt +1 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
LICENSE ADDED
@@ -0,0 +1 @@
 
 
1
+ Apache License, Version 2.0
README.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ language:
4
+ - ind
5
+ pretty_name: Indosum
6
+ task_categories:
7
+ - summarization
8
+ tags:
9
+ - summarization
10
+ ---
11
+
12
+ INDOSUM is a new benchmark dataset for Indonesian text summarization.
13
+ The dataset consists of news articles and manually constructed summaries.
14
+
15
+
16
+ ## Languages
17
+
18
+ ind
19
+
20
+ ## Supported Tasks
21
+
22
+ Summarization
23
+
24
+ ## Dataset Usage
25
+ ### Using `datasets` library
26
+ ```
27
+ from datasets import load_dataset
28
+ dset = datasets.load_dataset("SEACrowd/indosum", trust_remote_code=True)
29
+ ```
30
+ ### Using `seacrowd` library
31
+ ```import seacrowd as sc
32
+ # Load the dataset using the default config
33
+ dset = sc.load_dataset("indosum", schema="seacrowd")
34
+ # Check all available subsets (config names) of the dataset
35
+ print(sc.available_config_names("indosum"))
36
+ # Load the dataset using a specific config
37
+ dset = sc.load_dataset_by_config_name(config_name="<config_name>")
38
+ ```
39
+
40
+ More details on how to load the `seacrowd` library can be found [here](https://github.com/SEACrowd/seacrowd-datahub?tab=readme-ov-file#how-to-use).
41
+
42
+
43
+ ## Dataset Homepage
44
+
45
+ [https://github.com/kata-ai/indosum](https://github.com/kata-ai/indosum)
46
+
47
+ ## Dataset Version
48
+
49
+ Source: 1.0.0. SEACrowd: 2024.06.20.
50
+
51
+ ## Dataset License
52
+
53
+ Apache License, Version 2.0
54
+
55
+ ## Citation
56
+
57
+ If you are using the **Indosum** dataloader in your work, please cite the following:
58
+ ```
59
+ @INPROCEEDINGS{8629109,
60
+ author={Kurniawan, Kemal and Louvan, Samuel},
61
+ booktitle={2018 International Conference on Asian Language Processing (IALP)},
62
+ title={Indosum: A New Benchmark Dataset for Indonesian Text Summarization},
63
+ year={2018},
64
+ volume={},
65
+ number={},
66
+ pages={215-220},
67
+ doi={10.1109/IALP.2018.8629109}}
68
+
69
+
70
+ @article{lovenia2024seacrowd,
71
+ title={SEACrowd: A Multilingual Multimodal Data Hub and Benchmark Suite for Southeast Asian Languages},
72
+ author={Holy Lovenia and Rahmad Mahendra and Salsabil Maulana Akbar and Lester James V. Miranda and Jennifer Santoso and Elyanah Aco and Akhdan Fadhilah and Jonibek Mansurov and Joseph Marvin Imperial and Onno P. Kampman and Joel Ruben Antony Moniz and Muhammad Ravi Shulthan Habibi and Frederikus Hudi and Railey Montalan and Ryan Ignatius and Joanito Agili Lopo and William Nixon and Börje F. Karlsson and James Jaya and Ryandito Diandaru and Yuze Gao and Patrick Amadeus and Bin Wang and Jan Christian Blaise Cruz and Chenxi Whitehouse and Ivan Halim Parmonangan and Maria Khelli and Wenyu Zhang and Lucky Susanto and Reynard Adha Ryanda and Sonny Lazuardi Hermawan and Dan John Velasco and Muhammad Dehan Al Kautsar and Willy Fitra Hendria and Yasmin Moslem and Noah Flynn and Muhammad Farid Adilazuarda and Haochen Li and Johanes Lee and R. Damanhuri and Shuo Sun and Muhammad Reza Qorib and Amirbek Djanibekov and Wei Qi Leong and Quyet V. Do and Niklas Muennighoff and Tanrada Pansuwan and Ilham Firdausi Putra and Yan Xu and Ngee Chia Tai and Ayu Purwarianti and Sebastian Ruder and William Tjhi and Peerat Limkonchotiwat and Alham Fikri Aji and Sedrick Keh and Genta Indra Winata and Ruochen Zhang and Fajri Koto and Zheng-Xin Yong and Samuel Cahyawijaya},
73
+ year={2024},
74
+ eprint={2406.10118},
75
+ journal={arXiv preprint arXiv: 2406.10118}
76
+ }
77
+
78
+ ```
__init__.py ADDED
File without changes
indosum.py ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from pathlib import Path
3
+ from typing import Dict, List, Tuple
4
+
5
+ import datasets
6
+
7
+ from seacrowd.utils.configs import SEACrowdConfig
8
+ from seacrowd.utils.constants import Tasks
9
+ from seacrowd.utils import schemas
10
+ import jsonlines
11
+ from nltk.tokenize.treebank import TreebankWordDetokenizer
12
+
13
+ _CITATION = """\
14
+ @INPROCEEDINGS{8629109,
15
+ author={Kurniawan, Kemal and Louvan, Samuel},
16
+ booktitle={2018 International Conference on Asian Language Processing (IALP)},
17
+ title={Indosum: A New Benchmark Dataset for Indonesian Text Summarization},
18
+ year={2018},
19
+ volume={},
20
+ number={},
21
+ pages={215-220},
22
+ doi={10.1109/IALP.2018.8629109}}
23
+ """
24
+
25
+ _LOCAL = False
26
+ _LANGUAGES = ["ind"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
27
+ _DATASETNAME = "indosum"
28
+
29
+ _DESCRIPTION = """\
30
+ INDOSUM is a new benchmark dataset for Indonesian text summarization.
31
+ The dataset consists of news articles and manually constructed summaries.
32
+ """
33
+
34
+ _HOMEPAGE = "https://github.com/kata-ai/indosum"
35
+
36
+ _LICENSE = "Apache License, Version 2.0"
37
+
38
+ _URLS = {
39
+ _DATASETNAME: "https://www.kaggle.com/api/v1/datasets/download/siagian/indosum",
40
+ }
41
+
42
+ _SUPPORTED_TASKS = [Tasks.SUMMARIZATION]
43
+
44
+ _SOURCE_VERSION = "1.0.0"
45
+
46
+ _SEACROWD_VERSION = "2024.06.20"
47
+
48
+
49
+ class IndoSUM(datasets.GeneratorBasedBuilder):
50
+ """INDOSUM is a new benchmark dataset for Indonesian text summarization. The dataset consists of news articles and manually constructed summaries."""
51
+
52
+ SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
53
+ SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
54
+
55
+ BUILDER_CONFIGS = (
56
+ [
57
+ SEACrowdConfig(
58
+ name="indosum_fold{fold_number}_source".format(fold_number=i),
59
+ version=_SOURCE_VERSION,
60
+ description="indosum source schema",
61
+ schema="source",
62
+ subset_id="indosum_fold{fold_number}".format(fold_number=i),
63
+ ) for i in range(5)
64
+ ]
65
+ +
66
+ [
67
+ SEACrowdConfig(
68
+ name="indosum_fold{fold_number}_seacrowd_t2t".format(fold_number=i),
69
+ version=_SEACROWD_VERSION,
70
+ description="indosum Nusantara schema",
71
+ schema="seacrowd_t2t",
72
+ subset_id="indosum_fold{fold_number}".format(fold_number=i),
73
+ ) for i in range(5)
74
+ ]
75
+ )
76
+
77
+ DEFAULT_CONFIG_NAME = "indosum_fold0_source"
78
+
79
+ def _info(self) -> datasets.DatasetInfo:
80
+
81
+ if self.config.schema == "source":
82
+
83
+ features = datasets.Features(
84
+ {
85
+ "document": datasets.Value("string"),
86
+ "id": datasets.Value("string"),
87
+ "summary": datasets.Value("string")
88
+ }
89
+ )
90
+
91
+ elif self.config.schema == "seacrowd_t2t":
92
+ features = schemas.text2text_features
93
+
94
+ return datasets.DatasetInfo(
95
+ description=_DESCRIPTION,
96
+ features=features,
97
+ homepage=_HOMEPAGE,
98
+ license=_LICENSE,
99
+ citation=_CITATION,
100
+ )
101
+
102
+ def _get_fold_index(self):
103
+ try:
104
+ subset_id = self.config.subset_id
105
+ idx_fold = subset_id.index("_fold")
106
+ file_id = subset_id[(idx_fold + 5):]
107
+ return int(file_id)
108
+ except:
109
+ return 0
110
+
111
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
112
+ idx = self._get_fold_index()
113
+
114
+ urls = _URLS[_DATASETNAME]
115
+
116
+ data_dir = Path(dl_manager.download_and_extract(urls))
117
+
118
+ location = {
119
+ # "train": "indosum/train.0{fold_number}.jsonl",
120
+ # "test": "indosum/test.0{fold_number}.jsonl",
121
+ # "dev": "indosum/dev.0{fold_number}.jsonl"
122
+ "train": "train.0{fold_number}.jsonl",
123
+ "test": "test.0{fold_number}.jsonl",
124
+ "dev": "dev.0{fold_number}.jsonl"
125
+ }
126
+
127
+ data_dir = dl_manager.download_and_extract(urls)
128
+
129
+ return [
130
+ datasets.SplitGenerator(
131
+ name=datasets.Split.TRAIN,
132
+
133
+ gen_kwargs={
134
+ "filepath": os.path.join(data_dir, location["train"].format(fold_number=idx+1)),
135
+ "split": "train",
136
+ },
137
+ ),
138
+ datasets.SplitGenerator(
139
+ name=datasets.Split.TEST,
140
+ gen_kwargs={
141
+ "filepath": os.path.join(data_dir, location["test"].format(fold_number=idx+1)),
142
+ "split": "test",
143
+ },
144
+ ),
145
+ datasets.SplitGenerator(
146
+ name=datasets.Split.VALIDATION,
147
+ gen_kwargs={
148
+ "filepath": os.path.join(data_dir, location["dev"].format(fold_number=idx+1)),
149
+ "split": "dev",
150
+ },
151
+ ),
152
+ ]
153
+
154
+ def _get_full_paragraph_and_summary(self, data: Dict) -> Tuple[str, str]:
155
+ detokenizer = TreebankWordDetokenizer()
156
+ paragraph = ""
157
+ summary = ""
158
+ begin_paragraph = True
159
+ begin_summary = True
160
+
161
+ for each_paragraph in data["paragraphs"]:
162
+ for each_sentence in each_paragraph:
163
+ detokenized_sentence = detokenizer.detokenize(each_sentence)
164
+ if begin_paragraph:
165
+ paragraph+=detokenized_sentence
166
+ begin_paragraph = False
167
+ else:
168
+ paragraph = "{} {}".format(paragraph, detokenized_sentence)
169
+
170
+ for each_summary in data["summary"]:
171
+ detokenized_sentence = detokenizer.detokenize(each_summary)
172
+ if begin_summary:
173
+ summary+=detokenized_sentence
174
+ begin_summary = False
175
+ else:
176
+ summary = "{} {}".format(summary, detokenized_sentence)
177
+
178
+ return paragraph, summary
179
+
180
+ def _generate_examples(self, filepath: Path, split: str) -> Tuple[int, Dict]:
181
+
182
+ if self.config.schema == "source":
183
+ i = 0
184
+ with jsonlines.open(filepath) as f:
185
+ for each_data in f.iter():
186
+ full_paragraph, full_summary = self._get_full_paragraph_and_summary(each_data)
187
+ ex = {
188
+ "id": each_data["id"],
189
+ "document": full_paragraph,
190
+ "summary": full_summary
191
+ }
192
+ yield i, ex
193
+ i+=1
194
+
195
+ elif self.config.schema == "seacrowd_t2t":
196
+ i = 0
197
+ with jsonlines.open(filepath) as f:
198
+ for each_data in f.iter():
199
+ full_paragraph, full_summary = self._get_full_paragraph_and_summary(each_data)
200
+ ex = {
201
+ "id": each_data["id"],
202
+ "text_1": full_paragraph,
203
+ "text_2": full_summary,
204
+ "text_1_name": "document",
205
+ "text_2_name": "summary"
206
+ }
207
+ yield i, ex
208
+ i+=1
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ seacrowd>=0.2.0