Commit
•
c44c61f
0
Parent(s):
initial commit
Browse files- invoker/data.jsonl +3 -0
- juggernaut/data.jsonl +3 -0
- test_dataset.py +98 -0
invoker/data.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{"quas":"quas", "wex": "wex", "exort": "exort", "spell": "defeaning blast"}
|
2 |
+
{"quas":"quas quas quas", "wex": "", "exort": "", "spell": "cold snap"}
|
3 |
+
{"quas":"quas", "wex": "wex wex", "exort": "", "spell": "tornado"}
|
juggernaut/data.jsonl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{"context":"Looks like it's just you", "answer": "and me."}
|
2 |
+
{"context":"There's a fine line between bravery", "answer": "and stupidity."}
|
3 |
+
{"context":"If only I could scratch", "answer": "my nose..."}
|
test_dataset.py
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
|
16 |
+
# Lint as: python3
|
17 |
+
"""we're testin'"""
|
18 |
+
|
19 |
+
import datasets
|
20 |
+
import json
|
21 |
+
|
22 |
+
class TestDatasetConfig(datasets.BuilderConfig):
|
23 |
+
"""BuilderConfig for Test Dataset for testing HF parsing"""
|
24 |
+
|
25 |
+
def __init__(
|
26 |
+
self,
|
27 |
+
text_features,
|
28 |
+
hero = "juggernaut",
|
29 |
+
foo = "foo",
|
30 |
+
process_label=lambda x: x,
|
31 |
+
**kwargs,
|
32 |
+
):
|
33 |
+
"""BuilderConfig for TestDatset.
|
34 |
+
|
35 |
+
Args:
|
36 |
+
text_features: `dict[string, string]`, map from the name of the feature
|
37 |
+
dict for each text field to the name of the column in the tsv file
|
38 |
+
label_column: `string`, name of the column in the tsv file corresponding
|
39 |
+
to the label
|
40 |
+
data_dir: `string`, the path to the folder containing the tsv files in the
|
41 |
+
downloaded zip
|
42 |
+
label_classes: `list[string]`, the list of classes if the label is
|
43 |
+
categorical. If not provided, then the label will be of type
|
44 |
+
`datasets.Value('float32')`.
|
45 |
+
process_label: `Function[string, any]`, function taking in the raw value
|
46 |
+
of the label and processing it to the form required by the label feature
|
47 |
+
**kwargs: keyword arguments forwarded to super.
|
48 |
+
"""
|
49 |
+
super(TestDatasetConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
50 |
+
self.text_features = text_features
|
51 |
+
self.hero = hero
|
52 |
+
self.foo = foo
|
53 |
+
self.process_label = process_label
|
54 |
+
|
55 |
+
|
56 |
+
class TestDatasetEvals(datasets.GeneratorBasedBuilder):
|
57 |
+
"""The General Language Understanding Evaluation (GLUE) benchmark."""
|
58 |
+
|
59 |
+
BUILDER_CONFIGS = [
|
60 |
+
TestDatasetConfig(
|
61 |
+
name="name_for_test_dataset",
|
62 |
+
description= "this is a test dataset for our unit test intergrating HF datasets" ,
|
63 |
+
text_features={"context": "context", "answer": "answer"},
|
64 |
+
data_dir="heroes",
|
65 |
+
),
|
66 |
+
]
|
67 |
+
|
68 |
+
def _info(self):
|
69 |
+
features = {text_feature: datasets.Value("string") for text_feature in self.config.text_features.keys()}
|
70 |
+
features["idx"] = datasets.Value("int32")
|
71 |
+
return datasets.DatasetInfo(
|
72 |
+
description=self.config.description,
|
73 |
+
features=datasets.Features(features),
|
74 |
+
)
|
75 |
+
|
76 |
+
def _split_generators(self, dl_manager):
|
77 |
+
constructed_filepath = self.construct_filepath()
|
78 |
+
data_file = dl_manager.download(constructed_filepath)
|
79 |
+
return [
|
80 |
+
datasets.SplitGenerator(
|
81 |
+
name=datasets.Split.TEST,
|
82 |
+
gen_kwargs={
|
83 |
+
"data_file": data_file,
|
84 |
+
# "split": "test",
|
85 |
+
},
|
86 |
+
),
|
87 |
+
]
|
88 |
+
|
89 |
+
def construct_filepath(self):
|
90 |
+
return self.hero + '/' + self.config.data_dir + '/data.jsonl'
|
91 |
+
|
92 |
+
def _generate_examples(self, data_file):
|
93 |
+
with open(data_file, encoding="utf8") as f:
|
94 |
+
for n, row in enumerate(f):
|
95 |
+
data = json.loads(row)
|
96 |
+
example = {feat: data[col] for feat, col in self.config.text_features.items()}
|
97 |
+
example["idx"] = n
|
98 |
+
yield example["idx"], example
|