Datasets:

Languages:
Indonesian
Multilinguality:
monolingual
Language Creators:
found
Annotations Creators:
no-annotation
Source Datasets:
extended
ArXiv:
Tags:
License:
acul3 commited on
Commit
7f339c7
1 Parent(s): 829b234

add script

Browse files
mc4-id-filter/{c4-id.tfrecord-01019-of-01024.json.gz → c4-id-validation.tfrecord-00000-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01023-of-01024.json.gz → c4-id-validation.tfrecord-00001-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01022-of-01024.json.gz → c4-id-validation.tfrecord-00002-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01021-of-01024.json.gz → c4-id-validation.tfrecord-00003-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01020-of-01024.json.gz → c4-id-validation.tfrecord-00004-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01018-of-01024.json.gz → c4-id-validation.tfrecord-00005-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01017-of-01024.json.gz → c4-id-validation.tfrecord-00006-of-00008.json.gz} RENAMED
File without changes
mc4-id-filter/{c4-id.tfrecord-01016-of-01024.json.gz → c4-id-validation.tfrecord-00007-of-00008.json.gz} RENAMED
File without changes
mc4_id.py ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 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
+ """Cleaned Indonesian split of the mC4 corpus."""
16
+ import json
17
+ import gzip
18
+ import textwrap
19
+ import datasets
20
+ logger = datasets.logging.get_logger(__name__)
21
+ _CITATION = """
22
+ @article{JMLR:v21:20-074,
23
+ author = {Colin Raffel and Noam Shazeer and Adam Roberts and Katherine Lee and Sharan Narang and Michael Matena and Yanqi Zhou and Wei Li and Peter J. Liu},
24
+ title = {Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer},
25
+ journal = {Journal of Machine Learning Research},
26
+ year = {2020},
27
+ volume = {21},
28
+ number = {140},
29
+ pages = {1-67},
30
+ url = {http://jmlr.org/papers/v21/20-074.html}
31
+ }
32
+ """
33
+ _DESCRIPTION = """\
34
+ A thoroughly cleaned version of the Italian portion of the multilingual
35
+ colossal, cleaned version of Common Crawl's web crawl corpus (mC4) by AllenAI.
36
+ Based on Common Crawl dataset: "https://commoncrawl.org".
37
+ This is the processed version of Google's mC4 dataset by AllenAI, with further cleaning
38
+ detailed in the repository README file.
39
+ """
40
+ _HOMEPAGE = "https://github.com/allenai/allennlp/discussions/5056"
41
+ _LICENSE = "Open Data Commons Attribution License (ODC-By) v1.0"
42
+ _BASE_URL = "https://huggingface.co/datasets/munggok/mc4-id/resolve/main/mc4-id-filter/c4-id{split_suffix}.tfrecord-{index:05d}-of-{n_shards:05d}.json.gz"
43
+ _CONFIGS = {
44
+ "tiny": {"train": 100, "validation": 1},
45
+ "small": {"train": 250, "validation": 2},
46
+ "medium": {"train": 500, "validation": 4},
47
+ "large": {"train": 750, "validation": 6},
48
+ "full": {"train": 1016, "validation": 8}
49
+ }
50
+ class CleanMc4IdConfig(datasets.BuilderConfig):
51
+ """BuilderConfig for the Clean mC4 Italian."""
52
+ def __init__(self, **kwargs):
53
+ """BuilderConfig for Clean mC4 Italian.
54
+ Args:
55
+ **kwargs: keyword arguments forwarded to super.
56
+ """
57
+ super().__init__(**kwargs)
58
+ class Mc4(datasets.GeneratorBasedBuilder):
59
+ """mC4, a colossal, cleaned version of Common Crawl's web crawl corpus."""
60
+ BUILDER_CONFIGS = [
61
+ CleanMc4IdConfig(
62
+ name="tiny",
63
+ version=datasets.Version("1.0.0"),
64
+ description=textwrap.dedent(
65
+ f"""\
66
+ A tiny cleaned version of the Italian portion of the multilingual C4 corpus.
67
+ Estimated size of compressed files: 10GB
68
+ """
69
+ )
70
+ ),
71
+ CleanMc4IdConfig(
72
+ name="small",
73
+ version=datasets.Version("1.0.0"),
74
+ description=textwrap.dedent(
75
+ f"""\
76
+ A small cleaned version of the Italian portion of the multilingual C4 corpus.
77
+ Estimated size of compressed files: 25GB
78
+ """
79
+ )
80
+ ),
81
+ CleanMc4IdConfig(
82
+ name="medium",
83
+ version=datasets.Version("1.0.0"),
84
+ description=textwrap.dedent(
85
+ f"""\
86
+ A medium cleaned version of the Italian portion of the multilingual C4 corpus.
87
+ Estimated size of compressed files: 50GB
88
+ """
89
+ )
90
+ ),
91
+ CleanMc4IdConfig(
92
+ name="large",
93
+ version=datasets.Version("1.0.0"),
94
+ description=textwrap.dedent(
95
+ f"""\
96
+ A large cleaned version of the Italian portion of the multilingual C4 corpus.
97
+ Estimated size of compressed files: 75GB
98
+ """
99
+ )
100
+ ),
101
+ CleanMc4IdConfig(
102
+ name="full",
103
+ version=datasets.Version("1.0.0"),
104
+ description=textwrap.dedent(
105
+ f"""\
106
+ The full cleaned version of the Italian portion of the multilingual C4 corpus.
107
+ Estimated size of compressed files: 103GB
108
+ """
109
+ )
110
+ )
111
+ ]
112
+ def _info(self):
113
+ return datasets.DatasetInfo(
114
+ description=_DESCRIPTION,
115
+ features=datasets.Features(
116
+ {
117
+ "text": datasets.Value("string"),
118
+ "timestamp": datasets.Value("string"),
119
+ "url": datasets.Value("string"),
120
+ }
121
+ ),
122
+ supervised_keys=None,
123
+ homepage=_HOMEPAGE,
124
+ license=_LICENSE,
125
+ citation=_CITATION,
126
+ )
127
+ def _split_generators(self, dl_manager):
128
+ data_urls = {}
129
+ for split in ["train", "validation"]:
130
+ data_urls[split] = [
131
+ _BASE_URL.format(
132
+ split_suffix="-validation" if split == "validation" else "",
133
+ index=index,
134
+ n_shards=8 if split == "validation" else 1024,
135
+ )
136
+ for index in range(_CONFIGS[self.config.name][split])
137
+ ]
138
+ train_downloaded_files = dl_manager.download(data_urls["train"])
139
+ validation_downloaded_files = dl_manager.download(data_urls["validation"])
140
+ return [
141
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": train_downloaded_files}),
142
+ datasets.SplitGenerator(
143
+ name=datasets.Split.VALIDATION, gen_kwargs={"filepaths": validation_downloaded_files}
144
+ ),
145
+ ]
146
+ def _generate_examples(self, filepaths):
147
+ """This function returns the examples in the raw (text) form by iterating on all the files."""
148
+ id_ = 0
149
+ for filepath in filepaths:
150
+ logger.info(f"Generating examples from {filepath}")
151
+ with gzip.open(open(filepath, "rb"), "rt", encoding="utf-8") as f:
152
+ for line in f:
153
+ if line:
154
+ example = json.loads(line)
155
+ yield id_, example
156
+ id_ += 1