mathiascreutz
commited on
Commit
•
786e261
1
Parent(s):
b9ec98e
Testing configs
Browse files- opusparcus.py +7 -5
opusparcus.py
CHANGED
@@ -62,7 +62,7 @@ class OpusparcusConfig(datasets.BuilderConfig):
|
|
62 |
available dates can be found at https://dumps.wikimedia.org/enwiki/.
|
63 |
**kwargs: keyword arguments forwarded to super.
|
64 |
"""
|
65 |
-
super(
|
66 |
name="{0}".format(lang),
|
67 |
description="Opusparcus dataset for {0}".format(lang),
|
68 |
**kwargs,
|
@@ -85,7 +85,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
85 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
86 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
87 |
BUILDER_CONFIGS = [
|
88 |
-
datasets.OpusparcusConfig(
|
89 |
]
|
90 |
|
91 |
#DEFAULT_CONFIG_NAME = "test" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
@@ -95,6 +95,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
95 |
#if self.config.name == "test": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
96 |
features = datasets.Features(
|
97 |
{
|
|
|
98 |
"sent1": datasets.Value("string"),
|
99 |
"sent2": datasets.Value("string"),
|
100 |
"annot_score": datasets.Value("float"),
|
@@ -141,7 +142,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
141 |
name=datasets.Split.TEST,
|
142 |
# These kwargs will be passed to _generate_examples
|
143 |
gen_kwargs={
|
144 |
-
"
|
145 |
"filepath": data_dir["test"],
|
146 |
"split": "test"
|
147 |
},
|
@@ -150,7 +151,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
150 |
name=datasets.Split.VALIDATION,
|
151 |
# These kwargs will be passed to _generate_examples
|
152 |
gen_kwargs={
|
153 |
-
"
|
154 |
"filepath": data_dir["validation"],
|
155 |
"split": "validation",
|
156 |
},
|
@@ -158,7 +159,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
158 |
]
|
159 |
|
160 |
def _generate_examples(
|
161 |
-
|
162 |
):
|
163 |
|
164 |
""" Yields examples as (key, example) tuples. """
|
@@ -168,6 +169,7 @@ class Opusparcus(datasets.GeneratorBasedBuilder):
|
|
168 |
for id_, row in enumerate(f):
|
169 |
data = json.loads(row)
|
170 |
yield id_, {
|
|
|
171 |
"sent1": data["sent1"],
|
172 |
"sent2": data["sent2"],
|
173 |
"annot_score": data["annot_score"],
|
|
|
62 |
available dates can be found at https://dumps.wikimedia.org/enwiki/.
|
63 |
**kwargs: keyword arguments forwarded to super.
|
64 |
"""
|
65 |
+
super(OpusparcusConfig, self).__init__(
|
66 |
name="{0}".format(lang),
|
67 |
description="Opusparcus dataset for {0}".format(lang),
|
68 |
**kwargs,
|
|
|
85 |
# data = datasets.load_dataset('my_dataset', 'first_domain')
|
86 |
# data = datasets.load_dataset('my_dataset', 'second_domain')
|
87 |
BUILDER_CONFIGS = [
|
88 |
+
datasets.OpusparcusConfig(name="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.
|
|
|
95 |
#if self.config.name == "test": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
96 |
features = datasets.Features(
|
97 |
{
|
98 |
+
"lang": datasets.Value("string"),
|
99 |
"sent1": datasets.Value("string"),
|
100 |
"sent2": datasets.Value("string"),
|
101 |
"annot_score": datasets.Value("float"),
|
|
|
142 |
name=datasets.Split.TEST,
|
143 |
# These kwargs will be passed to _generate_examples
|
144 |
gen_kwargs={
|
145 |
+
"name": self.config.name
|
146 |
"filepath": data_dir["test"],
|
147 |
"split": "test"
|
148 |
},
|
|
|
151 |
name=datasets.Split.VALIDATION,
|
152 |
# These kwargs will be passed to _generate_examples
|
153 |
gen_kwargs={
|
154 |
+
"name": self.config.name
|
155 |
"filepath": data_dir["validation"],
|
156 |
"split": "validation",
|
157 |
},
|
|
|
159 |
]
|
160 |
|
161 |
def _generate_examples(
|
162 |
+
self, name, filepath, split # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
163 |
):
|
164 |
|
165 |
""" Yields examples as (key, example) tuples. """
|
|
|
169 |
for id_, row in enumerate(f):
|
170 |
data = json.loads(row)
|
171 |
yield id_, {
|
172 |
+
"lang": data["lang"],
|
173 |
"sent1": data["sent1"],
|
174 |
"sent2": data["sent2"],
|
175 |
"annot_score": data["annot_score"],
|