Datasets:
MLRS
/

Modalities:
Text
Languages:
Maltese
Libraries:
Datasets
License:
File size: 9,488 Bytes
f9314b1
2839b87
f9314b1
2839b87
 
 
 
 
 
 
cc1c062
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2839b87
 
d23bae7
 
2839b87
 
 
 
 
 
f9314b1
2839b87
 
 
 
 
 
 
 
 
 
 
 
 
 
f9314b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2839b87
 
 
 
 
 
 
f9314b1
 
 
 
2839b87
 
 
 
 
cc1c062
d23bae7
2839b87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f9314b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2839b87
 
 
 
 
 
 
 
 
 
 
f9314b1
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
import json
import os
from pathlib import Path

import datasets

_DESCRIPTION = """\
General Corpora for the Maltese language.
"""

_CITATION = """\
@inproceedings{BERTu,
    title       = {Pre-training Data Quality and Quantity for a Low-Resource Language: New Corpus and {BERT} Models for {M}altese},
    author      = {Micallef, Kurt and
                   Gatt, Albert and
                   Tanti, Marc and
                   van der Plas, Lonneke and
                   Borg, Claudia},
    booktitle   = {Proceedings of the 3rd Workshop on Deep Learning for Low-Resource NLP (DeepLo 2022)},
    day         = {14},
    month       = {07},
    year        = {2022},
    address     = {Seattle, Washington},
    publisher   = {Association for Computational Linguistics},
}
"""

_HOMEPAGE = "https://mlrs.research.um.edu.mt/"

_LICENSE = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0)"

_URL = "data/"
_SHUFFLED_URL = {
    "train": os.path.join(_URL, "shuffled/train.txt"),
    "validation": os.path.join(_URL, "shuffled/validation.txt"),
    "test": os.path.join(_URL, "shuffled/test.txt"),
}
_SUBSET_URL_PATTERN = "{}/**/*.jsonl"


