samuelcahyawijaya commited on
Commit
6974665
1 Parent(s): 17c2226

Update nusatranslation_mt.py

Browse files
Files changed (1) hide show
  1. nusatranslation_mt.py +6 -36
nusatranslation_mt.py CHANGED
@@ -14,7 +14,7 @@ _DATASETNAME = "nusatranslation_mt"
14
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
15
  _UNIFIED_VIEW_NAME = DEFAULT_NUSANTARA_VIEW_NAME
16
 
17
- _LANGUAGES = ["btk", "bew", "bug", "jav", "mad", "mak", "min", "mui", "rej", "sun"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
18
  _LOCAL = False
19
 
20
  _CITATION = """\
@@ -49,30 +49,6 @@ _URLS = {
49
  "test": "https://raw.githubusercontent.com/IndoNLP/nusa-writes/main/data/nusa_kalimat-mt-{lang}-test.csv",
50
  }
51
 
52
-
53
- # def nusantara_config_constructor(lang, schema, version):
54
- # """Construct NusantaraConfig with nusatranslation_mt_{lang}_{schema} as the name format"""
55
- # if schema != "source" and schema != "nusantara_t2t":
56
- # raise ValueError(f"Invalid schema: {schema}")
57
-
58
- # if lang == "":
59
- # return NusantaraConfig(
60
- # name="nusatranslation_mt_{schema}".format(schema=schema),
61
- # version=datasets.Version(version),
62
- # description="nusatranslation_mt with {schema} schema for all 12 languages".format(schema=schema),
63
- # schema=schema,
64
- # subset_id="nusatranslation_mt",
65
- # )
66
- # else:
67
- # return NusantaraConfig(
68
- # name="nusatranslation_mt_{lang}_{schema}".format(lang=lang, schema=schema),
69
- # version=datasets.Version(version),
70
- # description="nusatranslation_mt with {schema} schema for {lang} language".format(lang=lang, schema=schema),
71
- # schema=schema,
72
- # subset_id="nusatranslation_mt",
73
- # )
74
-
75
-
76
  LANGUAGES_MAP = {
77
  "abs": "ambon",
78
  "btk": "batak",
@@ -152,16 +128,10 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
152
 
153
  def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
154
  """Returns SplitGenerators."""
155
- if self.config.name == "nusatranslation_mt_source" or self.config.name == "nusatranslation_mt_nusantara_t2t":
156
- # Load all 12 languages
157
- train_csv_path = dl_manager.download_and_extract([_URLS["train"].format(lang=lang) for lang in LANGUAGES_MAP])
158
- validation_csv_path = dl_manager.download_and_extract([_URLS["validation"].format(lang=lang) for lang in LANGUAGES_MAP])
159
- test_csv_path = dl_manager.download_and_extract([_URLS["test"].format(lang=lang) for lang in LANGUAGES_MAP])
160
- else:
161
- lang = self.config.name.split("_")[2] if self.config.name.split("_")[2] != "ind" else self.config.name.split("_")[3]
162
- train_csv_path = Path(dl_manager.download_and_extract(_URLS["train"].format(lang=lang)))
163
- validation_csv_path = Path(dl_manager.download_and_extract(_URLS["validation"].format(lang=lang)))
164
- test_csv_path = Path(dl_manager.download_and_extract(_URLS["test"].format(lang=lang)))
165
 
166
  return [
167
  datasets.SplitGenerator(
@@ -232,4 +202,4 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
232
  }
233
  yield idx, ex
234
  else:
235
- raise ValueError(f"Invalid config: {self.config.name}")
 
14
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
15
  _UNIFIED_VIEW_NAME = DEFAULT_NUSANTARA_VIEW_NAME
16
 
17
+ _LANGUAGES = ["ind", "btk", "bew", "bug", "jav", "mad", "mak", "min", "mui", "rej", "sun"] # We follow ISO639-3 language code (https://iso639-3.sil.org/code_tables/639/data)
18
  _LOCAL = False
19
 
20
  _CITATION = """\
 
49
  "test": "https://raw.githubusercontent.com/IndoNLP/nusa-writes/main/data/nusa_kalimat-mt-{lang}-test.csv",
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  LANGUAGES_MAP = {
53
  "abs": "ambon",
54
  "btk": "batak",
 
128
 
129
  def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
130
  """Returns SplitGenerators."""
131
+ lang = self.config.name.split("_")[2] if self.config.name.split("_")[2] != "ind" else self.config.name.split("_")[3]
132
+ train_csv_path = Path(dl_manager.download_and_extract(_URLS["train"].format(lang=lang)))
133
+ validation_csv_path = Path(dl_manager.download_and_extract(_URLS["validation"].format(lang=lang)))
134
+ test_csv_path = Path(dl_manager.download_and_extract(_URLS["test"].format(lang=lang)))
 
 
 
 
 
 
135
 
136
  return [
137
  datasets.SplitGenerator(
 
202
  }
203
  yield idx, ex
204
  else:
205
+ raise ValueError(f"Invalid config: {self.config.name}")