Tests passed using correct CLI command
Browse files- dataset_infos.json +0 -0
- dialog_babi.py +376 -10
dataset_infos.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
dialog_babi.py
CHANGED
@@ -40,12 +40,338 @@ For each task, there are 1000 dialogs for training, 1000 for development and 100
|
|
40 |
|
41 |
_HOMEPAGE = "https://research.facebook.com/downloads/babi/"
|
42 |
|
43 |
-
_LICENSE = "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
DIALOG_BABI_ARCHIVE_URL = "https://www.dropbox.com/s/20rgyj8rryvos9l/dialog-bAbI-tasks-1_6.zip?dl=1"
|
46 |
|
47 |
|
48 |
-
class
|
49 |
"""Facebook's dataset 'dialog-babi' for end-to-end dialogue learning."""
|
50 |
|
51 |
VERSION = datasets.Version("1.0.0")
|
@@ -60,13 +386,15 @@ class DialogBabiDataset(datasets.GeneratorBasedBuilder):
|
|
60 |
]
|
61 |
|
62 |
DEFAULT_CONFIG_NAME = "task1-API-calls"
|
|
|
63 |
|
64 |
def _info(self):
|
65 |
-
if self.config.name
|
66 |
features = datasets.Features(
|
67 |
{
|
68 |
"user_turns": datasets.Sequence(datasets.Value("string")),
|
69 |
-
"system_turns": datasets.Sequence(datasets.Value("string"))
|
|
|
70 |
}
|
71 |
)
|
72 |
else:
|
@@ -88,6 +416,34 @@ class DialogBabiDataset(datasets.GeneratorBasedBuilder):
|
|
88 |
data_dir = dl_manager.download_and_extract(DIALOG_BABI_ARCHIVE_URL)
|
89 |
task_data_dir = os.path.join(data_dir, "dialog-bAbI-tasks-1_6", self.config.name)
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
return [
|
92 |
datasets.SplitGenerator(
|
93 |
name=datasets.Split.TRAIN,
|
@@ -143,17 +499,27 @@ class DialogBabiDataset(datasets.GeneratorBasedBuilder):
|
|
143 |
|
144 |
user_turns = []
|
145 |
system_turns = []
|
|
|
146 |
|
147 |
-
for turn in dialogue_rows:
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
152 |
|
153 |
|
154 |
example_key = f"{split}-{dialogue_id}"
|
155 |
-
|
|
|
156 |
"user_turns": user_turns,
|
157 |
"system_turns": system_turns
|
158 |
}
|
|
|
|
|
|
|
|
|
|
|
159 |
|
|
|
40 |
|
41 |
_HOMEPAGE = "https://research.facebook.com/downloads/babi/"
|
42 |
|
43 |
+
_LICENSE = """
|
44 |
+
CC License
|
45 |
+
|
46 |
+
Dialog bAbI tasks data
|
47 |
+
|
48 |
+
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
|
49 |
+
|
50 |
+
Creative Commons Legal Code
|
51 |
+
|
52 |
+
Attribution 3.0 Unported
|
53 |
+
|
54 |
+
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
55 |
+
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
56 |
+
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
57 |
+
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
58 |
+
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
59 |
+
DAMAGES RESULTING FROM ITS USE.
|
60 |
+
|
61 |
+
License
|
62 |
+
|
63 |
+
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
64 |
+
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
65 |
+
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
66 |
+
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
67 |
+
|
68 |
+
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
69 |
+
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
70 |
+
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
71 |
+
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
72 |
+
CONDITIONS.
|
73 |
+
|
74 |
+
1. Definitions
|
75 |
+
|
76 |
+
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
77 |
+
other pre-existing works, such as a translation, adaptation,
|
78 |
+
derivative work, arrangement of music or other alterations of a
|
79 |
+
literary or artistic work, or phonogram or performance and includes
|
80 |
+
cinematographic adaptations or any other form in which the Work may be
|
81 |
+
recast, transformed, or adapted including in any form recognizably
|
82 |
+
derived from the original, except that a work that constitutes a
|
83 |
+
Collection will not be considered an Adaptation for the purpose of
|
84 |
+
this License. For the avoidance of doubt, where the Work is a musical
|
85 |
+
work, performance or phonogram, the synchronization of the Work in
|
86 |
+
timed-relation with a moving image ("synching") will be considered an
|
87 |
+
Adaptation for the purpose of this License.
|
88 |
+
b. "Collection" means a collection of literary or artistic works, such as
|
89 |
+
encyclopedias and anthologies, or performances, phonograms or
|
90 |
+
broadcasts, or other works or subject matter other than works listed
|
91 |
+
in Section 1(f) below, which, by reason of the selection and
|
92 |
+
arrangement of their contents, constitute intellectual creations, in
|
93 |
+
which the Work is included in its entirety in unmodified form along
|
94 |
+
with one or more other contributions, each constituting separate and
|
95 |
+
independent works in themselves, which together are assembled into a
|
96 |
+
collective whole. A work that constitutes a Collection will not be
|
97 |
+
considered an Adaptation (as defined above) for the purposes of this
|
98 |
+
License.
|
99 |
+
c. "Distribute" means to make available to the public the original and
|
100 |
+
copies of the Work or Adaptation, as appropriate, through sale or
|
101 |
+
other transfer of ownership.
|
102 |
+
d. "Licensor" means the individual, individuals, entity or entities that
|
103 |
+
offer(s) the Work under the terms of this License.
|
104 |
+
e. "Original Author" means, in the case of a literary or artistic work,
|
105 |
+
the individual, individuals, entity or entities who created the Work
|
106 |
+
or if no individual or entity can be identified, the publisher; and in
|
107 |
+
addition (i) in the case of a performance the actors, singers,
|
108 |
+
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
109 |
+
play in, interpret or otherwise perform literary or artistic works or
|
110 |
+
expressions of folklore; (ii) in the case of a phonogram the producer
|
111 |
+
being the person or legal entity who first fixes the sounds of a
|
112 |
+
performance or other sounds; and, (iii) in the case of broadcasts, the
|
113 |
+
organization that transmits the broadcast.
|
114 |
+
f. "Work" means the literary and/or artistic work offered under the terms
|
115 |
+
of this License including without limitation any production in the
|
116 |
+
literary, scientific and artistic domain, whatever may be the mode or
|
117 |
+
form of its expression including digital form, such as a book,
|
118 |
+
pamphlet and other writing; a lecture, address, sermon or other work
|
119 |
+
of the same nature; a dramatic or dramatico-musical work; a
|
120 |
+
choreographic work or entertainment in dumb show; a musical
|
121 |
+
composition with or without words; a cinematographic work to which are
|
122 |
+
assimilated works expressed by a process analogous to cinematography;
|
123 |
+
a work of drawing, painting, architecture, sculpture, engraving or
|
124 |
+
lithography; a photographic work to which are assimilated works
|
125 |
+
expressed by a process analogous to photography; a work of applied
|
126 |
+
art; an illustration, map, plan, sketch or three-dimensional work
|
127 |
+
relative to geography, topography, architecture or science; a
|
128 |
+
performance; a broadcast; a phonogram; a compilation of data to the
|
129 |
+
extent it is protected as a copyrightable work; or a work performed by
|
130 |
+
a variety or circus performer to the extent it is not otherwise
|
131 |
+
considered a literary or artistic work.
|
132 |
+
g. "You" means an individual or entity exercising rights under this
|
133 |
+
License who has not previously violated the terms of this License with
|
134 |
+
respect to the Work, or who has received express permission from the
|
135 |
+
Licensor to exercise rights under this License despite a previous
|
136 |
+
violation.
|
137 |
+
h. "Publicly Perform" means to perform public recitations of the Work and
|
138 |
+
to communicate to the public those public recitations, by any means or
|
139 |
+
process, including by wire or wireless means or public digital
|
140 |
+
performances; to make available to the public Works in such a way that
|
141 |
+
members of the public may access these Works from a place and at a
|
142 |
+
place individually chosen by them; to perform the Work to the public
|
143 |
+
by any means or process and the communication to the public of the
|
144 |
+
performances of the Work, including by public digital performance; to
|
145 |
+
broadcast and rebroadcast the Work by any means including signs,
|
146 |
+
sounds or images.
|
147 |
+
i. "Reproduce" means to make copies of the Work by any means including
|
148 |
+
without limitation by sound or visual recordings and the right of
|
149 |
+
fixation and reproducing fixations of the Work, including storage of a
|
150 |
+
protected performance or phonogram in digital form or other electronic
|
151 |
+
medium.
|
152 |
+
|
153 |
+
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
154 |
+
limit, or restrict any uses free from copyright or rights arising from
|
155 |
+
limitations or exceptions that are provided for in connection with the
|
156 |
+
copyright protection under copyright law or other applicable laws.
|
157 |
+
|
158 |
+
3. License Grant. Subject to the terms and conditions of this License,
|
159 |
+
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
160 |
+
perpetual (for the duration of the applicable copyright) license to
|
161 |
+
exercise the rights in the Work as stated below:
|
162 |
+
|
163 |
+
a. to Reproduce the Work, to incorporate the Work into one or more
|
164 |
+
Collections, and to Reproduce the Work as incorporated in the
|
165 |
+
Collections;
|
166 |
+
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
167 |
+
including any translation in any medium, takes reasonable steps to
|
168 |
+
clearly label, demarcate or otherwise identify that changes were made
|
169 |
+
to the original Work. For example, a translation could be marked "The
|
170 |
+
original work was translated from English to Spanish," or a
|
171 |
+
modification could indicate "The original work has been modified.";
|
172 |
+
c. to Distribute and Publicly Perform the Work including as incorporated
|
173 |
+
in Collections; and,
|
174 |
+
d. to Distribute and Publicly Perform Adaptations.
|
175 |
+
e. For the avoidance of doubt:
|
176 |
+
|
177 |
+
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
178 |
+
which the right to collect royalties through any statutory or
|
179 |
+
compulsory licensing scheme cannot be waived, the Licensor
|
180 |
+
reserves the exclusive right to collect such royalties for any
|
181 |
+
exercise by You of the rights granted under this License;
|
182 |
+
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
183 |
+
which the right to collect royalties through any statutory or
|
184 |
+
compulsory licensing scheme can be waived, the Licensor waives the
|
185 |
+
exclusive right to collect such royalties for any exercise by You
|
186 |
+
of the rights granted under this License; and,
|
187 |
+
iii. Voluntary License Schemes. The Licensor waives the right to
|
188 |
+
collect royalties, whether individually or, in the event that the
|
189 |
+
Licensor is a member of a collecting society that administers
|
190 |
+
voluntary licensing schemes, via that society, from any exercise
|
191 |
+
by You of the rights granted under this License.
|
192 |
+
|
193 |
+
The above rights may be exercised in all media and formats whether now
|
194 |
+
known or hereafter devised. The above rights include the right to make
|
195 |
+
such modifications as are technically necessary to exercise the rights in
|
196 |
+
other media and formats. Subject to Section 8(f), all rights not expressly
|
197 |
+
granted by Licensor are hereby reserved.
|
198 |
+
|
199 |
+
4. Restrictions. The license granted in Section 3 above is expressly made
|
200 |
+
subject to and limited by the following restrictions:
|
201 |
+
|
202 |
+
a. You may Distribute or Publicly Perform the Work only under the terms
|
203 |
+
of this License. You must include a copy of, or the Uniform Resource
|
204 |
+
Identifier (URI) for, this License with every copy of the Work You
|
205 |
+
Distribute or Publicly Perform. You may not offer or impose any terms
|
206 |
+
on the Work that restrict the terms of this License or the ability of
|
207 |
+
the recipient of the Work to exercise the rights granted to that
|
208 |
+
recipient under the terms of the License. You may not sublicense the
|
209 |
+
Work. You must keep intact all notices that refer to this License and
|
210 |
+
to the disclaimer of warranties with every copy of the Work You
|
211 |
+
Distribute or Publicly Perform. When You Distribute or Publicly
|
212 |
+
Perform the Work, You may not impose any effective technological
|
213 |
+
measures on the Work that restrict the ability of a recipient of the
|
214 |
+
Work from You to exercise the rights granted to that recipient under
|
215 |
+
the terms of the License. This Section 4(a) applies to the Work as
|
216 |
+
incorporated in a Collection, but this does not require the Collection
|
217 |
+
apart from the Work itself to be made subject to the terms of this
|
218 |
+
License. If You create a Collection, upon notice from any Licensor You
|
219 |
+
must, to the extent practicable, remove from the Collection any credit
|
220 |
+
as required by Section 4(b), as requested. If You create an
|
221 |
+
Adaptation, upon notice from any Licensor You must, to the extent
|
222 |
+
practicable, remove from the Adaptation any credit as required by
|
223 |
+
Section 4(b), as requested.
|
224 |
+
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
225 |
+
Collections, You must, unless a request has been made pursuant to
|
226 |
+
Section 4(a), keep intact all copyright notices for the Work and
|
227 |
+
provide, reasonable to the medium or means You are utilizing: (i) the
|
228 |
+
name of the Original Author (or pseudonym, if applicable) if supplied,
|
229 |
+
and/or if the Original Author and/or Licensor designate another party
|
230 |
+
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
231 |
+
attribution ("Attribution Parties") in Licensor's copyright notice,
|
232 |
+
terms of service or by other reasonable means, the name of such party
|
233 |
+
or parties; (ii) the title of the Work if supplied; (iii) to the
|
234 |
+
extent reasonably practicable, the URI, if any, that Licensor
|
235 |
+
specifies to be associated with the Work, unless such URI does not
|
236 |
+
refer to the copyright notice or licensing information for the Work;
|
237 |
+
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
|
238 |
+
a credit identifying the use of the Work in the Adaptation (e.g.,
|
239 |
+
"French translation of the Work by Original Author," or "Screenplay
|
240 |
+
based on original Work by Original Author"). The credit required by
|
241 |
+
this Section 4 (b) may be implemented in any reasonable manner;
|
242 |
+
provided, however, that in the case of a Adaptation or Collection, at
|
243 |
+
a minimum such credit will appear, if a credit for all contributing
|
244 |
+
authors of the Adaptation or Collection appears, then as part of these
|
245 |
+
credits and in a manner at least as prominent as the credits for the
|
246 |
+
other contributing authors. For the avoidance of doubt, You may only
|
247 |
+
use the credit required by this Section for the purpose of attribution
|
248 |
+
in the manner set out above and, by exercising Your rights under this
|
249 |
+
License, You may not implicitly or explicitly assert or imply any
|
250 |
+
connection with, sponsorship or endorsement by the Original Author,
|
251 |
+
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
252 |
+
use of the Work, without the separate, express prior written
|
253 |
+
permission of the Original Author, Licensor and/or Attribution
|
254 |
+
Parties.
|
255 |
+
c. Except as otherwise agreed in writing by the Licensor or as may be
|
256 |
+
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
257 |
+
Publicly Perform the Work either by itself or as part of any
|
258 |
+
Adaptations or Collections, You must not distort, mutilate, modify or
|
259 |
+
take other derogatory action in relation to the Work which would be
|
260 |
+
prejudicial to the Original Author's honor or reputation. Licensor
|
261 |
+
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
262 |
+
of the right granted in Section 3(b) of this License (the right to
|
263 |
+
make Adaptations) would be deemed to be a distortion, mutilation,
|
264 |
+
modification or other derogatory action prejudicial to the Original
|
265 |
+
Author's honor and reputation, the Licensor will waive or not assert,
|
266 |
+
as appropriate, this Section, to the fullest extent permitted by the
|
267 |
+
applicable national law, to enable You to reasonably exercise Your
|
268 |
+
right under Section 3(b) of this License (right to make Adaptations)
|
269 |
+
but not otherwise.
|
270 |
+
|
271 |
+
5. Representations, Warranties and Disclaimer
|
272 |
+
|
273 |
+
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
274 |
+
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
275 |
+
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
276 |
+
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
277 |
+
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
278 |
+
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
279 |
+
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
280 |
+
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
281 |
+
|
282 |
+
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
283 |
+
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
284 |
+
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
285 |
+
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
286 |
+
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
287 |
+
|
288 |
+
7. Termination
|
289 |
+
|
290 |
+
a. This License and the rights granted hereunder will terminate
|
291 |
+
automatically upon any breach by You of the terms of this License.
|
292 |
+
Individuals or entities who have received Adaptations or Collections
|
293 |
+
from You under this License, however, will not have their licenses
|
294 |
+
terminated provided such individuals or entities remain in full
|
295 |
+
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
296 |
+
survive any termination of this License.
|
297 |
+
b. Subject to the above terms and conditions, the license granted here is
|
298 |
+
perpetual (for the duration of the applicable copyright in the Work).
|
299 |
+
Notwithstanding the above, Licensor reserves the right to release the
|
300 |
+
Work under different license terms or to stop distributing the Work at
|
301 |
+
any time; provided, however that any such election will not serve to
|
302 |
+
withdraw this License (or any other license that has been, or is
|
303 |
+
required to be, granted under the terms of this License), and this
|
304 |
+
License will continue in full force and effect unless terminated as
|
305 |
+
stated above.
|
306 |
+
|
307 |
+
8. Miscellaneous
|
308 |
+
|
309 |
+
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
310 |
+
the Licensor offers to the recipient a license to the Work on the same
|
311 |
+
terms and conditions as the license granted to You under this License.
|
312 |
+
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
313 |
+
offers to the recipient a license to the original Work on the same
|
314 |
+
terms and conditions as the license granted to You under this License.
|
315 |
+
c. If any provision of this License is invalid or unenforceable under
|
316 |
+
applicable law, it shall not affect the validity or enforceability of
|
317 |
+
the remainder of the terms of this License, and without further action
|
318 |
+
by the parties to this agreement, such provision shall be reformed to
|
319 |
+
the minimum extent necessary to make such provision valid and
|
320 |
+
enforceable.
|
321 |
+
d. No term or provision of this License shall be deemed waived and no
|
322 |
+
breach consented to unless such waiver or consent shall be in writing
|
323 |
+
and signed by the party to be charged with such waiver or consent.
|
324 |
+
e. This License constitutes the entire agreement between the parties with
|
325 |
+
respect to the Work licensed here. There are no understandings,
|
326 |
+
agreements or representations with respect to the Work not specified
|
327 |
+
here. Licensor shall not be bound by any additional provisions that
|
328 |
+
may appear in any communication from You. This License may not be
|
329 |
+
modified without the mutual written agreement of the Licensor and You.
|
330 |
+
f. The rights granted under, and the subject matter referenced, in this
|
331 |
+
License were drafted utilizing the terminology of the Berne Convention
|
332 |
+
for the Protection of Literary and Artistic Works (as amended on
|
333 |
+
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
334 |
+
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
335 |
+
and the Universal Copyright Convention (as revised on July 24, 1971).
|
336 |
+
These rights and subject matter take effect in the relevant
|
337 |
+
jurisdiction in which the License terms are sought to be enforced
|
338 |
+
according to the corresponding provisions of the implementation of
|
339 |
+
those treaty provisions in the applicable national law. If the
|
340 |
+
standard suite of rights granted under applicable copyright law
|
341 |
+
includes additional rights not granted under this License, such
|
342 |
+
additional rights are deemed to be included in the License; this
|
343 |
+
License is not intended to restrict the license of any rights under
|
344 |
+
applicable law.
|
345 |
+
|
346 |
+
|
347 |
+
Creative Commons Notice
|
348 |
+
|
349 |
+
Creative Commons is not a party to this License, and makes no warranty
|
350 |
+
whatsoever in connection with the Work. Creative Commons will not be
|
351 |
+
liable to You or any party on any legal theory for any damages
|
352 |
+
whatsoever, including without limitation any general, special,
|
353 |
+
incidental or consequential damages arising in connection to this
|
354 |
+
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
355 |
+
Commons has expressly identified itself as the Licensor hereunder, it
|
356 |
+
shall have all rights and obligations of Licensor.
|
357 |
+
|
358 |
+
Except for the limited purpose of indicating to the public that the
|
359 |
+
Work is licensed under the CCPL, Creative Commons does not authorize
|
360 |
+
the use by either party of the trademark "Creative Commons" or any
|
361 |
+
related trademark or logo of Creative Commons without the prior
|
362 |
+
written consent of Creative Commons. Any permitted use will be in
|
363 |
+
compliance with Creative Commons' then-current trademark usage
|
364 |
+
guidelines, as may be published on its website or otherwise made
|
365 |
+
available upon request from time to time. For the avoidance of doubt,
|
366 |
+
this trademark restriction does not form part of this License.
|
367 |
+
|
368 |
+
Creative Commons may be contacted at https://creativecommons.org/.
|
369 |
+
"""
|
370 |
|
371 |
DIALOG_BABI_ARCHIVE_URL = "https://www.dropbox.com/s/20rgyj8rryvos9l/dialog-bAbI-tasks-1_6.zip?dl=1"
|
372 |
|
373 |
|
374 |
+
class DialogBabi(datasets.GeneratorBasedBuilder):
|
375 |
"""Facebook's dataset 'dialog-babi' for end-to-end dialogue learning."""
|
376 |
|
377 |
VERSION = datasets.Version("1.0.0")
|
|
|
386 |
]
|
387 |
|
388 |
DEFAULT_CONFIG_NAME = "task1-API-calls"
|
389 |
+
CONFIGS_WITH_KB = ("task3-options", "task4-phone-address", "task5-full-dialogs")
|
390 |
|
391 |
def _info(self):
|
392 |
+
if self.config.name in self.CONFIGS_WITH_KB:
|
393 |
features = datasets.Features(
|
394 |
{
|
395 |
"user_turns": datasets.Sequence(datasets.Value("string")),
|
396 |
+
"system_turns": datasets.Sequence(datasets.Value("string")),
|
397 |
+
"kb_facts": datasets.Sequence(feature={"turn_id":datasets.Value("int32"), "fact":datasets.Value("string")})
|
398 |
}
|
399 |
)
|
400 |
else:
|
|
|
416 |
data_dir = dl_manager.download_and_extract(DIALOG_BABI_ARCHIVE_URL)
|
417 |
task_data_dir = os.path.join(data_dir, "dialog-bAbI-tasks-1_6", self.config.name)
|
418 |
|
419 |
+
if self.config.name == "task6-dstc2":
|
420 |
+
return [
|
421 |
+
datasets.SplitGenerator(
|
422 |
+
name=datasets.Split.TRAIN,
|
423 |
+
# These kwargs will be passed to _generate_examples
|
424 |
+
gen_kwargs={
|
425 |
+
"filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-trn.txt"),
|
426 |
+
"split": f"{self.config.name}-train",
|
427 |
+
},
|
428 |
+
),
|
429 |
+
datasets.SplitGenerator(
|
430 |
+
name=datasets.Split.VALIDATION,
|
431 |
+
# These kwargs will be passed to _generate_examples
|
432 |
+
gen_kwargs={
|
433 |
+
"filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-dev.txt"),
|
434 |
+
"split": f"{self.config.name}-dev",
|
435 |
+
},
|
436 |
+
),
|
437 |
+
datasets.SplitGenerator(
|
438 |
+
name=datasets.Split.TEST,
|
439 |
+
# These kwargs will be passed to _generate_examples
|
440 |
+
gen_kwargs={
|
441 |
+
"filepath": os.path.join(task_data_dir, f"dialog-babi-{self.config.name}-tst.txt"),
|
442 |
+
"split": f"{self.config.name}-test"
|
443 |
+
},
|
444 |
+
)
|
445 |
+
]
|
446 |
+
|
447 |
return [
|
448 |
datasets.SplitGenerator(
|
449 |
name=datasets.Split.TRAIN,
|
|
|
499 |
|
500 |
user_turns = []
|
501 |
system_turns = []
|
502 |
+
kb_facts = []
|
503 |
|
504 |
+
for turn_id, turn in enumerate(dialogue_rows):
|
505 |
+
if "\t" not in turn:
|
506 |
+
kb_facts.append({"turn_id": turn_id, "fact": turn})
|
507 |
+
else:
|
508 |
+
rest_turn, sys_turn = turn.split("\t")
|
509 |
+
_, user_turn = rest_turn.split(" ", 1)
|
510 |
+
user_turns.append(user_turn)
|
511 |
+
system_turns.append(sys_turn)
|
512 |
|
513 |
|
514 |
example_key = f"{split}-{dialogue_id}"
|
515 |
+
|
516 |
+
dialogue_dict = {
|
517 |
"user_turns": user_turns,
|
518 |
"system_turns": system_turns
|
519 |
}
|
520 |
+
|
521 |
+
if self.config.name in self.CONFIGS_WITH_KB:
|
522 |
+
dialogue_dict["kb_facts"] = kb_facts
|
523 |
+
|
524 |
+
return example_key, dialogue_dict
|
525 |
|