albertvillanova HF staff commited on
Commit
eb7cc75
1 Parent(s): 4057ce5

Delete loading script

Browse files
Files changed (1) hide show
  1. air_dialogue.py +0 -289
air_dialogue.py DELETED
@@ -1,289 +0,0 @@
1
- # coding=utf-8
2
- # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
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
- """AirDialogue: A large dataset for goal oriented conversations."""
16
-
17
-
18
- import json
19
-
20
- import datasets
21
-
22
-
23
- # TODO: Add BibTeX citation
24
- # Find for instance the citation on arxiv or on the dataset repo/website
25
- _CITATION = """\
26
- @inproceedings{wei-etal-2018-airdialogue,
27
- title = "{A}ir{D}ialogue: An Environment for Goal-Oriented Dialogue Research",
28
- author = "Wei, Wei and
29
- Le, Quoc and
30
- Dai, Andrew and
31
- Li, Jia",
32
- booktitle = "Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing",
33
- month = oct # "-" # nov,
34
- year = "2018",
35
- address = "Brussels, Belgium",
36
- publisher = "Association for Computational Linguistics",
37
- url = "https://www.aclweb.org/anthology/D18-1419",
38
- doi = "10.18653/v1/D18-1419",
39
- pages = "3844--3854",
40
- abstract = "Recent progress in dialogue generation has inspired a number of studies on dialogue systems that are capable of accomplishing tasks through natural language interactions. A promising direction among these studies is the use of reinforcement learning techniques, such as self-play, for training dialogue agents. However, current datasets are limited in size, and the environment for training agents and evaluating progress is relatively unsophisticated. We present AirDialogue, a large dataset that contains 301,427 goal-oriented conversations. To collect this dataset, we create a context-generator which provides travel and flight restrictions. We then ask human annotators to play the role of a customer or an agent and interact with the goal of successfully booking a trip given the restrictions. Key to our environment is the ease of evaluating the success of the dialogue, which is achieved by using ground-truth states (e.g., the flight being booked) generated by the restrictions. Any dialogue agent that does not generate the correct states is considered to fail. Our experimental results indicate that state-of-the-art dialogue models can only achieve a score of 0.17 while humans can reach a score of 0.91, which suggests significant opportunities for future improvement.",
41
- }
42
- """
43
-
44
- # TODO: Add description of the dataset here
45
- # You can copy an official description
46
- _DESCRIPTION = """\
47
- AirDialogue, is a large dataset that contains 402,038 goal-oriented conversations. To collect this dataset, we create a contextgenerator which provides travel and flight restrictions. Then the human annotators are asked to play the role of a customer or an agent and interact with the goal of successfully booking a trip given the restrictions.
48
- """
49
-
50
- # TODO: Add a link to an official homepage for the dataset here
51
- _HOMEPAGE = "https://worksheets.codalab.org/worksheets/0xa79833f4b3c24f4188cee7131b120a59"
52
-
53
- # TODO: Add the licence for the dataset here if you can find it
54
- _LICENSE = "cc-by-nc-4.0"
55
-
56
- # TODO: Add link to the official dataset URLs here
57
- # The HuggingFace dataset library don't host the datasets but only point to the original files
58
- # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
59
- _URLs = {
60
- "air_dialogue_data": "https://storage.googleapis.com/airdialogue/airdialogue_data.tar.gz",
61
- "air_dialogue_kb": "https://storage.googleapis.com/airdialogue/airdialogue_data.tar.gz",
62
- }
63
-
64
-
65
- # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
66
- class AirDialogue(datasets.GeneratorBasedBuilder):
67
- """TODO: Short description of my dataset."""
68
-
69
- VERSION = datasets.Version("1.1.0")
70
-
71
- # This is an example of a dataset with multiple configurations.
72
- # If you don't want/need to define several sub-sets in your dataset,
73
- # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
74
-
75
- # If you need to make complex sub-parts in the datasets with configurable options
76
- # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
77
- # BUILDER_CONFIG_CLASS = MyBuilderConfig
78
-
79
- # You will be able to load one or the other configurations in the following list with
80
- # data = datasets.load_dataset('my_dataset', 'first_domain')
81
- # data = datasets.load_dataset('my_dataset', 'second_domain')
82
- BUILDER_CONFIGS = [
83
- datasets.BuilderConfig(
84
- name="air_dialogue_data", version=VERSION, description="This part of my dataset covers the dialog files"
85
- ),
86
- datasets.BuilderConfig(
87
- name="air_dialogue_kb", version=VERSION, description="This part of my dataset covers the knowledge base"
88
- ),
89
- ]
90
-
91
- DEFAULT_CONFIG_NAME = (
92
- "air_dialogue_data" # It's not mandatory to have a default configuration. Just use one if it make sense.
93
- )
94
-
95
- def _info(self):
96
- # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
97
- if (
98
- self.config.name == "air_dialogue_data"
99
- ): # This is the name of the configuration selected in BUILDER_CONFIGS above
100
- features = datasets.Features(
101
- {
102
- "action": {
103
- "status": datasets.Value("string"),
104
- "name": datasets.Value("string"),
105
- "flight": datasets.features.Sequence(datasets.Value("int32")),
106
- },
107
- "intent": {
108
- "return_month": datasets.Value("string"),
109
- "return_day": datasets.Value("string"),
110
- "max_price": datasets.Value("int32"),
111
- "departure_airport": datasets.Value("string"),
112
- "max_connections": datasets.Value("int32"),
113
- "departure_day": datasets.Value("string"),
114
- "goal": datasets.Value("string"),
115
- "departure_month": datasets.Value("string"),
116
- "name": datasets.Value("string"),
117
- "return_airport": datasets.Value("string"),
118
- },
119
- "timestamps": datasets.features.Sequence(datasets.Value("int64")),
120
- "dialogue": datasets.features.Sequence(datasets.Value("string")),
121
- "expected_action": {
122
- "status": datasets.Value("string"),
123
- "name": datasets.Value("string"),
124
- "flight": datasets.features.Sequence(datasets.Value("int32")),
125
- },
126
- "search_info": [
127
- {
128
- "button_name": datasets.Value("string"),
129
- "field_name": datasets.Value("string"),
130
- "field_value": datasets.Value("string"),
131
- "timestmamp": datasets.Value("int64"),
132
- },
133
- ],
134
- "correct_sample": datasets.Value("bool_"),
135
- }
136
- )
137
- else:
138
- features = datasets.Features(
139
- {
140
- "kb": [
141
- {
142
- "airline": datasets.Value("string"),
143
- "class": datasets.Value("string"),
144
- "departure_airport": datasets.Value("string"),
145
- "departure_day": datasets.Value("string"),
146
- "departure_month": datasets.Value("string"),
147
- "departure_time_num": datasets.Value("int32"),
148
- "flight_number": datasets.Value("int32"),
149
- "num_connections": datasets.Value("int32"),
150
- "price": datasets.Value("int32"),
151
- "return_airport": datasets.Value("string"),
152
- "return_day": datasets.Value("string"),
153
- "return_month": datasets.Value("string"),
154
- "return_time_num": datasets.Value("int32"),
155
- },
156
- ],
157
- "reservation": datasets.Value("int32"),
158
- }
159
- )
160
-
161
- return datasets.DatasetInfo(
162
- # This is the description that will appear on the datasets page.
163
- description=_DESCRIPTION,
164
- # This defines the different columns of the dataset and their types
165
- features=features, # Here we define them above because they are different between the two configurations
166
- # If there's a common (input, target) tuple from the features,
167
- # specify them here. They'll be used if as_supervised=True in
168
- # builder.as_dataset.
169
- supervised_keys=None,
170
- # Homepage of the dataset for documentation
171
- homepage=_HOMEPAGE,
172
- # License for the dataset if available
173
- license=_LICENSE,
174
- # Citation for the dataset
175
- citation=_CITATION,
176
- )
177
-
178
- def _split_generators(self, dl_manager):
179
- """Returns SplitGenerators."""
180
- # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
181
- # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
182
-
183
- # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
184
- # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
185
- # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
186
- my_urls = _URLs[self.config.name]
187
- archive = dl_manager.download(my_urls)
188
- if self.config.name == "air_dialogue_data":
189
- train = "airdialogue_data/airdialogue/train_data.json"
190
- dev = "airdialogue_data/airdialogue/dev_data.json"
191
- else:
192
- train = "airdialogue_data/airdialogue/train_kb.json"
193
- dev = "airdialogue_data/airdialogue/dev_kb.json"
194
-
195
- return [
196
- datasets.SplitGenerator(
197
- name=datasets.Split.TRAIN,
198
- # These kwargs will be passed to _generate_examples
199
- gen_kwargs={
200
- "filepath": train,
201
- "files": dl_manager.iter_archive(archive),
202
- },
203
- ),
204
- datasets.SplitGenerator(
205
- name=datasets.Split.VALIDATION,
206
- # These kwargs will be passed to _generate_examples
207
- gen_kwargs={
208
- "filepath": dev,
209
- "files": dl_manager.iter_archive(archive),
210
- },
211
- ),
212
- ]
213
-
214
- def _generate_examples(self, filepath, files):
215
- """Yields examples."""
216
- # TODO: This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
217
- # It is in charge of opening the given file and yielding (key, example) tuples from the dataset
218
- # The key is not important, it's more here for legacy reason (legacy from tfds)
219
-
220
- for path, f in files:
221
- if path == filepath:
222
- for id_, row in enumerate(f):
223
- row = row.decode("utf-8")
224
- data = json.loads(row)
225
- if self.config.name == "air_dialogue_data":
226
-
227
- intent = {
228
- "return_month": data["intent"]["return_month"],
229
- "return_day": data["intent"]["return_day"],
230
- "max_price": data["intent"]["max_price"],
231
- "departure_airport": data["intent"]["departure_airport"],
232
- "max_connections": data["intent"].get("max_connections", -1),
233
- "departure_day": data["intent"]["departure_day"],
234
- "goal": data["intent"]["goal"],
235
- "departure_month": data["intent"]["departure_month"],
236
- "name": data["intent"]["name"],
237
- "return_airport": data["intent"]["return_airport"],
238
- }
239
-
240
- search_info = (
241
- []
242
- if "search_info" not in data
243
- else [
244
- {
245
- "button_name": search_info.get("button_name", ""),
246
- "field_name": search_info.get("field_name", ""),
247
- "field_value": search_info.get("field_value", ""),
248
- "timestmamp": search_info["timestmamp"],
249
- }
250
- for search_info in data["search_info"]
251
- ]
252
- )
253
-
254
- yield id_, {
255
- "action": {key: data["action"][key] for key in data["action"]},
256
- "intent": intent,
257
- "timestamps": data["timestamps"],
258
- "dialogue": data["dialogue"],
259
- "expected_action": {key: data["expected_action"][key] for key in data["expected_action"]},
260
- "search_info": search_info,
261
- "correct_sample": data["correct_sample"],
262
- }
263
-
264
- else:
265
-
266
- kb = [
267
- {
268
- "airline": kb["airline"],
269
- "class": kb["class"],
270
- "departure_airport": kb["departure_airport"],
271
- "departure_day": kb["departure_day"],
272
- "departure_month": kb["departure_month"],
273
- "departure_time_num": kb["departure_time_num"],
274
- "flight_number": kb["flight_number"],
275
- "num_connections": kb["num_connections"],
276
- "price": kb["price"],
277
- "return_airport": kb["return_airport"],
278
- "return_day": kb["return_day"],
279
- "return_month": kb["return_month"],
280
- "return_time_num": kb["return_time_num"],
281
- }
282
- for kb in data["kb"]
283
- ]
284
-
285
- yield id_, {
286
- "kb": kb,
287
- "reservation": data["reservation"],
288
- }
289
- break