Datasets:
Update mc4-sampling.py
Browse files- mc4-sampling.py +10 -12
mc4-sampling.py
CHANGED
|
@@ -271,17 +271,15 @@ _N_SHARDS_PER_SPLIT = {
|
|
| 271 |
class Mc4SamplingConfig(datasets.BuilderConfig):
|
| 272 |
"""BuilderConfig for mC4 Sampling."""
|
| 273 |
|
| 274 |
-
def __init__(self, *args, **kwargs):
|
| 275 |
"""BuilderConfig for mC4 Sampling.
|
| 276 |
Args:
|
| 277 |
languages (:obj:`List[str]`): list of languages to load
|
| 278 |
**kwargs: keyword arguments forwarded to super.
|
| 279 |
"""
|
| 280 |
-
print(args, kwargs)
|
| 281 |
-
languages = kwargs.pop("languages", [])
|
| 282 |
super().__init__(
|
| 283 |
*args,
|
| 284 |
-
|
| 285 |
**kwargs,
|
| 286 |
)
|
| 287 |
self.languages = languages
|
|
@@ -290,11 +288,11 @@ class Mc4SamplingConfig(datasets.BuilderConfig):
|
|
| 290 |
class Mc4Sampling(datasets.GeneratorBasedBuilder):
|
| 291 |
"""mC4 Sampling, a colossal, cleaned version of Common Crawl's web crawl corpus."""
|
| 292 |
|
| 293 |
-
BUILDER_CONFIGS = [Mc4SamplingConfig(
|
| 294 |
BUILDER_CONFIG_CLASS = Mc4SamplingConfig
|
| 295 |
|
| 296 |
-
def __init__(self, *args,
|
| 297 |
-
self.data_files = kwargs.
|
| 298 |
self.sampling_method = kwargs.pop("sampling_method", None)
|
| 299 |
self.perplexity_model = kwargs.pop("perplexity_model", None)
|
| 300 |
self.sampling_factor = kwargs.pop("sampling_factor", None)
|
|
@@ -322,11 +320,11 @@ class Mc4Sampling(datasets.GeneratorBasedBuilder):
|
|
| 322 |
self.should_keep_doc = self._should_keep_doc_gaussian
|
| 323 |
else:
|
| 324 |
self.should_keep_doc = self._should_keep_doc_step
|
| 325 |
-
init_kwargs = {
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
}
|
| 329 |
-
super().__init__(*args,
|
| 330 |
|
| 331 |
def get_perplexity(self, doc):
|
| 332 |
doc_log_score, doc_length = 0, 0
|
|
|
|
| 271 |
class Mc4SamplingConfig(datasets.BuilderConfig):
|
| 272 |
"""BuilderConfig for mC4 Sampling."""
|
| 273 |
|
| 274 |
+
def __init__(self, languages, *args, **kwargs):
|
| 275 |
"""BuilderConfig for mC4 Sampling.
|
| 276 |
Args:
|
| 277 |
languages (:obj:`List[str]`): list of languages to load
|
| 278 |
**kwargs: keyword arguments forwarded to super.
|
| 279 |
"""
|
|
|
|
|
|
|
| 280 |
super().__init__(
|
| 281 |
*args,
|
| 282 |
+
name="+".join(languages),
|
| 283 |
**kwargs,
|
| 284 |
)
|
| 285 |
self.languages = languages
|
|
|
|
| 288 |
class Mc4Sampling(datasets.GeneratorBasedBuilder):
|
| 289 |
"""mC4 Sampling, a colossal, cleaned version of Common Crawl's web crawl corpus."""
|
| 290 |
|
| 291 |
+
BUILDER_CONFIGS = [Mc4SamplingConfig(languages=[lang]) for lang in _LANGUAGES]
|
| 292 |
BUILDER_CONFIG_CLASS = Mc4SamplingConfig
|
| 293 |
|
| 294 |
+
def __init__(self, *args, **kwargs):
|
| 295 |
+
self.data_files = kwargs.get("data_files", {})
|
| 296 |
self.sampling_method = kwargs.pop("sampling_method", None)
|
| 297 |
self.perplexity_model = kwargs.pop("perplexity_model", None)
|
| 298 |
self.sampling_factor = kwargs.pop("sampling_factor", None)
|
|
|
|
| 320 |
self.should_keep_doc = self._should_keep_doc_gaussian
|
| 321 |
else:
|
| 322 |
self.should_keep_doc = self._should_keep_doc_step
|
| 323 |
+
# init_kwargs = {
|
| 324 |
+
# prop: kwargs.get(prop)
|
| 325 |
+
# for prop in ("name", "version", "data_dir", "data_files", "description")
|
| 326 |
+
# }
|
| 327 |
+
super().__init__(*args, **kwargs)
|
| 328 |
|
| 329 |
def get_perplexity(self, doc):
|
| 330 |
doc_log_score, doc_length = 0, 0
|