holylovenia commited on
Commit
4f6ca70
1 Parent(s): a7c56c7

Upload nusatranslation_mt.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. nusatranslation_mt.py +18 -18
nusatranslation_mt.py CHANGED
@@ -6,13 +6,13 @@ import re
6
  import datasets
7
  import pandas as pd
8
 
9
- from nusacrowd.utils import schemas
10
- from nusacrowd.utils.configs import NusantaraConfig
11
- from nusacrowd.utils.constants import DEFAULT_NUSANTARA_VIEW_NAME, DEFAULT_SOURCE_VIEW_NAME, Tasks
12
 
13
  _DATASETNAME = "nusatranslation_mt"
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
@@ -41,7 +41,7 @@ _SUPPORTED_TASKS = [Tasks.MACHINE_TRANSLATION]
41
 
42
  _SOURCE_VERSION = "1.0.0"
43
 
44
- _NUSANTARA_VERSION = "1.0.0"
45
 
46
  _URLS = {
47
  "train": "https://raw.githubusercontent.com/IndoNLP/nusa-writes/main/data/nusa_kalimat-mt-{lang}-train.csv",
@@ -69,7 +69,7 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
69
 
70
  BUILDER_CONFIGS = (
71
  [
72
- NusantaraConfig(
73
  name=f"nusatranslation_mt_ind_{subset}_source",
74
  version=datasets.Version(_SOURCE_VERSION),
75
  description=f"nusatranslation_mt ind2{subset} source schema",
@@ -79,17 +79,17 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
79
  for subset in _LANGUAGES[1:]
80
  ]
81
  + [
82
- NusantaraConfig(
83
- name=f"nusatranslation_mt_ind_{subset}_nusantara_t2t",
84
- version=datasets.Version(_NUSANTARA_VERSION),
85
  description=f"nusatranslation_mt ind2{subset} Nusantara schema",
86
- schema="nusantara_t2t",
87
  subset_id=f"nusatranslation_mt",
88
  )
89
  for subset in _LANGUAGES[1:]
90
  ]
91
  + [
92
- NusantaraConfig(
93
  name=f"nusatranslation_mt_{subset}_ind_source",
94
  version=datasets.Version(_SOURCE_VERSION),
95
  description=f"nusatranslation_mt {subset}2ind source schema",
@@ -99,11 +99,11 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
99
  for subset in _LANGUAGES[1:]
100
  ]
101
  + [
102
- NusantaraConfig(
103
- name=f"nusatranslation_mt_{subset}_ind_nusantara_t2t",
104
- version=datasets.Version(_NUSANTARA_VERSION),
105
  description=f"nusatranslation_mt {subset}2ind Nusantara schema",
106
- schema="nusantara_t2t",
107
  subset_id=f"nusatranslation_mt",
108
  )
109
  for subset in _LANGUAGES[1:]
@@ -115,7 +115,7 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
115
  def _info(self):
116
  if self.config.schema == "source":
117
  features = datasets.Features({"id": datasets.Value("string"), "text": datasets.Value("string"), "label": datasets.Value("string")})
118
- elif self.config.schema == "nusantara_t2t":
119
  features = schemas.text2text_features
120
 
121
  return datasets.DatasetInfo(
@@ -172,7 +172,7 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
172
  return src_lang, tgt_lang, self._merge_subsets(dfs, subsets, revert=(src_lang != "ind"))
173
 
174
  def _generate_examples(self, filepath: Path) -> Tuple[int, Dict]:
175
- if self.config.schema != "source" and self.config.schema != "nusantara_t2t":
176
  raise ValueError(f"Invalid config schema: {self.config.schema}")
177
 
178
  # print(filepath)
@@ -191,7 +191,7 @@ class NusaTranslationMT(datasets.GeneratorBasedBuilder):
191
  }
192
  yield idx, ex
193
 
194
- elif self.config.schema == "nusantara_t2t":
195
  for idx, row in enumerate(df.itertuples()):
196
  ex = {
197
  "id": str(idx),
 
6
  import datasets
7
  import pandas as pd
8
 
9
+ from seacrowd.utils import schemas
10
+ from seacrowd.utils.configs import SEACrowdConfig
11
+ from seacrowd.utils.constants import DEFAULT_SEACROWD_VIEW_NAME, DEFAULT_SOURCE_VIEW_NAME, Tasks
12
 
13
  _DATASETNAME = "nusatranslation_mt"
14
  _SOURCE_VIEW_NAME = DEFAULT_SOURCE_VIEW_NAME
15
+ _UNIFIED_VIEW_NAME = DEFAULT_SEACROWD_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
 
41
 
42
  _SOURCE_VERSION = "1.0.0"
43
 
44
+ _SEACROWD_VERSION = "2024.06.20"
45
 
46
  _URLS = {
47
  "train": "https://raw.githubusercontent.com/IndoNLP/nusa-writes/main/data/nusa_kalimat-mt-{lang}-train.csv",
 
69
 
70
  BUILDER_CONFIGS = (
71
  [
72
+ SEACrowdConfig(
73
  name=f"nusatranslation_mt_ind_{subset}_source",
74
  version=datasets.Version(_SOURCE_VERSION),
75
  description=f"nusatranslation_mt ind2{subset} source schema",
 
79
  for subset in _LANGUAGES[1:]
80
  ]
81
  + [
82
+ SEACrowdConfig(
83
+ name=f"nusatranslation_mt_ind_{subset}_seacrowd_t2t",
84
+ version=datasets.Version(_SEACROWD_VERSION),
85
  description=f"nusatranslation_mt ind2{subset} Nusantara schema",
86
+ schema="seacrowd_t2t",
87
  subset_id=f"nusatranslation_mt",
88
  )
89
  for subset in _LANGUAGES[1:]
90
  ]
91
  + [
92
+ SEACrowdConfig(
93
  name=f"nusatranslation_mt_{subset}_ind_source",
94
  version=datasets.Version(_SOURCE_VERSION),
95
  description=f"nusatranslation_mt {subset}2ind source schema",
 
99
  for subset in _LANGUAGES[1:]
100
  ]
101
  + [
102
+ SEACrowdConfig(
103
+ name=f"nusatranslation_mt_{subset}_ind_seacrowd_t2t",
104
+ version=datasets.Version(_SEACROWD_VERSION),
105
  description=f"nusatranslation_mt {subset}2ind Nusantara schema",
106
+ schema="seacrowd_t2t",
107
  subset_id=f"nusatranslation_mt",
108
  )
109
  for subset in _LANGUAGES[1:]
 
115
  def _info(self):
116
  if self.config.schema == "source":
117
  features = datasets.Features({"id": datasets.Value("string"), "text": datasets.Value("string"), "label": datasets.Value("string")})
118
+ elif self.config.schema == "seacrowd_t2t":
119
  features = schemas.text2text_features
120
 
121
  return datasets.DatasetInfo(
 
172
  return src_lang, tgt_lang, self._merge_subsets(dfs, subsets, revert=(src_lang != "ind"))
173
 
174
  def _generate_examples(self, filepath: Path) -> Tuple[int, Dict]:
175
+ if self.config.schema != "source" and self.config.schema != "seacrowd_t2t":
176
  raise ValueError(f"Invalid config schema: {self.config.schema}")
177
 
178
  # print(filepath)
 
191
  }
192
  yield idx, ex
193
 
194
+ elif self.config.schema == "seacrowd_t2t":
195
  for idx, row in enumerate(df.itertuples()):
196
  ex = {
197
  "id": str(idx),