Upload melayu_brunei.py with huggingface_hub
Browse files- melayu_brunei.py +197 -0
melayu_brunei.py
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2022 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
|
17 |
+
from pathlib import Path
|
18 |
+
from typing import Dict, List, Tuple
|
19 |
+
|
20 |
+
import datasets
|
21 |
+
|
22 |
+
from seacrowd.utils.configs import SEACrowdConfig
|
23 |
+
from seacrowd.utils import schemas
|
24 |
+
from seacrowd.utils.constants import Tasks, Licenses, TASK_TO_SCHEMA
|
25 |
+
|
26 |
+
|
27 |
+
_CITATION = """\
|
28 |
+
@article{shiohara2021two,
|
29 |
+
title={Two Brunei Malay Texts: A Story of the Maiden Stem and Two Episodes in the History of Weston and Bukau},
|
30 |
+
author={Shiohara, Asako and Fitri, Mohd Izzuddin},
|
31 |
+
journal={アジア・アフリカの言語と言語学 (Asian and African languages and linguistics)},
|
32 |
+
number={15},
|
33 |
+
pages={171--190},
|
34 |
+
year={2021},
|
35 |
+
publisher={アジア・アフリカ言語文化研究所}
|
36 |
+
}
|
37 |
+
"""
|
38 |
+
|
39 |
+
|
40 |
+
_DATASETNAME = "melayu_brunei"
|
41 |
+
|
42 |
+
_DESCRIPTION = """\
|
43 |
+
This article gives two texts of Brunei Malay (ISO 639-3: kxd) collected in the town of Weston in Sabah State of Malaysia.
|
44 |
+
The texts exhibit linguistic features that are similar to those of Brunei Malay spoken in Brunei Darussalam;
|
45 |
+
it has a vowel inventory of only three vowels /a, i, u/, use of the pronoun kitani for the first person plural inclusive
|
46 |
+
and the use of the base-stem transitive form in patientive voice clauses. One of the texts tells a folk story about
|
47 |
+
Batang Dayang and other text includes two episodes: Javanese runaways arriving in Weston and the origin of the name
|
48 |
+
Bukau, a town near Weston.
|
49 |
+
"""
|
50 |
+
|
51 |
+
_HOMEPAGE = "https://github.com/matbahasa/Melayu_Brunei"
|
52 |
+
|
53 |
+
_LANGUAGES = ['kxd']
|
54 |
+
|
55 |
+
_LICENSE = Licenses.CC_BY_4_0.value
|
56 |
+
|
57 |
+
_LOCAL = False
|
58 |
+
|
59 |
+
_URLS = {
|
60 |
+
'Folklor2-1-01': 'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-01.txt',
|
61 |
+
'Folklor2-1-02':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-02.txt',
|
62 |
+
'Folklor2-1-03':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-03.txt',
|
63 |
+
'Folklor2-1-04':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-04.txt',
|
64 |
+
'Folklor2-1-05':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-05.txt',
|
65 |
+
'Folklor2-1-06':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-06.txt',
|
66 |
+
'Folklor2-1-07':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-07.txt',
|
67 |
+
'Folklor2-1-08':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-1-08.txt',
|
68 |
+
'Folklor2-2-01':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-01.txt',
|
69 |
+
'Folklor2-2-02':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-02.txt',
|
70 |
+
'Folklor2-2-03':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-03.txt',
|
71 |
+
'Folklor2-2-04':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-04.txt',
|
72 |
+
'Folklor2-2-05':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-05.txt',
|
73 |
+
'Folklor2-2-06':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-06.txt',
|
74 |
+
'Folklor2-2-07':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-07.txt',
|
75 |
+
'Folklor2-2-08':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-08.txt',
|
76 |
+
'Folklor2-2-09':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-09.txt',
|
77 |
+
'Folklor2-2-10':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-10.txt',
|
78 |
+
'Folklor2-2-11':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-11.txt',
|
79 |
+
'Folklor2-2-12':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-12.txt',
|
80 |
+
'Folklor2-2-13':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-13.txt',
|
81 |
+
'Folklor2-2-14':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-14.txt',
|
82 |
+
'Folklor2-2-15':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-15.txt',
|
83 |
+
'Folklor2-2-16':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-2-16.txt',
|
84 |
+
'Folklor2-3-01':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-01.txt',
|
85 |
+
'Folklor2-3-02':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-02.txt',
|
86 |
+
'Folklor2-3-03':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-03.txt',
|
87 |
+
'Folklor2-3-06':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-06.txt',
|
88 |
+
'Folklor2-3-07':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-07.txt',
|
89 |
+
'Folklor2-3-08':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-08.txt',
|
90 |
+
'Folklor2-3-09':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-09.txt',
|
91 |
+
'Folklor2-3-10':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-3-10.txt',
|
92 |
+
'Folklor2-4-00':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-00.txt',
|
93 |
+
'Folklor2-4-01':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-01.txt',
|
94 |
+
'Folklor2-4-02':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-02.txt',
|
95 |
+
'Folklor2-4-03':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-03.txt',
|
96 |
+
'Folklor2-4-04':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-04.txt',
|
97 |
+
'Folklor2-4-05':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-05.txt',
|
98 |
+
'Folklor2-4-06':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-06.txt',
|
99 |
+
'Folklor2-4-07':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-07.txt',
|
100 |
+
'Folklor2-4-08':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-08.txt',
|
101 |
+
'Folklor2-4-09':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-4-09.txt',
|
102 |
+
'Folklor2-5-01':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-5-01.txt',
|
103 |
+
'Folklor2-5-02':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-5-02.txt',
|
104 |
+
'Folklor2-5-03':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor2-5-03.txt',
|
105 |
+
'Folklor3-0-01':'https://raw.githubusercontent.com/matbahasa/Melayu_Brunei/master/Folklor/Folklor3-0-01.txt',
|
106 |
+
}
|
107 |
+
|
108 |
+
_SUPPORTED_TASKS = [Tasks.SELF_SUPERVISED_PRETRAINING]
|
109 |
+
|
110 |
+
|
111 |
+
_SOURCE_VERSION = "1.0.0"
|
112 |
+
|
113 |
+
_SEACROWD_VERSION = "2024.06.20"
|
114 |
+
|
115 |
+
|
116 |
+
# TODO: Name the dataset class to match the script name using CamelCase instead of snake_case
|
117 |
+
class MelayuBruneiDataset(datasets.GeneratorBasedBuilder):
|
118 |
+
"""This article gives two texts of Brunei Malay (ISO 639-3: kxd) collected in the town of
|
119 |
+
Weston in Sabah State of Malaysia. The texts exhibit linguistic features that are similar to those of
|
120 |
+
Brunei Malay spoken in Brunei Darussalam; it has a vowel inventory of only three vowels /a, i, u/,
|
121 |
+
use of the pronoun kitani for the first person plural inclusive and the use of the base-stem transitive
|
122 |
+
form in patientive voice clauses. One of the texts tells a folk story about Batang Dayang and other text
|
123 |
+
includes two episodes: Javanese runaways arriving in Weston and the origin of the name Bukau, a town near Weston.
|
124 |
+
"""
|
125 |
+
|
126 |
+
SOURCE_VERSION = datasets.Version(_SOURCE_VERSION)
|
127 |
+
SEACROWD_VERSION = datasets.Version(_SEACROWD_VERSION)
|
128 |
+
|
129 |
+
SEACROWD_SCHEMA_NAME = TASK_TO_SCHEMA[_SUPPORTED_TASKS[0]].lower()
|
130 |
+
|
131 |
+
BUILDER_CONFIGS = [
|
132 |
+
SEACrowdConfig(
|
133 |
+
name=f"{_DATASETNAME}_source",
|
134 |
+
version=SOURCE_VERSION,
|
135 |
+
description=f"{_DATASETNAME} source schema",
|
136 |
+
schema="source",
|
137 |
+
subset_id=f"{_DATASETNAME}",
|
138 |
+
),
|
139 |
+
SEACrowdConfig(
|
140 |
+
name=f"{_DATASETNAME}_seacrowd_{SEACROWD_SCHEMA_NAME}",
|
141 |
+
version=SEACROWD_VERSION,
|
142 |
+
description=f"{_DATASETNAME} SEACrowd schema",
|
143 |
+
schema=f"seacrowd_{SEACROWD_SCHEMA_NAME}",
|
144 |
+
subset_id=f"{_DATASETNAME}",
|
145 |
+
),
|
146 |
+
]
|
147 |
+
|
148 |
+
DEFAULT_CONFIG_NAME = f"{_DATASETNAME}_source"
|
149 |
+
|
150 |
+
def _info(self) -> datasets.DatasetInfo:
|
151 |
+
|
152 |
+
if self.config.schema == "source":
|
153 |
+
features = datasets.Features(
|
154 |
+
{
|
155 |
+
"id": datasets.Value("string"),
|
156 |
+
"text": datasets.Value("string"),
|
157 |
+
}
|
158 |
+
)
|
159 |
+
|
160 |
+
elif self.config.schema == f"seacrowd_{self.SEACROWD_SCHEMA_NAME}":
|
161 |
+
features = schemas.self_supervised_pretraining.features
|
162 |
+
|
163 |
+
return datasets.DatasetInfo(
|
164 |
+
description=_DESCRIPTION,
|
165 |
+
features=features,
|
166 |
+
homepage=_HOMEPAGE,
|
167 |
+
license=_LICENSE,
|
168 |
+
citation=_CITATION,
|
169 |
+
)
|
170 |
+
|
171 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
172 |
+
"""Returns SplitGenerators."""
|
173 |
+
urls = [_URLS[key] for key in _URLS.keys()]
|
174 |
+
data_path = dl_manager.download_and_extract(urls)
|
175 |
+
|
176 |
+
|
177 |
+
return [
|
178 |
+
datasets.SplitGenerator(
|
179 |
+
name=datasets.Split.TRAIN,
|
180 |
+
gen_kwargs={
|
181 |
+
"filepath": data_path[0],
|
182 |
+
"other_path": data_path[1:]
|
183 |
+
},
|
184 |
+
),
|
185 |
+
]
|
186 |
+
|
187 |
+
def _generate_examples(self, filepath: Path, other_path: List) -> Tuple[int, Dict]:
|
188 |
+
"""Yields examples as (key, example) tuples."""
|
189 |
+
|
190 |
+
filepaths = [filepath] + other_path
|
191 |
+
data = []
|
192 |
+
for filepath in filepaths:
|
193 |
+
with open(filepath, "r") as f:
|
194 |
+
data.append(" ".join([line.rstrip() for line in f.readlines()]))
|
195 |
+
|
196 |
+
for id, text in enumerate(data):
|
197 |
+
yield id, {"id": id, "text": text}
|