system HF staff commited on
Commit
68c5599
•
1 Parent(s): 88c0185

Update files from the datasets library (from 1.3.0)

Browse files

Release notes: https://github.com/huggingface/datasets/releases/tag/1.3.0

README.md CHANGED
@@ -43,6 +43,7 @@ task_ids:
43
  - [Dataset Curators](#dataset-curators)
44
  - [Licensing Information](#licensing-information)
45
  - [Citation Information](#citation-information)
 
46
 
47
  ## Dataset Description
48
 
@@ -58,7 +59,9 @@ Doc2dial is dataset of goal-oriented dialogues that are grounded in the associat
58
 
59
  ### Supported Tasks and Leaderboards
60
 
61
- [More Information Needed]
 
 
62
 
63
  ### Languages
64
 
@@ -77,11 +80,11 @@ Sample data instance for `dialogue_domain` :
77
  "domain": "dmv",
78
  "turns": [
79
  {
80
- "da": "assert/provide/precondition_pos",
81
- "reference": [
82
  {
83
- "keys": "4",
84
- "values": "['precondition']"
85
  }
86
  ],
87
  "role": "user",
@@ -89,19 +92,19 @@ Sample data instance for `dialogue_domain` :
89
  "utterance": "Hello, I forgot o update my address, can you help me with that?"
90
  },
91
  {
92
- "da": "respond/reply/open",
93
- "reference": [
94
  {
95
- "keys": "6",
96
- "values": "['solution']"
97
  },
98
  {
99
- "keys": "7",
100
- "values": "['solution']"
101
  },
102
  {
103
- "keys": "4",
104
- "values": "['reference']"
105
  }
106
  ],
107
  "role": "agent",
@@ -109,15 +112,15 @@ Sample data instance for `dialogue_domain` :
109
  "utterance": "hi, you have to report any change of address to DMV within 10 days after moving. You should do this both for the address associated with your license and all the addresses associated with all your vehicles."
110
  },
111
  {
112
- "da": "request/query/open",
113
- "reference": [
114
  {
115
- "keys": "56",
116
- "values": "['solution']"
117
  },
118
  {
119
- "keys": "48",
120
- "values": "['reference']"
121
  }
122
  ],
123
  "role": "user",
@@ -125,15 +128,15 @@ Sample data instance for `dialogue_domain` :
125
  "utterance": "Can I do my DMV transactions online?"
126
  },
127
  {
128
- "da": "respond/reply/open",
129
- "reference": [
130
  {
131
- "keys": "56",
132
- "values": "['solution']"
133
  },
134
  {
135
- "keys": "48",
136
- "values": "['reference']"
137
  }
138
  ],
139
  "role": "agent",
@@ -141,11 +144,11 @@ Sample data instance for `dialogue_domain` :
141
  "utterance": "Yes, you can sign up for MyDMV for all the online transactions needed."
142
  },
143
  {
144
- "da": "request/query/open",
145
- "reference": [
146
  {
147
- "keys": "48",
148
- "values": "['precondition']"
149
  }
150
  ],
151
  "role": "user",
@@ -153,23 +156,23 @@ Sample data instance for `dialogue_domain` :
153
  "utterance": "Thanks, and in case I forget to bring all of the documentation needed to the DMV office, what can I do?"
154
  },
155
  {
156
- "da": "respond/reply/open",
157
- "reference": [
158
  {
159
- "keys": "49",
160
- "values": "['solution']"
161
  },
162
  {
163
- "keys": "50",
164
- "values": "['solution']"
165
  },
166
  {
167
- "keys": "52",
168
- "values": "['solution']"
169
  },
170
  {
171
- "keys": "48",
172
- "values": "['reference']"
173
  }
174
  ],
175
  "role": "agent",
@@ -177,19 +180,19 @@ Sample data instance for `dialogue_domain` :
177
  "utterance": "This happens often with our customers so that's why our website and MyDMV are so useful for our customers. Just check if you can make your transaction online so you don't have to go to the DMV Office."
178
  },
179
  {
180
- "da": "request/query/follow-up",
181
- "reference": [
182
  {
183
- "keys": "6",
184
- "values": "['solution']"
185
  },
186
  {
187
- "keys": "7",
188
- "values": "['solution']"
189
  },
190
  {
191
- "keys": "4",
192
- "values": "['reference']"
193
  }
194
  ],
195
  "role": "user",
@@ -197,19 +200,19 @@ Sample data instance for `dialogue_domain` :
197
  "utterance": "Ok, and can you tell me again where should I report my new address?"
198
  },
199
  {
200
- "da": "respond/reply/open",
201
- "reference": [
202
  {
203
- "keys": "6",
204
- "values": "['solution']"
205
  },
206
  {
207
- "keys": "7",
208
- "values": "['solution']"
209
  },
210
  {
211
- "keys": "4",
212
- "values": "['reference']"
213
  }
214
  ],
215
  "role": "agent",
@@ -217,11 +220,11 @@ Sample data instance for `dialogue_domain` :
217
  "utterance": "Sure. Any change of address must be reported to the DMV, that's for the address associated with your license and any of your vehicles."
218
  },
219
  {
220
- "da": "request/query/open",
221
- "reference": [
222
  {
223
- "keys": "40",
224
- "values": "['precondition']"
225
  }
226
  ],
227
  "role": "user",
@@ -229,19 +232,19 @@ Sample data instance for `dialogue_domain` :
229
  "utterance": "Can you tell me more about Traffic points and their cost?"
230
  },
231
  {
232
- "da": "respond/reply/open",
233
- "reference": [
234
  {
235
- "keys": "41",
236
- "values": "['solution']"
237
  },
238
  {
239
- "keys": "43",
240
- "values": "['solution']"
241
  },
242
  {
243
- "keys": "40",
244
- "values": "['reference']"
245
  }
246
  ],
247
  "role": "agent",
@@ -316,15 +319,6 @@ Sample data instance for `doc2dial_rc` :
316
  "is_impossible": false,
317
  "question": "Hello, I want to know about the retirement plan.",
318
  "answers": {
319
- "sp_id": [
320
- [
321
- "1",
322
- "2"
323
- ]
324
- ],
325
- "answer_end": [
326
- 67
327
- ],
328
  "answer_start": [
329
  0
330
  ],
@@ -332,79 +326,7 @@ Sample data instance for `doc2dial_rc` :
332
  "\n\nBenefits Planner: Retirement \n\n\nOnline Calculator (WEP Version) \n"
333
  ]
334
  },
335
- "doc_context": "\n\nBenefits Planner: Retirement \n\n\nOnline Calculator (WEP Version) \nThe calculator shown below allows you to estimate your Social Security benefit. However , for the most accurate estimates , use the Detailed Calculator. You need to enter all your past earnings, which are shown on your online. Please Note: The Online Calculator is updated periodically * with new benefit increases and other benefit amounts. Therefore , it is likely that your benefit estimates in the future will differ from those calculated today. The Online Calculator works on PCs and Macs with Javascript enabled. Some browsers may not allow you to print the table below. Note: If your birthday is on January 1st , we figure your benefit as if your birthday was in the previous year. If you qualify for benefits as a Survivor , your full retirement age for survivors benefits may be different. ",
336
- "dial_context": {
337
- "da": [
338
- "request/query/open"
339
- ],
340
- "references": [
341
- {
342
- "sp_id": [
343
- [
344
- "1"
345
- ]
346
- ],
347
- "answer_end": [
348
- 32
349
- ],
350
- "answer_start": [
351
- 0
352
- ],
353
- "text": [
354
- "\n\nBenefits Planner: Retirement \n"
355
- ]
356
- }
357
- ],
358
- "role": [
359
- "user"
360
- ],
361
- "turn_id": [
362
- 1
363
- ],
364
- "utterance": [
365
- "Hello, I want to know about the retirement plan."
366
- ]
367
- },
368
- "end_candidates": [
369
- 32,
370
- 67,
371
- 147,
372
- 157,
373
- 191,
374
- 220,
375
- 294,
376
- 307,
377
- 409,
378
- 421,
379
- 517,
380
- 586,
381
- 644,
382
- 650,
383
- 687,
384
- 756,
385
- 800,
386
- 866
387
- ],
388
- "start_candidates": [
389
- 0,
390
- 32,
391
- 67,
392
- 147,
393
- 157,
394
- 191,
395
- 220,
396
- 294,
397
- 307,
398
- 409,
399
- 421,
400
- 517,
401
- 586,
402
- 644,
403
- 650,
404
- 687,
405
- 756,
406
- 800
407
- ],
408
  "title": "Benefits Planner: Retirement | Online Calculator (WEP Version)#1_0",
409
  "domain": "ssa"
410
  }
@@ -447,30 +369,21 @@ For `dialogue_domain`:
447
  - `turn_id`: the time order of the turn;
448
  - `role`: either "agent" or "user";
449
  - `da`: dialogue act;
450
- - `reference`: the grounding span (`id_sp`) in the associated document. If a turn is an irrelevant turn, i.e., `da` ends with "ood", `reference` is empty. **Note** that spans with labels "*precondition*"/"*solution*" are the actual grounding spans. Spans with label "*reference*" are the related titles or contextual reference, which is used for the purpose of describing a dialogue scene better to crowd contributors.
451
  - `utterance`: the human-generated utterance based on the dialogue scene.
452
 
453
 
454
 
455
- For `doc2dial_rc`,
456
 
457
  - `id`: the ID of a QA instance;
458
  - `question`: user query;
459
- - `is_impossible`: if the question is answerable;
460
  - `answers`: the answers that are grounded in the associated document;
461
- - `sp_id`: the ID of a document span as the grounding of an answer;
462
- - `answer_start` / `answer_end`: the start / end position of the grounding span in the associated document (`doc_context`);
463
  - `text`: the text content of the grounding span;
464
- - `dial_context`: the dialogue history;
465
- - `turn_id`: the time order of the turn;
466
- - `role`: either "agent" or "user";
467
- - `da`: dialogue act;
468
- - `utterance`: the human-generated utterance based on the dialogue scene.
469
- - `references`: the grounding spans (same as `answers`).
470
  - `title`: the title of the associated document;
471
  - `domain`: the domain of the associated document;
472
- - `doc_context`: the text content of the associated document (without HTML markups);
473
- - `start_candidates` / `end_candidates`: the candidates of the start / end positions of the grounding spans.
474
 
475
 
476
 
@@ -544,3 +457,7 @@ Creative Commons Attribution 3.0 Unported
544
  publisher = "Association for Computational Linguistics",
545
  url = "https://www.aclweb.org/anthology/2020.emnlp-main.652",
546
  }
 
 
 
 
 
43
  - [Dataset Curators](#dataset-curators)
44
  - [Licensing Information](#licensing-information)
45
  - [Citation Information](#citation-information)
46
+ - [Contributions](#contributions)
47
 
48
  ## Dataset Description
49
 
 
59
 
60
  ### Supported Tasks and Leaderboards
61
 
62
+ > Supported Task: [Shared Task](https://doc2dial.github.io/workshop2021/shared.html) hosted by DialDoc21 at ACL.
63
+
64
+ > Leaderboard: [LINK](https://eval.ai/web/challenges/challenge-page/793)
65
 
66
  ### Languages
67
 
 
80
  "domain": "dmv",
81
  "turns": [
82
  {
83
+ "da": "query_condition",
84
+ "references": [
85
  {
86
+ "sp_id": "4",
87
+ "label": "precondition"
88
  }
89
  ],
90
  "role": "user",
 
92
  "utterance": "Hello, I forgot o update my address, can you help me with that?"
93
  },
94
  {
95
+ "da": "response_solution",
96
+ "references": [
97
  {
98
+ "sp_id": "6",
99
+ "label": "solution"
100
  },
101
  {
102
+ "sp_id": "7",
103
+ "label": "solution"
104
  },
105
  {
106
+ "sp_id": "4",
107
+ "label": "references"
108
  }
109
  ],
110
  "role": "agent",
 
112
  "utterance": "hi, you have to report any change of address to DMV within 10 days after moving. You should do this both for the address associated with your license and all the addresses associated with all your vehicles."
113
  },
114
  {
115
+ "da": "query_solution",
116
+ "references": [
117
  {
118
+ "sp_id": "56",
119
+ "label": "solution"
120
  },
121
  {
122
+ "sp_id": "48",
123
+ "label": "references"
124
  }
125
  ],
126
  "role": "user",
 
128
  "utterance": "Can I do my DMV transactions online?"
129
  },
130
  {
131
+ "da": "respond_solution",
132
+ "references": [
133
  {
134
+ "sp_id": "56",
135
+ "label": "solution"
136
  },
137
  {
138
+ "sp_id": "48",
139
+ "label": "references"
140
  }
141
  ],
142
  "role": "agent",
 
144
  "utterance": "Yes, you can sign up for MyDMV for all the online transactions needed."
145
  },
146
  {
147
+ "da": "query_condition",
148
+ "references": [
149
  {
150
+ "sp_id": "48",
151
+ "label": "precondition"
152
  }
153
  ],
154
  "role": "user",
 
156
  "utterance": "Thanks, and in case I forget to bring all of the documentation needed to the DMV office, what can I do?"
157
  },
158
  {
159
+ "da": "respond_solution",
160
+ "references": [
161
  {
162
+ "sp_id": "49",
163
+ "label": "solution"
164
  },
165
  {
166
+ "sp_id": "50",
167
+ "label": "solution"
168
  },
169
  {
170
+ "sp_id": "52",
171
+ "label": "solution"
172
  },
173
  {
174
+ "sp_id": "48",
175
+ "label": "references"
176
  }
177
  ],
178
  "role": "agent",
 
180
  "utterance": "This happens often with our customers so that's why our website and MyDMV are so useful for our customers. Just check if you can make your transaction online so you don't have to go to the DMV Office."
181
  },
182
  {
183
+ "da": "query_solution",
184
+ "references": [
185
  {
186
+ "sp_id": "6",
187
+ "label": "solution"
188
  },
189
  {
190
+ "sp_id": "7",
191
+ "label": "solution"
192
  },
193
  {
194
+ "sp_id": "4",
195
+ "label": "references"
196
  }
197
  ],
198
  "role": "user",
 
200
  "utterance": "Ok, and can you tell me again where should I report my new address?"
201
  },
202
  {
203
+ "da": "respond_solution",
204
+ "references": [
205
  {
206
+ "sp_id": "6",
207
+ "label": "solution"
208
  },
209
  {
210
+ "sp_id": "7",
211
+ "label": "solution"
212
  },
213
  {
214
+ "sp_id": "4",
215
+ "label": "references"
216
  }
217
  ],
218
  "role": "agent",
 
220
  "utterance": "Sure. Any change of address must be reported to the DMV, that's for the address associated with your license and any of your vehicles."
221
  },
222
  {
223
+ "da": "query_condition",
224
+ "references": [
225
  {
226
+ "sp_id": "40",
227
+ "label": "precondition"
228
  }
229
  ],
230
  "role": "user",
 
232
  "utterance": "Can you tell me more about Traffic points and their cost?"
233
  },
234
  {
235
+ "da": "respond_solution",
236
+ "references": [
237
  {
238
+ "sp_id": "41",
239
+ "label": "solution"
240
  },
241
  {
242
+ "sp_id": "43",
243
+ "label": "solution"
244
  },
245
  {
246
+ "sp_id": "40",
247
+ "label": "references"
248
  }
249
  ],
250
  "role": "agent",
 
319
  "is_impossible": false,
320
  "question": "Hello, I want to know about the retirement plan.",
321
  "answers": {
 
 
 
 
 
 
 
 
 
322
  "answer_start": [
323
  0
324
  ],
 
326
  "\n\nBenefits Planner: Retirement \n\n\nOnline Calculator (WEP Version) \n"
327
  ]
328
  },
329
+ "context": "\n\nBenefits Planner: Retirement \n\n\nOnline Calculator (WEP Version) \nThe calculator shown below allows you to estimate your Social Security benefit. However , for the most accurate estimates , use the Detailed Calculator. You need to enter all your past earnings, which are shown on your online. Please Note: The Online Calculator is updated periodically * with new benefit increases and other benefit amounts. Therefore , it is likely that your benefit estimates in the future will differ from those calculated today. The Online Calculator works on PCs and Macs with Javascript enabled. Some browsers may not allow you to print the table below. Note: If your birthday is on January 1st , we figure your benefit as if your birthday was in the previous year. If you qualify for benefits as a Survivor , your full retirement age for survivors benefits may be different. ",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  "title": "Benefits Planner: Retirement | Online Calculator (WEP Version)#1_0",
331
  "domain": "ssa"
332
  }
 
369
  - `turn_id`: the time order of the turn;
370
  - `role`: either "agent" or "user";
371
  - `da`: dialogue act;
372
+ - `references`: the grounding span (`id_sp`) in the associated document. If a turn is an irrelevant turn, i.e., `da` ends with "ood", `reference` is empty. **Note** that spans with labels "*precondition*"/"*solution*" are the actual grounding spans. Spans with label "*reference*" are the related titles or contextual reference, which is used for the purpose of describing a dialogue scene better to crowd contributors.
373
  - `utterance`: the human-generated utterance based on the dialogue scene.
374
 
375
 
376
 
377
+ For `doc2dial_rc`, this conforms to [SQuAD](https://rajpurkar.github.io/SQuAD-explorer/) data format. For how to load Doc2Dial data for reading comprehension task, please refer [here](https://github.com/doc2dial/sharedtask-dialdoc2021).
378
 
379
  - `id`: the ID of a QA instance;
380
  - `question`: user query;
 
381
  - `answers`: the answers that are grounded in the associated document;
382
+ - `answer_start`: the start position of the grounding span in the associated document (`context`);
 
383
  - `text`: the text content of the grounding span;
 
 
 
 
 
 
384
  - `title`: the title of the associated document;
385
  - `domain`: the domain of the associated document;
386
+ - `context`: the text content of the associated document (without HTML markups).
 
387
 
388
 
389
 
 
457
  publisher = "Association for Computational Linguistics",
458
  url = "https://www.aclweb.org/anthology/2020.emnlp-main.652",
459
  }
460
+
461
+ ### Contributions
462
+
463
+ Thanks to [@songfeng](https://github.com/songfeng), [@KMFODA](https://github.com/KMFODA) for adding this dataset.
doc2dial.py CHANGED
@@ -14,7 +14,7 @@
14
  # limitations under the License.
15
 
16
  # Lint as: python3
17
- """Doc2dial: A Goal-Oriented Document-Grounded Dialogue Dataset v0.9.0"""
18
 
19
  from __future__ import absolute_import, division, print_function
20
 
@@ -44,22 +44,17 @@ in over 450 documents from four domains. Compared to the prior document-grounded
44
  this dataset covers a variety of dialogue scenes in information-seeking conversations.
45
  """
46
 
47
- _HOMEPAGE = "https://doc2dial.github.io/file/doc2dial/"
48
 
49
- # TODO: Add the licence for the dataset here if you can find it
50
- _LICENSE = ""
51
 
52
- _URLs = "https://doc2dial.github.io/file/doc2dial.zip"
53
 
54
 
55
  class Doc2dial(datasets.GeneratorBasedBuilder):
56
- "Doc2dial: A Goal-Oriented Document-Grounded Dialogue Dataset v0.9"
57
 
58
- VERSION = datasets.Version("1.1.0")
59
 
60
- # You will be able to load one or the other configurations in the following list with
61
- # data = datasets.load_dataset("my_dataset", "first_domain")
62
- # data = datasets.load_dataset("my_dataset", "second_domain")
63
  BUILDER_CONFIGS = [
64
  datasets.BuilderConfig(
65
  name="dialogue_domain",
@@ -93,10 +88,10 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
93
  "turn_id": datasets.Value("int32"),
94
  "role": datasets.Value("string"),
95
  "da": datasets.Value("string"),
96
- "reference": [
97
  {
98
- "keys": datasets.Value("string"),
99
- "values": datasets.Value("string"),
100
  }
101
  ],
102
  "utterance": datasets.Value("string"),
@@ -134,37 +129,16 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
134
  features = datasets.Features(
135
  {
136
  "id": datasets.Value("string"),
 
 
137
  "question": datasets.Value("string"),
138
  "answers": datasets.features.Sequence(
139
  {
140
  "text": datasets.Value("string"),
141
  "answer_start": datasets.Value("int32"),
142
- "answer_end": datasets.Value("int32"),
143
- "sp_id": datasets.features.Sequence(datasets.Value("string")),
144
- }
145
- ),
146
- "is_impossible": datasets.Value("bool"),
147
- "dial_context": datasets.features.Sequence(
148
- {
149
- "turn_id": datasets.Value("int32"),
150
- "role": datasets.Value("string"),
151
- "da": datasets.Value("string"),
152
- "utterance": datasets.Value("string"),
153
- "references": datasets.features.Sequence(
154
- {
155
- "text": datasets.Value("string"),
156
- "answer_start": datasets.Value("int32"),
157
- "answer_end": datasets.Value("int32"),
158
- "sp_id": datasets.features.Sequence(datasets.Value("string")),
159
- }
160
- ),
161
  }
162
  ),
163
- "doc_context": datasets.Value("string"),
164
- "title": datasets.Value("string"),
165
  "domain": datasets.Value("string"),
166
- "start_candidates": datasets.features.Sequence(datasets.Value("int32")),
167
- "end_candidates": datasets.features.Sequence(datasets.Value("int32")),
168
  }
169
  )
170
 
@@ -179,6 +153,7 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
179
  def _split_generators(self, dl_manager):
180
 
181
  my_urls = _URLs
 
182
  data_dir = dl_manager.download_and_extract(my_urls)
183
 
184
  if self.config.name == "dialogue_domain":
@@ -186,13 +161,13 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
186
  datasets.SplitGenerator(
187
  name=datasets.Split.TRAIN,
188
  gen_kwargs={
189
- "filepath": os.path.join(data_dir, "doc2dial/v0.9/data/woOOD/doc2dial_dial_train.json"),
190
  },
191
  ),
192
  datasets.SplitGenerator(
193
  name=datasets.Split.VALIDATION,
194
  gen_kwargs={
195
- "filepath": os.path.join(data_dir, "doc2dial/v0.9/data/woOOD/doc2dial_dial_dev.json"),
196
  },
197
  ),
198
  ]
@@ -201,7 +176,7 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
201
  datasets.SplitGenerator(
202
  name=datasets.Split.TRAIN,
203
  gen_kwargs={
204
- "filepath": os.path.join(data_dir, "doc2dial/v0.9/data/doc2dial_doc.json"),
205
  },
206
  )
207
  ]
@@ -210,69 +185,45 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
210
  datasets.SplitGenerator(
211
  name=datasets.Split.VALIDATION,
212
  gen_kwargs={
213
- "filepath": os.path.join(
214
- data_dir, "doc2dial", "v0.9", "data", "woOOD", "doc2dial_dial_dev.json"
215
- ),
216
  },
217
  ),
218
  datasets.SplitGenerator(
219
  name=datasets.Split.TRAIN,
220
  gen_kwargs={
221
- "filepath": os.path.join(
222
- data_dir,
223
- "doc2dial",
224
- "v0.9",
225
- "data",
226
- "woOOD",
227
- "doc2dial_dial_train.json",
228
- ),
229
  },
230
  ),
231
  ]
232
 
233
  def _load_doc_data_rc(self, filepath):
234
- doc_filepath = os.path.join(os.path.dirname(filepath), "..", "doc2dial_doc.json")
235
  with open(doc_filepath, encoding="utf-8") as f:
236
  data = json.load(f)["doc_data"]
237
  return data
238
 
239
- def _get_start_end_candidates_rc(self, spans):
240
- """Get the start and end positions of all the spans"""
241
- start_candidates, end_candidates = [], []
242
- for _, sp in spans.items():
243
- start_candidates.append(sp["start_sp"])
244
- end_candidates.append(sp["end_sp"])
245
- return start_candidates, end_candidates
246
-
247
- def _create_answers_merging_text_ref_rc(self, refs, spans, doc_text):
248
- """Combine the consecutive spans. Create answers with the start and end position of merged spans and corresponding text content in the document."""
249
- output = []
250
- if not refs:
251
- return output
252
- all_consecutive_spans = []
253
- consecutive_spans = []
254
- for id_, _ in sorted(refs.items(), key=lambda x: int(x[0])):
255
- if not consecutive_spans or int(id_) == int(consecutive_spans[-1]) + 1:
256
- consecutive_spans.append(id_)
257
- else:
258
- all_consecutive_spans.append(consecutive_spans)
259
- consecutive_spans = [id_]
260
- all_consecutive_spans.append(consecutive_spans)
261
- if len(all_consecutive_spans) > 1:
262
- all_consecutive_spans.reverse()
263
- for con_spans in all_consecutive_spans:
264
- answer = {
265
- "answer_start": spans[con_spans[0]]["start_sp"],
266
- "answer_end": spans[con_spans[-1]]["end_sp"],
267
- "text": doc_text[spans[con_spans[0]]["start_sp"] : spans[con_spans[-1]]["end_sp"]],
268
- "sp_id": con_spans,
269
- }
270
- output.append(answer)
271
- return output
272
 
273
  def _generate_examples(self, filepath):
274
  """This function returns the examples in the raw (text) form."""
275
-
276
  if self.config.name == "dialogue_domain":
277
  logging.info("generating examples from = %s", filepath)
278
  with open(filepath, encoding="utf-8") as f:
@@ -285,22 +236,7 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
285
  "dial_id": dialogue["dial_id"],
286
  "domain": domain,
287
  "doc_id": doc_id,
288
- "turns": [
289
- {
290
- "turn_id": i["turn_id"],
291
- "role": i["role"],
292
- "da": i["da"],
293
- "reference": [
294
- {
295
- "keys": ref,
296
- "values": str(i["reference"][ref]),
297
- }
298
- for ref in i["reference"]
299
- ],
300
- "utterance": i["utterance"],
301
- }
302
- for i in dialogue["turns"]
303
- ],
304
  }
305
 
306
  yield dialogue["dial_id"], x
@@ -340,33 +276,22 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
340
  "doc_html_ts": data["doc_data"][domain][doc_id]["doc_html_ts"],
341
  "doc_html_raw": data["doc_data"][domain][doc_id]["doc_html_raw"],
342
  }
 
343
  elif self.config.name == "doc2dial_rc":
344
  """Load dialog data in the reading comprehension task setup, where context is the grounding document,
345
  input query is dialog history in reversed order, and output to predict is the next agent turn."""
346
 
347
  logging.info("generating examples from = %s", filepath)
348
-
349
  doc_data = self._load_doc_data_rc(filepath)
350
  with open(filepath, encoding="utf-8") as f:
351
  dial_data = json.load(f)["dial_data"]
352
  for domain, d_doc_dials in dial_data.items():
353
  for doc_id, dials in d_doc_dials.items():
354
  doc = doc_data[domain][doc_id]
355
- (
356
- start_pos_char_candidates,
357
- end_pos_char_candidates,
358
- ) = self._get_start_end_candidates_rc(doc["spans"])
359
  for dial in dials:
360
  all_prev_utterances = []
361
- all_prev_turns = []
362
  for idx, turn in enumerate(dial["turns"]):
363
- all_prev_utterances.append(turn["utterance"])
364
- if "references" not in turn:
365
- turn["references"] = self._create_answers_merging_text_ref_rc(
366
- turn["reference"], doc["spans"], doc["doc_text"]
367
- )
368
- turn.pop("reference", None)
369
- all_prev_turns.append(turn)
370
  if turn["role"] == "agent":
371
  continue
372
  if idx + 1 < len(dial["turns"]):
@@ -374,29 +299,18 @@ class Doc2dial(datasets.GeneratorBasedBuilder):
374
  turn_to_predict = dial["turns"][idx + 1]
375
  else:
376
  continue
377
- question = " ".join(list(reversed(all_prev_utterances)))
378
- id_ = dial["dial_id"] + "_" + str(turn["turn_id"])
379
  qa = {
380
  "id": id_,
381
- "question": question,
382
- "answers": [],
383
- "dial_context": all_prev_turns,
384
- "doc_context": doc["doc_text"],
385
  "title": doc_id,
 
 
 
 
 
 
 
386
  "domain": domain,
387
- "start_candidates": start_pos_char_candidates,
388
- "end_candidates": end_pos_char_candidates,
389
  }
390
- if "references" not in turn_to_predict:
391
- turn_to_predict["references"] = self._create_answers_merging_text_ref_rc(
392
- turn_to_predict["reference"], doc["spans"], doc["doc_text"]
393
- )
394
- if not turn_to_predict["references"]:
395
- qa["is_impossible"] = True
396
- else:
397
- qa["is_impossible"] = False
398
- qa["answers"] = turn_to_predict["references"]
399
- assert (
400
- len((qa["answers"])) >= 1
401
- ), "Ensure the answers are not empty if the question is answerable"
402
  yield id_, qa
 
14
  # limitations under the License.
15
 
16
  # Lint as: python3
17
+ """Doc2dial: A Goal-Oriented Document-Grounded Dialogue Dataset v1.0.1"""
18
 
19
  from __future__ import absolute_import, division, print_function
20
 
 
44
  this dataset covers a variety of dialogue scenes in information-seeking conversations.
45
  """
46
 
47
+ _HOMEPAGE = "https://doc2dial.github.io"
48
 
 
 
49
 
50
+ _URLs = "https://doc2dial.github.io/file/doc2dial_v1.0.1.zip"
51
 
52
 
53
  class Doc2dial(datasets.GeneratorBasedBuilder):
54
+ "Doc2dial: A Goal-Oriented Document-Grounded Dialogue Dataset v1.0.1"
55
 
56
+ VERSION = datasets.Version("1.0.1")
57
 
 
 
 
58
  BUILDER_CONFIGS = [
59
  datasets.BuilderConfig(
60
  name="dialogue_domain",
 
88
  "turn_id": datasets.Value("int32"),
89
  "role": datasets.Value("string"),
90
  "da": datasets.Value("string"),
91
+ "references": [
92
  {
93
+ "sp_id": datasets.Value("string"),
94
+ "label": datasets.Value("string"),
95
  }
96
  ],
97
  "utterance": datasets.Value("string"),
 
129
  features = datasets.Features(
130
  {
131
  "id": datasets.Value("string"),
132
+ "title": datasets.Value("string"),
133
+ "context": datasets.Value("string"),
134
  "question": datasets.Value("string"),
135
  "answers": datasets.features.Sequence(
136
  {
137
  "text": datasets.Value("string"),
138
  "answer_start": datasets.Value("int32"),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
  ),
 
 
141
  "domain": datasets.Value("string"),
 
 
142
  }
143
  )
144
 
 
153
  def _split_generators(self, dl_manager):
154
 
155
  my_urls = _URLs
156
+
157
  data_dir = dl_manager.download_and_extract(my_urls)
158
 
159
  if self.config.name == "dialogue_domain":
 
161
  datasets.SplitGenerator(
162
  name=datasets.Split.TRAIN,
163
  gen_kwargs={
164
+ "filepath": os.path.join(data_dir, "doc2dial/v1.0.1/doc2dial_dial_train.json"),
165
  },
166
  ),
167
  datasets.SplitGenerator(
168
  name=datasets.Split.VALIDATION,
169
  gen_kwargs={
170
+ "filepath": os.path.join(data_dir, "doc2dial/v1.0.1/doc2dial_dial_validation.json"),
171
  },
172
  ),
173
  ]
 
176
  datasets.SplitGenerator(
177
  name=datasets.Split.TRAIN,
178
  gen_kwargs={
179
+ "filepath": os.path.join(data_dir, "doc2dial/v1.0.1/doc2dial_doc.json"),
180
  },
181
  )
182
  ]
 
185
  datasets.SplitGenerator(
186
  name=datasets.Split.VALIDATION,
187
  gen_kwargs={
188
+ "filepath": os.path.join(data_dir, "doc2dial/v1.0.1/doc2dial_dial_validation.json"),
 
 
189
  },
190
  ),
191
  datasets.SplitGenerator(
192
  name=datasets.Split.TRAIN,
193
  gen_kwargs={
194
+ "filepath": os.path.join(data_dir, "doc2dial/v1.0.1/doc2dial_dial_train.json"),
 
 
 
 
 
 
 
195
  },
196
  ),
197
  ]
198
 
199
  def _load_doc_data_rc(self, filepath):
200
+ doc_filepath = os.path.join(os.path.dirname(filepath), "doc2dial_doc.json")
201
  with open(doc_filepath, encoding="utf-8") as f:
202
  data = json.load(f)["doc_data"]
203
  return data
204
 
205
+ def _get_answers_rc(self, references, spans, doc_text):
206
+ """Obtain the grounding annotation for a given dialogue turn"""
207
+ if not references:
208
+ return []
209
+ start, end = -1, -1
210
+ ls_sp = []
211
+ for ele in references:
212
+ sp_id = ele["sp_id"]
213
+ start_sp, end_sp = spans[sp_id]["start_sp"], spans[sp_id]["end_sp"]
214
+ if start == -1 or start > start_sp:
215
+ start = start_sp
216
+ if end < end_sp:
217
+ end = end_sp
218
+ ls_sp.append(doc_text[start_sp:end_sp])
219
+ answer = {
220
+ "text": doc_text[start:end],
221
+ "answer_start": start,
222
+ }
223
+ return [answer]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
  def _generate_examples(self, filepath):
226
  """This function returns the examples in the raw (text) form."""
 
227
  if self.config.name == "dialogue_domain":
228
  logging.info("generating examples from = %s", filepath)
229
  with open(filepath, encoding="utf-8") as f:
 
236
  "dial_id": dialogue["dial_id"],
237
  "domain": domain,
238
  "doc_id": doc_id,
239
+ "turns": dialogue["turns"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  }
241
 
242
  yield dialogue["dial_id"], x
 
276
  "doc_html_ts": data["doc_data"][domain][doc_id]["doc_html_ts"],
277
  "doc_html_raw": data["doc_data"][domain][doc_id]["doc_html_raw"],
278
  }
279
+
280
  elif self.config.name == "doc2dial_rc":
281
  """Load dialog data in the reading comprehension task setup, where context is the grounding document,
282
  input query is dialog history in reversed order, and output to predict is the next agent turn."""
283
 
284
  logging.info("generating examples from = %s", filepath)
 
285
  doc_data = self._load_doc_data_rc(filepath)
286
  with open(filepath, encoding="utf-8") as f:
287
  dial_data = json.load(f)["dial_data"]
288
  for domain, d_doc_dials in dial_data.items():
289
  for doc_id, dials in d_doc_dials.items():
290
  doc = doc_data[domain][doc_id]
 
 
 
 
291
  for dial in dials:
292
  all_prev_utterances = []
 
293
  for idx, turn in enumerate(dial["turns"]):
294
+ all_prev_utterances.append("\t{}: {}".format(turn["role"], turn["utterance"]))
 
 
 
 
 
 
295
  if turn["role"] == "agent":
296
  continue
297
  if idx + 1 < len(dial["turns"]):
 
299
  turn_to_predict = dial["turns"][idx + 1]
300
  else:
301
  continue
302
+ question = " ".join(list(reversed(all_prev_utterances))).strip()
303
+ id_ = "{}_{}".format(dial["dial_id"], turn["turn_id"])
304
  qa = {
305
  "id": id_,
 
 
 
 
306
  "title": doc_id,
307
+ "context": doc["doc_text"],
308
+ "question": question,
309
+ "answers": self._get_answers_rc(
310
+ turn_to_predict["references"],
311
+ doc["spans"],
312
+ doc["doc_text"],
313
+ ),
314
  "domain": domain,
 
 
315
  }
 
 
 
 
 
 
 
 
 
 
 
 
316
  yield id_, qa
dummy/dialogue_domain/{1.1.0 → 1.0.1}/dummy_data.zip RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b9798815890f170ef0e8340411786b62871a937fb86e1e4c93ecee8bb352f7de
3
- size 12543
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:740c1207d38bd096d900299bb44139a2b858d30ae79154c3d772c0b4a6b4ce05
3
+ size 13462
dummy/{document_domain/1.1.0 → doc2dial_rc/1.0.1}/dummy_data.zip RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d00be8fde52bcbc7b75db842b89255ed382943f45c382353a7f279f537b4e4ef
3
- size 15435
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:740c1207d38bd096d900299bb44139a2b858d30ae79154c3d772c0b4a6b4ce05
3
+ size 13462
dummy/document_domain/1.0.1/dummy_data.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:740c1207d38bd096d900299bb44139a2b858d30ae79154c3d772c0b4a6b4ce05
3
+ size 13462