Narsil HF staff commited on
Commit
8a4dd8a
1 Parent(s): d0275f9

conversation dataset.

Browse files
conversational_dummy.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2021 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
+ """SUPERB: Speech processing Universal PERformance Benchmark."""
18
+
19
+
20
+ import datasets
21
+ from datasets.tasks import AutomaticSpeechRecognition
22
+
23
+
24
+ _CITATION = ""
25
+ _DESCRIPTION = ""
26
+
27
+
28
+ class AsrDummyConfig(datasets.BuilderConfig):
29
+ """BuilderConfig for Superb."""
30
+
31
+ def __init__(
32
+ self,
33
+ data_url,
34
+ url,
35
+ task_templates=None,
36
+ **kwargs,
37
+ ):
38
+ super().__init__(version=datasets.Version("1.9.0", ""), **kwargs)
39
+ self.data_url = data_url
40
+ self.url = url
41
+ self.task_templates = task_templates
42
+
43
+
44
+ class AsrDummy(datasets.GeneratorBasedBuilder):
45
+ """Superb dataset."""
46
+
47
+ BUILDER_CONFIGS = [
48
+ AsrDummyConfig(
49
+ name="conversational",
50
+ description="",
51
+ url="",
52
+ data_url="",
53
+ task_templates=[],
54
+ )
55
+ ]
56
+
57
+ DEFAULT_CONFIG_NAME = "conversational"
58
+
59
+ def _info(self):
60
+ return datasets.DatasetInfo(
61
+ description=_DESCRIPTION,
62
+ features=datasets.Features(
63
+ {
64
+ "id": datasets.Value("string"),
65
+ "generated_responses": datasets.features.Sequence(
66
+ datasets.Value("string")
67
+ ),
68
+ "past_user_inputs": datasets.features.Sequence(
69
+ datasets.Value("string")
70
+ ),
71
+ "new_user_input": datasets.Value("string"),
72
+ }
73
+ ),
74
+ supervised_keys=("file",),
75
+ homepage=self.config.url,
76
+ citation=_CITATION,
77
+ task_templates=self.config.task_templates,
78
+ )
79
+
80
+ def _split_generators(self, dl_manager):
81
+ return [
82
+ datasets.SplitGenerator(
83
+ name=datasets.Split.TEST,
84
+ gen_kwargs={},
85
+ ),
86
+ ]
87
+
88
+ def _generate_examples(self):
89
+ """Generate examples."""
90
+ # Only odd number to have user prompt
91
+ textss = [
92
+ ["Hello there", "Hello There", "Who are you ?"],
93
+ ["Hello there"],
94
+ [
95
+ "Hello there",
96
+ "Hello There",
97
+ "Can you help me ?",
98
+ "Yes what do you need ?",
99
+ "I am having a problem with your product",
100
+ ],
101
+ ]
102
+ for i, texts in enumerate(textss):
103
+ key = str(i)
104
+ past_user_inputs = texts[:-1:2]
105
+ generated_responses = texts[1::2]
106
+ new_user_input = texts[-1]
107
+ example = {
108
+ "id": key,
109
+ "generated_responses": generated_responses,
110
+ "past_user_inputs": past_user_inputs,
111
+ "new_user_input": new_user_input,
112
+ }
113
+ yield key, example
conversational_dummy.py.lock ADDED
File without changes