holylovenia commited on
Commit
4abff89
1 Parent(s): 3c7e217

Upload talpco.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. talpco.py +15 -15
talpco.py CHANGED
@@ -4,9 +4,9 @@ from typing import Dict, List
4
 
5
  import datasets
6
 
7
- from nusacrowd.utils import schemas
8
- from nusacrowd.utils.configs import NusantaraConfig
9
- from nusacrowd.utils.constants import Tasks
10
 
11
  _CITATION = """\
12
  @article{published_papers/22434604,
@@ -39,16 +39,16 @@ _URLS = {
39
  }
40
  _SUPPORTED_TASKS = [Tasks.MACHINE_TRANSLATION]
41
  _SOURCE_VERSION = "1.0.0"
42
- _NUSANTARA_VERSION = "1.0.0"
43
 
44
 
45
- def nusantara_config_constructor(lang_source, lang_target, schema, version):
46
- """Construct NusantaraConfig with talpco_{lang_source}_{lang_target}_{schema} as the name format"""
47
- if schema != "source" and schema != "nusantara_t2t":
48
  raise ValueError(f"Invalid schema: {schema}")
49
 
50
  if lang_source == "" and lang_target == "":
51
- return NusantaraConfig(
52
  name="talpco_{schema}".format(schema=schema),
53
  version=datasets.Version(version),
54
  description="talpco with {schema} schema for all 7 language pairs from / to ind language".format(schema=schema),
@@ -56,7 +56,7 @@ def nusantara_config_constructor(lang_source, lang_target, schema, version):
56
  subset_id="talpco",
57
  )
58
  else:
59
- return NusantaraConfig(
60
  name="talpco_{lang_source}_{lang_target}_{schema}".format(lang_source=lang_source, lang_target=lang_target, schema=schema),
61
  version=datasets.Version(version),
62
  description="talpco with {schema} schema for {lang_source} source language and {lang_target} target language".format(lang_source=lang_source, lang_target=lang_target, schema=schema),
@@ -69,15 +69,15 @@ class TALPCo(datasets.GeneratorBasedBuilder):
69
  """TALPCo datasets contains 1372 datasets in 8 languages"""
70
 
71
  BUILDER_CONFIGS = (
72
- [nusantara_config_constructor(lang1, lang2, "source", _SOURCE_VERSION) for lang1 in _LANGUAGES for lang2 in _LANGUAGES if lang1 != lang2]
73
- + [nusantara_config_constructor(lang1, lang2, "nusantara_t2t", _NUSANTARA_VERSION) for lang1 in _LANGUAGES for lang2 in _LANGUAGES if lang1 != lang2]
74
- + [nusantara_config_constructor("", "", "source", _SOURCE_VERSION), nusantara_config_constructor("", "", "nusantara_t2t", _NUSANTARA_VERSION)]
75
  )
76
 
77
  DEFAULT_CONFIG_NAME = "talpco_jpn_ind_source"
78
 
79
  def _info(self) -> datasets.DatasetInfo:
80
- if self.config.schema == "source" or self.config.schema == "nusantara_t2t":
81
  features = schemas.text2text_features
82
  else:
83
  raise ValueError(f"Invalid config schema: {self.config.schema}")
@@ -112,10 +112,10 @@ class TALPCo(datasets.GeneratorBasedBuilder):
112
  ]
113
 
114
  def _generate_examples(self, data: Dict, split: str):
115
- if self.config.schema != "source" and self.config.schema != "nusantara_t2t":
116
  raise ValueError(f"Invalid config schema: {self.config.schema}")
117
 
118
- if self.config.name == "talpco_source" or self.config.name == "talpco_nusantara_t2t":
119
  # load all 7 language pairs from / to ind language
120
  lang_target = "ind"
121
  for lang_source in _LANGUAGES:
 
4
 
5
  import datasets
6
 
7
+ from seacrowd.utils import schemas
8
+ from seacrowd.utils.configs import SEACrowdConfig
9
+ from seacrowd.utils.constants import Tasks
10
 
11
  _CITATION = """\
12
  @article{published_papers/22434604,
 
39
  }
40
  _SUPPORTED_TASKS = [Tasks.MACHINE_TRANSLATION]
41
  _SOURCE_VERSION = "1.0.0"
42
+ _SEACROWD_VERSION = "2024.06.20"
43
 
44
 
45
+ def seacrowd_config_constructor(lang_source, lang_target, schema, version):
46
+ """Construct SEACrowdConfig with talpco_{lang_source}_{lang_target}_{schema} as the name format"""
47
+ if schema != "source" and schema != "seacrowd_t2t":
48
  raise ValueError(f"Invalid schema: {schema}")
49
 
50
  if lang_source == "" and lang_target == "":
51
+ return SEACrowdConfig(
52
  name="talpco_{schema}".format(schema=schema),
53
  version=datasets.Version(version),
54
  description="talpco with {schema} schema for all 7 language pairs from / to ind language".format(schema=schema),
 
56
  subset_id="talpco",
57
  )
58
  else:
59
+ return SEACrowdConfig(
60
  name="talpco_{lang_source}_{lang_target}_{schema}".format(lang_source=lang_source, lang_target=lang_target, schema=schema),
61
  version=datasets.Version(version),
62
  description="talpco with {schema} schema for {lang_source} source language and {lang_target} target language".format(lang_source=lang_source, lang_target=lang_target, schema=schema),
 
69
  """TALPCo datasets contains 1372 datasets in 8 languages"""
70
 
71
  BUILDER_CONFIGS = (
72
+ [seacrowd_config_constructor(lang1, lang2, "source", _SOURCE_VERSION) for lang1 in _LANGUAGES for lang2 in _LANGUAGES if lang1 != lang2]
73
+ + [seacrowd_config_constructor(lang1, lang2, "seacrowd_t2t", _SEACROWD_VERSION) for lang1 in _LANGUAGES for lang2 in _LANGUAGES if lang1 != lang2]
74
+ + [seacrowd_config_constructor("", "", "source", _SOURCE_VERSION), seacrowd_config_constructor("", "", "seacrowd_t2t", _SEACROWD_VERSION)]
75
  )
76
 
77
  DEFAULT_CONFIG_NAME = "talpco_jpn_ind_source"
78
 
79
  def _info(self) -> datasets.DatasetInfo:
80
+ if self.config.schema == "source" or self.config.schema == "seacrowd_t2t":
81
  features = schemas.text2text_features
82
  else:
83
  raise ValueError(f"Invalid config schema: {self.config.schema}")
 
112
  ]
113
 
114
  def _generate_examples(self, data: Dict, split: str):
115
+ if self.config.schema != "source" and self.config.schema != "seacrowd_t2t":
116
  raise ValueError(f"Invalid config schema: {self.config.schema}")
117
 
118
+ if self.config.name == "talpco_source" or self.config.name == "talpco_seacrowd_t2t":
119
  # load all 7 language pairs from / to ind language
120
  lang_target = "ind"
121
  for lang_source in _LANGUAGES: