Yan-Jia Huang
commited on
Commit
•
6c9a0d9
1
Parent(s):
0c0aac4
fix: minor
Browse files
cc100.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import datasets
|
2 |
|
|
|
3 |
_LANGUAGES = [
|
4 |
"af",
|
5 |
"am",
|
@@ -118,12 +119,11 @@ _LANGUAGES = [
|
|
118 |
"zh-Hant",
|
119 |
"zu",
|
120 |
]
|
121 |
-
_VERSION = "0.0.1"
|
122 |
|
123 |
|
124 |
class Cc100Config(datasets.BuilderConfig):
|
125 |
-
def __init__(self, lang
|
126 |
-
super().__init__(name=
|
127 |
|
128 |
self.lang = lang
|
129 |
|
@@ -131,20 +131,18 @@ class Cc100Config(datasets.BuilderConfig):
|
|
131 |
class Cc100(datasets.GeneratorBasedBuilder):
|
132 |
BUILDER_CONFIG_CLASS = Cc100Config
|
133 |
BUILDER_CONFIGS = [
|
134 |
-
Cc100Config(lang=lang,
|
135 |
for lang in _LANGUAGES
|
136 |
]
|
137 |
|
138 |
def _info(self):
|
139 |
return datasets.DatasetInfo(
|
140 |
-
description="https://data.statmt.org/cc-100/",
|
141 |
features=datasets.Features(
|
142 |
{
|
143 |
"id": datasets.Value("string"),
|
144 |
"text": datasets.Value("string"),
|
145 |
},
|
146 |
),
|
147 |
-
supervised_keys=None,
|
148 |
)
|
149 |
|
150 |
def _split_generators(self, dl_manager):
|
@@ -154,13 +152,14 @@ class Cc100(datasets.GeneratorBasedBuilder):
|
|
154 |
|
155 |
return [
|
156 |
datasets.SplitGenerator(
|
157 |
-
name=datasets.Split.TRAIN,
|
|
|
158 |
)
|
159 |
]
|
160 |
|
161 |
def _generate_examples(self, datapath):
|
162 |
with open(datapath, encoding="utf-8") as f:
|
163 |
-
for i,
|
164 |
-
|
165 |
|
166 |
-
yield
|
|
|
1 |
import datasets
|
2 |
|
3 |
+
_VERSION = "0.0.1"
|
4 |
_LANGUAGES = [
|
5 |
"af",
|
6 |
"am",
|
|
|
119 |
"zh-Hant",
|
120 |
"zu",
|
121 |
]
|
|
|
122 |
|
123 |
|
124 |
class Cc100Config(datasets.BuilderConfig):
|
125 |
+
def __init__(self, lang, *args, **kwargs):
|
126 |
+
super().__init__(name=lang, *args, **kwargs)
|
127 |
|
128 |
self.lang = lang
|
129 |
|
|
|
131 |
class Cc100(datasets.GeneratorBasedBuilder):
|
132 |
BUILDER_CONFIG_CLASS = Cc100Config
|
133 |
BUILDER_CONFIGS = [
|
134 |
+
Cc100Config(lang=lang, version=datasets.Version(_VERSION))
|
135 |
for lang in _LANGUAGES
|
136 |
]
|
137 |
|
138 |
def _info(self):
|
139 |
return datasets.DatasetInfo(
|
|
|
140 |
features=datasets.Features(
|
141 |
{
|
142 |
"id": datasets.Value("string"),
|
143 |
"text": datasets.Value("string"),
|
144 |
},
|
145 |
),
|
|
|
146 |
)
|
147 |
|
148 |
def _split_generators(self, dl_manager):
|
|
|
152 |
|
153 |
return [
|
154 |
datasets.SplitGenerator(
|
155 |
+
name=datasets.Split.TRAIN,
|
156 |
+
gen_kwargs={"datapath": datapath},
|
157 |
)
|
158 |
]
|
159 |
|
160 |
def _generate_examples(self, datapath):
|
161 |
with open(datapath, encoding="utf-8") as f:
|
162 |
+
for i, text in enumerate(f):
|
163 |
+
example = (i, {"id": str(i), "text": text})
|
164 |
|
165 |
+
yield example
|