mathiascreutz
commited on
Commit
·
b9ec98e
1
Parent(s):
a40dcc3
Testing with a config
Browse files- opusparcus.py +24 -4
opusparcus.py
CHANGED
|
@@ -51,6 +51,24 @@ _URLs = {
|
|
| 51 |
|
| 52 |
}
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
class Opusparcus(datasets.GeneratorBasedBuilder):
|
| 55 |
|
| 56 |
"""TODO: Short description of my dataset."""
|
|
@@ -62,13 +80,13 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
| 62 |
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 63 |
# If you need to make complex sub-parts in the datasets with configurable options
|
| 64 |
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 65 |
-
|
| 66 |
# You will be able to load one or the other configurations in the following list with
|
| 67 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 68 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
#DEFAULT_CONFIG_NAME = "test" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 74 |
|
|
@@ -123,6 +141,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
| 123 |
name=datasets.Split.TEST,
|
| 124 |
# These kwargs will be passed to _generate_examples
|
| 125 |
gen_kwargs={
|
|
|
|
| 126 |
"filepath": data_dir["test"],
|
| 127 |
"split": "test"
|
| 128 |
},
|
|
@@ -131,6 +150,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
| 131 |
name=datasets.Split.VALIDATION,
|
| 132 |
# These kwargs will be passed to _generate_examples
|
| 133 |
gen_kwargs={
|
|
|
|
| 134 |
"filepath": data_dir["validation"],
|
| 135 |
"split": "validation",
|
| 136 |
},
|
|
|
|
| 51 |
|
| 52 |
}
|
| 53 |
|
| 54 |
+
class OpusparcusConfig(datasets.BuilderConfig):
|
| 55 |
+
"""BuilderConfig for Opusparcus."""
|
| 56 |
+
|
| 57 |
+
def __init__(self, lang=None, **kwargs):
|
| 58 |
+
"""BuilderConfig for Wikipedia.
|
| 59 |
+
Args:
|
| 60 |
+
language: string, the language code for the Wikipedia dump to use.
|
| 61 |
+
date: string, date of the Wikipedia dump in YYYYMMDD format. A list of
|
| 62 |
+
available dates can be found at https://dumps.wikimedia.org/enwiki/.
|
| 63 |
+
**kwargs: keyword arguments forwarded to super.
|
| 64 |
+
"""
|
| 65 |
+
super(WikipediaConfig, self).__init__(
|
| 66 |
+
name="{0}".format(lang),
|
| 67 |
+
description="Opusparcus dataset for {0}".format(lang),
|
| 68 |
+
**kwargs,
|
| 69 |
+
)
|
| 70 |
+
self.lang = lang
|
| 71 |
+
|
| 72 |
class Opusparcus(datasets.GeneratorBasedBuilder):
|
| 73 |
|
| 74 |
"""TODO: Short description of my dataset."""
|
|
|
|
| 80 |
# just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
|
| 81 |
# If you need to make complex sub-parts in the datasets with configurable options
|
| 82 |
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
| 83 |
+
BUILDER_CONFIG_CLASS = OpusparcusConfig
|
| 84 |
# You will be able to load one or the other configurations in the following list with
|
| 85 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
| 86 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
| 87 |
+
BUILDER_CONFIGS = [
|
| 88 |
+
datasets.OpusparcusConfig(lang="de", version=VERSION, description="This part of my dataset covers a first domain"),
|
| 89 |
+
]
|
| 90 |
|
| 91 |
#DEFAULT_CONFIG_NAME = "test" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
| 92 |
|
|
|
|
| 141 |
name=datasets.Split.TEST,
|
| 142 |
# These kwargs will be passed to _generate_examples
|
| 143 |
gen_kwargs={
|
| 144 |
+
"lang": self.config.lang
|
| 145 |
"filepath": data_dir["test"],
|
| 146 |
"split": "test"
|
| 147 |
},
|
|
|
|
| 150 |
name=datasets.Split.VALIDATION,
|
| 151 |
# These kwargs will be passed to _generate_examples
|
| 152 |
gen_kwargs={
|
| 153 |
+
"lang": self.config.lang
|
| 154 |
"filepath": data_dir["validation"],
|
| 155 |
"split": "validation",
|
| 156 |
},
|