class KorpusMalti(datasets.GeneratorBasedBuilder):
    """Korpus Malti: General Corpora for the Maltese Language"""

    VERSION = datasets.Version("4.0.0")

    DEFAULT_CONFIG_NAME = "shuffled"

    BUILDER_CONFIGS = [
        datasets.BuilderConfig(name=DEFAULT_CONFIG_NAME,
                               version=VERSION,
                               description="The shuffled data from all subsets.",
                               ),
        datasets.BuilderConfig(name="belles_lettres",
                               version=VERSION,
                               description="Literary texts, usually published and included in the corpus by permission of the copyright holder. Unfortunately these cannot be disseminated in their integral form.",
                               ),
        datasets.BuilderConfig(name="blogs",
                               version=VERSION,
                               description="Online blog articles from specific blogs, identified in advance and known to contain text written (or human-translated into) Maltese.",
                               ),
        datasets.BuilderConfig(name="comics",
                               version=VERSION,
                               description="A small set of online information about comic books in Maltese.",
                               ),
        datasets.BuilderConfig(name="court",
                               version=VERSION,
                               description="Publicly available proceedings form the courts of Malta.",
                               ),
        datasets.BuilderConfig(name="eu_docs",
                               version=VERSION,
                               description="Miscellaneous policy documents from the European Union institutions.",
                               ),
        datasets.BuilderConfig(name="gov_docs",
                               version=VERSION,
                               description="Miscellaneous policy documents from the Government of Malta.",
                               ),
        datasets.BuilderConfig(name="government_gazzette",
                               version=VERSION,
                               description="The official, publicly available gazette of the Government of Malta. The gazzette is bilingual; only the Maltese text is included.",
                               ),
        datasets.BuilderConfig(name="law_eu",
                               version=VERSION,
                               description="Miscellaneous EU laws in their official Maltese translation, obtained via the Eur-Lex repository and including the segments of the Acquis Communautaire available in the DGT translation memory.",
                               ),
        datasets.BuilderConfig(name="law_mt",
                               version=VERSION,
                               description="Maltese laws.",
                               ),
        datasets.BuilderConfig(name="legal",
                               version=VERSION,
                               description="Miscellaneous legal text.",
                               ),
        datasets.BuilderConfig(name="nonfiction",
                               version=VERSION,
                               description="Miscellaneous nonfiction, published or unpublished. Published texts are included with the permission of the copyright holder, where relevant.",
                               ),
        datasets.BuilderConfig(name="parliament",
                               version=VERSION,
                               description="The officially released transcripts of parliamentary debates of the Maltese parliament.",
                               ),
        datasets.BuilderConfig(name="press_eu",
                               version=VERSION,
                               description="Press releases in Maltese by the European Council of Ministers, European Parliament and European Commission.",
                               ),
        datasets.BuilderConfig(name="press_mt",
                               version=VERSION,
                               description="Articles in the Maltese press, sourced primarily from the online portals of Maltese newspapers.",
                               ),
        datasets.BuilderConfig(name="speeches",
                               version=VERSION,
                               description="Miscellaneous speeches in Maltese (pre-written).",
                               ),
        datasets.BuilderConfig(name="theses",
                               version=VERSION,
                               description="Academic dissertations written in Maltese.",
                               ),
        datasets.BuilderConfig(name="umlib_oar",
                               version=VERSION,
                               description="Very broad variety of nonfiction texts which are publicly available in the University of Malta Open Access Repository. Included with help and permission from the University of Malta library.",
                               ),
        datasets.BuilderConfig(name="web_general",
                               version=VERSION,
                               description="Miscellaneous text scraped from pre-identified web pages in Maltese.",
                               ),
        datasets.BuilderConfig(name="wiki",
                               version=VERSION,
                               description="The Maltese Wikipedia dump (downloaded 26th May, 2020).",
                               ),
    ]

    def _info(self):
        if self.config.name == self.DEFAULT_CONFIG_NAME:
            features = {
                "text": datasets.Value("string"),
            }
        else:
            features = {
                "text": datasets.Sequence(datasets.Value("string")),
            }

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=datasets.Features(features),
            homepage=_HOMEPAGE,
            citation=_CITATION,
            license=_LICENSE,
        )

    def _split_generators(self, dl_manager):
        if self.config.name == self.DEFAULT_CONFIG_NAME:
            data_files = dl_manager.download_and_extract(_SHUFFLED_URL)
            data_split = [
                datasets.SplitGenerator(
                    name=datasets.Split.TRAIN,
                    gen_kwargs={
                        "filepath": data_files["train"],
                    },
                ),
                datasets.SplitGenerator(
                    name=datasets.Split.VALIDATION,
                    gen_kwargs={
                        "filepath": data_files["validation"],
                    },
                ),
                datasets.SplitGenerator(
                    name=datasets.Split.TEST,
                    gen_kwargs={
                        "filepath": data_files["test"],
                    },
                ),
            ]
        else:
            file_pattern = _SUBSET_URL_PATTERN.format(self.config.name)
            base_path = self.base_path or ""
            file_paths = [path.relative_to(base_path)
                          for path in Path(os.path.join(base_path, _URL)).glob(file_pattern)]

            data_files = dl_manager.download_and_extract(file_paths)
            data_split = [
                datasets.SplitGenerator(
                    name=datasets.Split.TRAIN,
                    gen_kwargs={
                        "filepath": data_files,
                    },
                ),
            ]

        return data_split

    def _generate_examples(self, filepath):
        if self.config.name == self.DEFAULT_CONFIG_NAME:
            with open(filepath, encoding="utf-8") as file:
                for key, line in enumerate(file):
                    if len(line) > 0:
                        yield key, {
                            "text": line,
                        }
        else:
            key = 0
            for path in filepath:
                with open(path, encoding="utf-8") as file:
                    for line in file:
                        data = json.loads(line)
                        yield key, {
                            "text": data["text"],
                        }
                        key += 1