Refactor dict literals, docstring and download splits
Browse files
alt.py
CHANGED
|
@@ -45,31 +45,27 @@ _WIKI_URL = "https://www2.nict.go.jp/astrec-att/member/mutiyama/ALT/ALT-Parallel
|
|
| 45 |
|
| 46 |
|
| 47 |
class AltParallelConfig(datasets.BuilderConfig):
|
| 48 |
-
"""BuilderConfig for ALT."""
|
| 49 |
|
| 50 |
def __init__(self, languages, **kwargs):
|
| 51 |
-
"""BuilderConfig for ALT.
|
| 52 |
|
| 53 |
Args:
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
languages: languages that will be used for translation. it should be one of the
|
| 57 |
**kwargs: keyword arguments forwarded to super.
|
| 58 |
"""
|
| 59 |
|
| 60 |
name = "alt-parallel"
|
| 61 |
|
| 62 |
description = "ALT Parallel Corpus"
|
| 63 |
-
super(
|
| 64 |
name=name,
|
| 65 |
description=description,
|
| 66 |
version=datasets.Version("1.0.0", ""),
|
| 67 |
**kwargs,
|
| 68 |
)
|
| 69 |
|
| 70 |
-
available_langs =
|
| 71 |
-
["bg", "en", "en_tok", "fil", "hi", "id", "ja", "khm", "lo", "ms", "my", "th", "vi", "zh"]
|
| 72 |
-
)
|
| 73 |
for language in languages:
|
| 74 |
assert language in available_langs
|
| 75 |
|
|
@@ -184,7 +180,7 @@ class Alt(datasets.GeneratorBasedBuilder):
|
|
| 184 |
else:
|
| 185 |
data_path = dl_manager.download_and_extract(_URLs[self.config.name])
|
| 186 |
|
| 187 |
-
if self.config.name
|
| 188 |
return [
|
| 189 |
datasets.SplitGenerator(
|
| 190 |
name=datasets.Split.TRAIN,
|
|
@@ -192,9 +188,7 @@ class Alt(datasets.GeneratorBasedBuilder):
|
|
| 192 |
)
|
| 193 |
]
|
| 194 |
else:
|
| 195 |
-
data_split =
|
| 196 |
-
for k in _SPLIT:
|
| 197 |
-
data_split[k] = dl_manager.download_and_extract(_SPLIT[k])
|
| 198 |
|
| 199 |
return [
|
| 200 |
datasets.SplitGenerator(
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
class AltParallelConfig(datasets.BuilderConfig):
|
| 48 |
+
"""BuilderConfig for ALT Parallel."""
|
| 49 |
|
| 50 |
def __init__(self, languages, **kwargs):
|
| 51 |
+
"""BuilderConfig for ALT Parallel.
|
| 52 |
|
| 53 |
Args:
|
| 54 |
+
languages: languages that will be used for translation.
|
|
|
|
|
|
|
| 55 |
**kwargs: keyword arguments forwarded to super.
|
| 56 |
"""
|
| 57 |
|
| 58 |
name = "alt-parallel"
|
| 59 |
|
| 60 |
description = "ALT Parallel Corpus"
|
| 61 |
+
super().__init__(
|
| 62 |
name=name,
|
| 63 |
description=description,
|
| 64 |
version=datasets.Version("1.0.0", ""),
|
| 65 |
**kwargs,
|
| 66 |
)
|
| 67 |
|
| 68 |
+
available_langs = {"bg", "en", "en_tok", "fil", "hi", "id", "ja", "khm", "lo", "ms", "my", "th", "vi", "zh"}
|
|
|
|
|
|
|
| 69 |
for language in languages:
|
| 70 |
assert language in available_langs
|
| 71 |
|
|
|
|
| 180 |
else:
|
| 181 |
data_path = dl_manager.download_and_extract(_URLs[self.config.name])
|
| 182 |
|
| 183 |
+
if self.config.name in {"alt-my-transliteration", "alt-my-west-transliteration"}:
|
| 184 |
return [
|
| 185 |
datasets.SplitGenerator(
|
| 186 |
name=datasets.Split.TRAIN,
|
|
|
|
| 188 |
)
|
| 189 |
]
|
| 190 |
else:
|
| 191 |
+
data_split = dl_manager.download(_SPLIT)
|
|
|
|
|
|
|
| 192 |
|
| 193 |
return [
|
| 194 |
datasets.SplitGenerator(
|