Datasets:

ArXiv:
License:
afaji commited on
Commit
1d5773c
1 Parent(s): cfc778f
Files changed (2) hide show
  1. NusaX-MT.py +143 -0
  2. README.md +176 -0
NusaX-MT.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ from typing import Dict, List, Tuple
3
+
4
+ import datasets
5
+ import pandas as pd
6
+
7
+ _DATASETNAME = "NusaX_MT"
8
+
9
+ _LANGUAGES = ["ind", "ace", "ban", "bjn", "bbc", "bug", "jav", "mad", "min", "nij", "sun", "eng"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
10
+ _LOCAL = False
11
+
12
+ _CITATION = """\
13
+ @misc{winata2022nusax,
14
+ title={NusaX: Multilingual Parallel Sentiment Dataset for 10 Indonesian Local Languages},
15
+ author={Winata, Genta Indra and Aji, Alham Fikri and Cahyawijaya,
16
+ Samuel and Mahendra, Rahmad and Koto, Fajri and Romadhony,
17
+ Ade and Kurniawan, Kemal and Moeljadi, David and Prasojo,
18
+ Radityo Eko and Fung, Pascale and Baldwin, Timothy and Lau,
19
+ Jey Han and Sennrich, Rico and Ruder, Sebastian},
20
+ year={2022},
21
+ eprint={2205.15960},
22
+ archivePrefix={arXiv},
23
+ primaryClass={cs.CL}
24
+ }
25
+ """
26
+
27
+ _DESCRIPTION = """\
28
+ NusaX is a high-quality multilingual parallel corpus that covers 12 languages, Indonesian, English, and 10 Indonesian local languages, namely Acehnese, Balinese, Banjarese, Buginese, Madurese, Minangkabau, Javanese, Ngaju, Sundanese, and Toba Batak.
29
+ NusaX-MT is a parallel corpus for training and benchmarking machine translation models across 10 Indonesian local languages + Indonesian and English. The data is presented in csv format with 12 columns, one column for each language.
30
+ """
31
+
32
+ _HOMEPAGE = "https://github.com/IndoNLP/nusax/tree/main/datasets/mt"
33
+
34
+ _LICENSE = "Creative Commons Attribution Share-Alike 4.0 International"
35
+
36
+ _SOURCE_VERSION = "1.0.0"
37
+
38
+ _URLS = {
39
+ "train": "https://raw.githubusercontent.com/IndoNLP/nusax/main/datasets/mt/train.csv",
40
+ "validation": "https://raw.githubusercontent.com/IndoNLP/nusax/main/datasets/mt/valid.csv",
41
+ "test": "https://raw.githubusercontent.com/IndoNLP/nusax/main/datasets/mt/test.csv",
42
+ }
43
+
44
+ LANGUAGES_MAP = {
45
+ "ace": "acehnese",
46
+ "ban": "balinese",
47
+ "bjn": "banjarese",
48
+ "bug": "buginese",
49
+ "eng": "english",
50
+ "ind": "indonesian",
51
+ "jav": "javanese",
52
+ "mad": "madurese",
53
+ "min": "minangkabau",
54
+ "nij": "ngaju",
55
+ "sun": "sundanese",
56
+ "bbc": "toba_batak",
57
+ }
58
+
59
+
60
+ class NusaXMT(datasets.GeneratorBasedBuilder):
61
+ """NusaX-MT is a parallel corpus for training and benchmarking machine translation models across 10 Indonesian local languages + Indonesian and English. The data is presented in csv format with 12 columns, one column for each language."""
62
+
63
+ BUILDER_CONFIGS = [
64
+ datasets.BuilderConfig(name = f"{lang1}-{lang2}",
65
+ version = _SOURCE_VERSION)
66
+ for lang1 in LANGUAGES_MAP for lang2 in LANGUAGES_MAP if lang1 != lang2] + \
67
+ [datasets.BuilderConfig(name = f"ALL", version = _SOURCE_VERSION)]
68
+
69
+ DEFAULT_CONFIG_NAME = "ALL"
70
+ def _info(self) -> datasets.DatasetInfo:
71
+ features = datasets.Features(
72
+ {
73
+ "id": datasets.Value("string"),
74
+ "text_1": datasets.Value("string"),
75
+ "text_2": datasets.Value("string"),
76
+ "text_1_lang": datasets.Value("string"),
77
+ "text_2_lang": datasets.Value("string"),
78
+ }
79
+ )
80
+ return datasets.DatasetInfo(
81
+ description=_DESCRIPTION,
82
+ features=features,
83
+ homepage=_HOMEPAGE,
84
+ license=_LICENSE,
85
+ citation=_CITATION,
86
+ )
87
+
88
+ def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
89
+ """Returns SplitGenerators."""
90
+ train_csv_path = Path(dl_manager.download_and_extract(_URLS["train"]))
91
+ validation_csv_path = Path(dl_manager.download_and_extract(_URLS["validation"]))
92
+ test_csv_path = Path(dl_manager.download_and_extract(_URLS["test"]))
93
+
94
+ return [
95
+ datasets.SplitGenerator(
96
+ name=datasets.Split.TRAIN,
97
+ gen_kwargs={"filepath": train_csv_path},
98
+ ),
99
+ datasets.SplitGenerator(
100
+ name=datasets.Split.VALIDATION,
101
+ gen_kwargs={"filepath": validation_csv_path},
102
+ ),
103
+ datasets.SplitGenerator(
104
+ name=datasets.Split.TEST,
105
+ gen_kwargs={"filepath": test_csv_path},
106
+ ),
107
+ ]
108
+
109
+ def _generate_examples(self, filepath: Path) -> Tuple[int, Dict]:
110
+ df = pd.read_csv(filepath).reset_index()
111
+ if self.config.name == "ALL":
112
+ # load all 132 language pairs
113
+ id_count = -1
114
+ for lang_source in LANGUAGES_MAP:
115
+ for lang_target in LANGUAGES_MAP:
116
+ if lang_source == lang_target:
117
+ continue
118
+
119
+ for _, row in df.iterrows():
120
+ id_count += 1
121
+ ex = {
122
+ "id": str(id_count),
123
+ "text_1": row[LANGUAGES_MAP[lang_source]],
124
+ "text_2": row[LANGUAGES_MAP[lang_target]],
125
+ "text_1_lang": lang_source,
126
+ "text_2_lang": lang_target,
127
+ }
128
+ yield id_count, ex
129
+
130
+ else:
131
+ df = pd.read_csv(filepath).reset_index()
132
+ lang_source = self.config.name[0:3]
133
+ lang_target = self.config.name[4:7]
134
+
135
+ for index, row in df.iterrows():
136
+ ex = {
137
+ "id": str(index),
138
+ "text_1": row[LANGUAGES_MAP[lang_source]],
139
+ "text_2": row[LANGUAGES_MAP[lang_target]],
140
+ "text_1_lang": lang_source,
141
+ "text_2_lang": lang_target,
142
+ }
143
+ yield str(index), ex
README.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: NusaX-MT
3
+ annotations_creators:
4
+ - expert-generated
5
+ language_creators:
6
+ - expert-generated
7
+ license:
8
+ - cc-by-sa-4.0
9
+ multilinguality:
10
+ - multilingual
11
+ language:
12
+ - ace
13
+ - ban
14
+ - bjn
15
+ - bug
16
+ - en
17
+ - id
18
+ - jv
19
+ - mad
20
+ - min
21
+ - nij
22
+ - su
23
+ - bbc
24
+ size_categories:
25
+ - 10K<n<100K
26
+ source_datasets:
27
+ - original
28
+ task_categories:
29
+ - translation
30
+ dataset_info:
31
+ features:
32
+ - name: id
33
+ dtype: string
34
+ - name: text_1
35
+ dtype: string
36
+ - name: text_2
37
+ dtype: string
38
+ - name: text_1_lang
39
+ dtype: string
40
+ - name: text_2_lang
41
+ dtype: string
42
+ ---
43
+
44
+ # Dataset Card for NusaX-MT
45
+
46
+ ## Table of Contents
47
+ - [Dataset Description](#dataset-description)
48
+ - [Dataset Summary](#dataset-summary)
49
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
50
+ - [Languages](#languages)
51
+ - [Dataset Creation](#dataset-creation)
52
+ - [Curation Rationale](#curation-rationale)
53
+ - [Source Data](#source-data)
54
+ - [Annotations](#annotations)
55
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
56
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
57
+ - [Social Impact of Dataset](#social-impact-of-dataset)
58
+ - [Discussion of Biases](#discussion-of-biases)
59
+ - [Other Known Limitations](#other-known-limitations)
60
+ - [Additional Information](#additional-information)
61
+ - [Licensing Information](#licensing-information)
62
+ - [Citation Information](#citation-information)
63
+ - [Contributions](#contributions)
64
+
65
+ ## Dataset Description
66
+
67
+ - **Repository:** [GitHub](https://github.com/IndoNLP/nusax/tree/main/datasets/mt)
68
+ - **Paper:** [EACL 2022](https://arxiv.org/abs/2205.15960)
69
+ - **Point of Contact:** [GitHub](https://github.com/IndoNLP/nusax/tree/main/datasets/mt)
70
+
71
+ ### Dataset Summary
72
+
73
+ NusaX is a high-quality multilingual parallel corpus that covers 12 languages, Indonesian, English, and 10 Indonesian local languages, namely Acehnese, Balinese, Banjarese, Buginese, Madurese, Minangkabau, Javanese, Ngaju, Sundanese, and Toba Batak.
74
+ NusaX-MT is a parallel corpus for training and benchmarking machine translation models across 10 Indonesian local languages + Indonesian and English. The data is presented in csv format with 12 columns, one column for each language.
75
+
76
+
77
+ ### Supported Tasks and Leaderboards
78
+
79
+ - Machine translation for Indonesian languages
80
+
81
+ ### Languages
82
+
83
+ All possible pairs of the following:
84
+
85
+ - ace: acehnese,
86
+ - ban: balinese,
87
+ - bjn: banjarese,
88
+ - bug: buginese,
89
+ - eng: english,
90
+ - ind: indonesian,
91
+ - jav: javanese,
92
+ - mad: madurese,
93
+ - min: minangkabau,
94
+ - nij: ngaju,
95
+ - sun: sundanese,
96
+ - bbc: toba_batak,
97
+
98
+ ## Dataset Creation
99
+
100
+ ### Curation Rationale
101
+
102
+ There is a shortage of NLP research and resources for the Indonesian languages, despite the country having over 700 languages. With this in mind, we have created this dataset to support future research for the underrepresented languages in Indonesia.
103
+
104
+ ### Source Data
105
+
106
+ #### Initial Data Collection and Normalization
107
+
108
+ NusaX-MT is a dataset for machine translation in Indonesian langauges that has been expertly translated by native speakers.
109
+
110
+ #### Who are the source language producers?
111
+
112
+ The data was produced by humans (native speakers).
113
+
114
+ ### Annotations
115
+
116
+ #### Annotation process
117
+
118
+ NusaX-MT is derived from SmSA, which is the biggest publicly available dataset for Indonesian sentiment analysis. It comprises of comments and reviews from multiple online platforms. To ensure the quality of our dataset, we have filtered it by removing any abusive language and personally identifying information by manually reviewing all sentences. To ensure balance in the label distribution, we randomly picked 1,000 samples through stratified sampling and then translated them to the corresponding languages.
119
+
120
+ #### Who are the annotators?
121
+
122
+ Native speakers of both Indonesian and the corresponding languages.
123
+ Annotators were compensated based on the number of translated samples.
124
+
125
+ ### Personal and Sensitive Information
126
+
127
+ Personal information is removed.
128
+
129
+ ## Considerations for Using the Data
130
+
131
+ ### Social Impact of Dataset
132
+
133
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
134
+
135
+ ### Discussion of Biases
136
+
137
+ NusaX is created from review text. These data sources may contain some bias.
138
+
139
+ ### Other Known Limitations
140
+
141
+ No other known limitations
142
+
143
+ ## Additional Information
144
+
145
+ ### Licensing Information
146
+
147
+ CC-BY-SA 4.0.
148
+
149
+ Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
150
+
151
+ ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
152
+
153
+ No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
154
+
155
+ Please contact authors for any information on the dataset.
156
+
157
+ ### Citation Information
158
+
159
+ ```
160
+ @misc{winata2022nusax,
161
+ title={NusaX: Multilingual Parallel Sentiment Dataset for 10 Indonesian Local Languages},
162
+ author={Winata, Genta Indra and Aji, Alham Fikri and Cahyawijaya,
163
+ Samuel and Mahendra, Rahmad and Koto, Fajri and Romadhony,
164
+ Ade and Kurniawan, Kemal and Moeljadi, David and Prasojo,
165
+ Radityo Eko and Fung, Pascale and Baldwin, Timothy and Lau,
166
+ Jey Han and Sennrich, Rico and Ruder, Sebastian},
167
+ year={2022},
168
+ eprint={2205.15960},
169
+ archivePrefix={arXiv},
170
+ primaryClass={cs.CL}
171
+ }
172
+ ```
173
+
174
+ ### Contributions
175
+
176
+ Thanks to [@afaji](https://github.com/afaji) for adding this dataset.