holylovenia
commited on
Commit
•
4abff89
1
Parent(s):
3c7e217
Upload talpco.py with huggingface_hub
Browse files
talpco.py
CHANGED
@@ -4,9 +4,9 @@ from typing import Dict, List
|
|
4 |
|
5 |
import datasets
|
6 |
|
7 |
-
from
|
8 |
-
from
|
9 |
-
from
|
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 |
-
|
43 |
|
44 |
|
45 |
-
def
|
46 |
-
"""Construct
|
47 |
-
if schema != "source" and schema != "
|
48 |
raise ValueError(f"Invalid schema: {schema}")
|
49 |
|
50 |
if lang_source == "" and lang_target == "":
|
51 |
-
return
|
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
|
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 |
-
[
|
73 |
-
+ [
|
74 |
-
+ [
|
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 == "
|
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 != "
|
116 |
raise ValueError(f"Invalid config schema: {self.config.schema}")
|
117 |
|
118 |
-
if self.config.name == "talpco_source" or self.config.name == "
|
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:
|