Update small_mc4.py
Browse files- small_mc4.py +19 -0
small_mc4.py
CHANGED
|
@@ -42,6 +42,17 @@ _N_SHARDS_PER_SPLIT = {
|
|
| 42 |
}
|
| 43 |
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
class Mc4Config(datasets.BuilderConfig):
|
| 46 |
"""BuilderConfig for mC4."""
|
| 47 |
|
|
@@ -96,6 +107,14 @@ class Mc4(datasets.GeneratorBasedBuilder):
|
|
| 96 |
)
|
| 97 |
for lang in self.config.languages
|
| 98 |
for index in range(_N_SHARDS_PER_SPLIT[lang][split])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
]
|
| 100 |
train_downloaded_files = dl_manager.download(data_urls["train"])
|
| 101 |
validation_downloaded_files = dl_manager.download(data_urls["validation"])
|
|
|
|
| 42 |
}
|
| 43 |
|
| 44 |
|
| 45 |
+
import requests
|
| 46 |
+
|
| 47 |
+
def check_file_exists(url):
|
| 48 |
+
try:
|
| 49 |
+
response = requests.head(url)
|
| 50 |
+
return response.status_code == 200
|
| 51 |
+
except requests.RequestException:
|
| 52 |
+
return False
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
class Mc4Config(datasets.BuilderConfig):
|
| 57 |
"""BuilderConfig for mC4."""
|
| 58 |
|
|
|
|
| 107 |
)
|
| 108 |
for lang in self.config.languages
|
| 109 |
for index in range(_N_SHARDS_PER_SPLIT[lang][split])
|
| 110 |
+
if check_file_exists(
|
| 111 |
+
_DATA_URL.format(
|
| 112 |
+
language=lang,
|
| 113 |
+
split_suffix="-validation" if split == "validation" else "",
|
| 114 |
+
index=index,
|
| 115 |
+
n_shards=_N_SHARDS_PER_SPLIT[lang][split],
|
| 116 |
+
)
|
| 117 |
+
)
|
| 118 |
]
|
| 119 |
train_downloaded_files = dl_manager.download(data_urls["train"])
|
| 120 |
validation_downloaded_files = dl_manager.download(data_urls["validation"])
|