asi commited on
Commit
cfd3f56
1 Parent(s): ba357bb

:books: add documentation

Browse files
README.md ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ language_creators:
5
+ - found
6
+ languages:
7
+ - en
8
+ licenses:
9
+ - cc-by-nc-sa-4.0
10
+ multilinguality:
11
+ - multilingual
12
+ pretty_name: stackexchange
13
+ size_categories:
14
+ - unknown
15
+ source_datasets:
16
+ - original
17
+ task_categories:
18
+ - question-answering
19
+ task_ids:
20
+ - closed-domain-qa
21
+ ---
22
+
23
+ # Dataset Card Creation Guide
24
+
25
+ ## Table of Contents
26
+ - [Dataset Card Creation Guide](#dataset-card-creation-guide)
27
+ - [Table of Contents](#table-of-contents)
28
+ - [Dataset Description](#dataset-description)
29
+ - [Dataset Summary](#dataset-summary)
30
+ - [Languages](#languages)
31
+ - [Dataset Structure](#dataset-structure)
32
+ - [Data Instances](#data-instances)
33
+ - [Data Fields](#data-fields)
34
+ - [Data Splits](#data-splits)
35
+ - [Dataset Creation](#dataset-creation)
36
+ - [Curation Rationale](#curation-rationale)
37
+ - [Source Data](#source-data)
38
+ - [Initial Data Collection and Normalization](#initial-data-collection-and-normalization)
39
+ - [Who are the source language producers?](#who-are-the-source-language-producers)s
40
+ - [Additional Information](#additional-information)
41
+ - [Licensing Information](#licensing-information)
42
+ - [Citation Information](#citation-information)
43
+ - [Contributions](#contributions)
44
+
45
+ ## Dataset Description
46
+
47
+ - **Homepage:** [stackexchange](https://archive.org/details/stackexchange)
48
+ - **Repository:** [flax-sentence-embeddings](https://github.com/nreimers/flax-sentence-embeddings)
49
+
50
+ ### Dataset Summary
51
+
52
+ We automatically extracted question and answer (Q&A) pairs from [Stack Exchange](https://stackexchange.com/) network. Stack Exchange gather many Q&A communities across 50 online plateform, including the well known Stack Overflow and other technical sites. 100 millon developpers consult Stack Exchange every month. The dataset is a parallel corpus with each question mapped to the top rated answer. The dataset is split given communities which cover a variety of domains from 3d printing, economics, raspberry pi or emacs. An exhaustive list of all communities is available [here](https://stackexchange.com/sites).
53
+
54
+ ### Languages
55
+
56
+ Stack Exchange mainly consist of english language (en).
57
+
58
+ ## Dataset Structure
59
+
60
+ ### Data Instances
61
+
62
+ Each data samples is presented as follow:
63
+
64
+ ```
65
+ {'title_body': "Is there a Stack Exchange icon available? StackAuth /sites route provides all the site's icons except for the one of the Stack Exchange master site.\nCould you please provide it in some way (a static SVG would be good)?",
66
+ 'upvoted_answer': 'Here it is!\n\nDead link: SVG version here\nNote: the same restrictions on this trademarked icon that apply here, also apply to the icon above.',
67
+ 'downvoted_answer': 'No, the /sites route is not the right place for that.\n\n/sites enumerates all websites that expose API end-points. StackExchange.com does not expose such an endpoint, so it does not (and will not) appear in the results.'}
68
+ ```
69
+
70
+ This particular exampe corresponds to the [following page](https://stackapps.com/questions/1508/is-there-a-stack-exchange-icon-available)
71
+
72
+ ### Data Fields
73
+
74
+ The fields present in the dataset contain the following informations:
75
+
76
+ - `title_body`: This is the concatenation of the title and body from the question
77
+ - `upvoted_answer`: This is the body from the most upvoted answer
78
+
79
+ ### Data Splits
80
+
81
+ We provide multiple splits for this dataset, which each refers to a given community channel. We detail the number of pail for each split below:
82
+
83
+
84
+ | | Number of pairs |
85
+ | ----- | ------ |
86
+ | gaming | 82,887 |
87
+ | dba | 71,449 |
88
+ | codereview | 41,748 |
89
+ | gis | 100,254 |
90
+ | english | 100,640 |
91
+ | mathoverflow | 85,289 |
92
+ | askubuntu | 267,135 |
93
+ | electronics | 129,494 |
94
+ | apple | 92,487 |
95
+ | diy | 52,896 |
96
+ | magento | 79,241 |
97
+ | gamedev | 40,154 |
98
+ | mathematica | 59,895 |
99
+ | ell | 77,892 |
100
+ | judaism | 26,085 |
101
+ | drupal | 67,817 |
102
+ | blender | 54,153 |
103
+ | biology | 19,277 |
104
+ | android | 38,077 |
105
+ | crypto | 19,404 |
106
+ | christianity | 11,498 |
107
+ | cs | 30,010 |
108
+ | academia | 32,137 |
109
+ | chemistry | 27,061 |
110
+ | aviation | 18,755 |
111
+ | history | 10,766 |
112
+ | japanese | 20,948 |
113
+ | cooking | 22,641 |
114
+ | law | 16,133 |
115
+ | hermeneutics | 9,516 |
116
+ | hinduism | 8,999 |
117
+ | graphicdesign | 28,083 |
118
+ | dsp | 17,430 |
119
+ | bicycles | 15,708 |
120
+ | ethereum | 26,124 |
121
+ | ja | 17,376 |
122
+ | arduino | 16,281 |
123
+ | bitcoin | 22,474 |
124
+ | islam | 10,052 |
125
+ | datascience | 20,503 |
126
+ | german | 13,733 |
127
+ | codegolf | 8,211 |
128
+ | boardgames | 11,805 |
129
+ | economics | 8,844 |
130
+ | emacs | 16,830 |
131
+ | buddhism | 6,787 |
132
+ | gardening | 13,246 |
133
+ | astronomy | 9,086 |
134
+ | anime | 10,131 |
135
+ | fitness | 8,297 |
136
+ | cstheory | 7,742 |
137
+ | engineering | 8,649 |
138
+ | chinese | 8,646 |
139
+ | linguistics | 6,843 |
140
+ | cogsci | 5,101 |
141
+ | french | 10,578 |
142
+ | literature | 3,539 |
143
+ | ai | 5,763 |
144
+ | craftcms | 11,236 |
145
+ | health | 4,494 |
146
+ | chess | 6,392 |
147
+ | interpersonal | 3,398 |
148
+ | expressionengine | 10,742 |
149
+ | earthscience | 4,396 |
150
+ | civicrm | 10,648 |
151
+ | joomla | 5,887 |
152
+ | homebrew | 5,608 |
153
+ | latin | 3,969 |
154
+ | ham | 3,501 |
155
+ | hsm | 2,517 |
156
+ | avp | 6,450 |
157
+ | expatriates | 4,913 |
158
+ | matheducators | 2,706 |
159
+ | genealogy | 2,895 |
160
+ | 3dprinting | 3,488 |
161
+ | devops | 3,462 |
162
+ | bioinformatics | 3,135 |
163
+ | computergraphics | 2,306 |
164
+ | elementaryos | 5,917 |
165
+ | martialarts | 1,737 |
166
+ | hardwarerecs | 2,050 |
167
+ | lifehacks | 2,576 |
168
+ | crafts | 1,659 |
169
+ | italian | 3,101 |
170
+ | freelancing | 1,663 |
171
+ | materials | 1,101 |
172
+ | bricks | 3,530 |
173
+ | cseducators | 902 |
174
+ | eosio | 1,940 |
175
+ | iot | 1,359 |
176
+ | languagelearning | 948 |
177
+ | beer | 1,012 |
178
+ | ebooks | 1,107 |
179
+ | coffee | 1,188 |
180
+ | esperanto | 1,466 |
181
+ | korean | 1,406 |
182
+ | cardano | 248 |
183
+ | conlang | 334 |
184
+ | drones | 496 |
185
+ | iota | 775 |
186
+ | salesforce | 87,272 |
187
+ | wordpress | 83,621 |
188
+ | rpg | 40,435 |
189
+ | scifi | 54,805 |
190
+ | stats | 115,679 |
191
+ | serverfault | 238,507 |
192
+ | physics | 141,230 |
193
+ | sharepoint | 80,420 |
194
+ | security | 51,355 |
195
+ | worldbuilding | 26,210 |
196
+ | softwareengineering | 51,326 |
197
+ | superuser | 352,610 |
198
+ | meta | 1,000 |
199
+ | money | 29,404 |
200
+ | travel | 36,533 |
201
+ | photo | 23,204 |
202
+ | webmasters | 30,370 |
203
+ | workplace | 24,012 |
204
+ | ux | 28,901 |
205
+ | philosophy | 13,114 |
206
+ | music | 19,936 |
207
+ | politics | 11,047 |
208
+ | movies | 18,243 |
209
+ | space | 12,893 |
210
+ | skeptics | 8,145 |
211
+ | raspberrypi | 24,143 |
212
+ | rus | 16,528 |
213
+ | puzzling | 17,448 |
214
+ | webapps | 24,867 |
215
+ | mechanics | 18,613 |
216
+ | writers | 9,867 |
217
+ | networkengineering | 12,590 |
218
+ | parenting | 5,998 |
219
+ | softwarerecs | 11,761 |
220
+ | quant | 12,933 |
221
+ | spanish | 7,675 |
222
+ | scicomp | 7,036 |
223
+ | pets | 6,156 |
224
+ | sqa | 9,256 |
225
+ | sitecore | 7,838 |
226
+ | vi | 9,000 |
227
+ | outdoors | 5,278 |
228
+ | sound | 8,303 |
229
+ | pm | 5,435 |
230
+ | reverseengineering | 5,817 |
231
+ | retrocomputing | 3,907 |
232
+ | tridion | 5,907 |
233
+ | quantumcomputing | 4,320 |
234
+ | sports | 4,707 |
235
+ | robotics | 4,648 |
236
+ | russian | 3,937 |
237
+ | opensource | 3,221 |
238
+ | woodworking | 2,955 |
239
+ | ukrainian | 1,767 |
240
+ | opendata | 3,842 |
241
+ | patents | 3,573 |
242
+ | mythology | 1,595 |
243
+ | portuguese | 1,964 |
244
+ | tor | 4,167 |
245
+ | monero | 3,508 |
246
+ | sustainability | 1,674 |
247
+ | musicfans | 2,431 |
248
+ | poker | 1,665 |
249
+ | or | 1,490 |
250
+ | windowsphone | 2,807 |
251
+ | stackapps | 1,518 |
252
+ | moderators | 504 |
253
+ | vegetarianism | 585 |
254
+ | tezos | 1,169 |
255
+ | stellar | 1,078 |
256
+ | pt | 103,277 |
257
+ | unix | 155,414 |
258
+ | tex | 171,628 |
259
+ | ru | 253,289 |
260
+ | total | 4,750,619 |
261
+
262
+ ## Dataset Creation
263
+
264
+ ### Curation Rationale
265
+
266
+ We primary designed this dataset for sentence embeddings training. Indeed sentence embeddings may be trained using a contrastive learning setup for which the model is trained to associate each sentence with its corresponding pair out of multiple proposition. Such models require many examples to be efficient and thus the dataset creation may be tedious. Community networks such as Stack Exchange allow us to build many examples semi-automatically.
267
+
268
+ ### Source Data
269
+
270
+ The source data are dumps from [Stack Exchange](https://archive.org/details/stackexchange)
271
+
272
+ #### Initial Data Collection and Normalization
273
+
274
+ We collected the data from the math community.
275
+
276
+ We filtered out questions which title or body length is bellow 20 characters and questions for which body length is above 4096 characters.
277
+
278
+ #### Who are the source language producers?
279
+
280
+ Questions and answers are written by the community developpers of Stack Exchange.
281
+
282
+ ## Additional Information
283
+
284
+ ### Licensing Information
285
+
286
+ Please see the license information at: https://archive.org/details/stackexchange
287
+
288
+ ### Citation Information
289
+
290
+ ```
291
+ @misc{StackExchangeDataset,
292
+ author = {Flax Sentence Embeddings Team},
293
+ title = {Stack Exchange question pairs},
294
+ year = {2021},
295
+ howpublished = {https://huggingface.co/datasets/flax-sentence-embeddings/},
296
+ }
297
+ ```
298
+
299
+
300
+ ### Contributions
301
+
302
+ Thanks to the Flax Sentence Embeddings team for adding this dataset.
stackexchange_title_best_voted_answer_jsonl.py ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The HuggingFace Datasets Authors and the Flax Sentence Embeddings team.
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
+ """The dataset is a collection of Question and Answer automatically extracted from Stack Exchange community network."""
16
+
17
+
18
+ import csv
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ _CITATION = """\
26
+ @misc{StackExchangeDataset,
27
+ author = {Flax Sentence Embeddings Team},
28
+ title = {Stack Exchange question pairs},
29
+ year = {2021},
30
+ howpublished = {https://huggingface.co/datasets/flax-sentence-embeddings/},
31
+ }
32
+ """
33
+
34
+ # TODO: Add description of the dataset here
35
+ # You can copy an official description
36
+ _DESCRIPTION = """\
37
+ This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
38
+ """
39
+
40
+ # TODO: Add a link to an official homepage for the dataset here
41
+ _HOMEPAGE = "https://huggingface.co/datasets/flax-sentence-embeddings/"
42
+
43
+ # TODO: Add the licence for the dataset here if you can find it
44
+ _LICENSE = "https://archive.org/details/stackexchange"
45
+
46
+ # TODO: Add link to the official dataset URLs here
47
+ # The HuggingFace dataset library don't host the datasets but only point to the original files
48
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
49
+ _URLs = {
50
+ 'gaming': 'gaming.stackexchange.com.jsonl.gz',
51
+ 'dba': 'dba.stackexchange.com.jsonl.gz',
52
+ 'codereview': 'codereview.stackexchange.com.jsonl.gz',
53
+ 'gis': 'gis.stackexchange.com.jsonl.gz',
54
+ 'english': 'english.stackexchange.com.jsonl.gz',
55
+ 'mathoverflow': 'mathoverflow.net.jsonl.gz',
56
+ 'askubuntu': 'askubuntu.com.jsonl.gz',
57
+ 'electronics': 'electronics.stackexchange.com.jsonl.gz',
58
+ 'apple': 'apple.stackexchange.com.jsonl.gz',
59
+ 'diy': 'diy.stackexchange.com.jsonl.gz',
60
+ 'magento': 'magento.stackexchange.com.jsonl.gz',
61
+ 'gamedev': 'gamedev.stackexchange.com.jsonl.gz',
62
+ 'mathematica': 'mathematica.stackexchange.com.jsonl.gz',
63
+ 'ell': 'ell.stackexchange.com.jsonl.gz',
64
+ 'judaism': 'judaism.stackexchange.com.jsonl.gz',
65
+ 'drupal': 'drupal.stackexchange.com.jsonl.gz',
66
+ 'blender': 'blender.stackexchange.com.jsonl.gz',
67
+ 'biology': 'biology.stackexchange.com.jsonl.gz',
68
+ 'android': 'android.stackexchange.com.jsonl.gz',
69
+ 'crypto': 'crypto.stackexchange.com.jsonl.gz',
70
+ 'christianity': 'christianity.stackexchange.com.jsonl.gz',
71
+ 'cs': 'cs.stackexchange.com.jsonl.gz',
72
+ 'academia': 'academia.stackexchange.com.jsonl.gz',
73
+ 'chemistry': 'chemistry.stackexchange.com.jsonl.gz',
74
+ 'aviation': 'aviation.stackexchange.com.jsonl.gz',
75
+ 'history': 'history.stackexchange.com.jsonl.gz',
76
+ 'japanese': 'japanese.stackexchange.com.jsonl.gz',
77
+ 'cooking': 'cooking.stackexchange.com.jsonl.gz',
78
+ 'law': 'law.stackexchange.com.jsonl.gz',
79
+ 'hermeneutics': 'hermeneutics.stackexchange.com.jsonl.gz',
80
+ 'hinduism': 'hinduism.stackexchange.com.jsonl.gz',
81
+ 'graphicdesign': 'graphicdesign.stackexchange.com.jsonl.gz',
82
+ 'dsp': 'dsp.stackexchange.com.jsonl.gz',
83
+ 'bicycles': 'bicycles.stackexchange.com.jsonl.gz',
84
+ 'ethereum': 'ethereum.stackexchange.com.jsonl.gz',
85
+ 'ja': 'ja.stackoverflow.com.jsonl.gz',
86
+ 'arduino': 'arduino.stackexchange.com.jsonl.gz',
87
+ 'bitcoin': 'bitcoin.stackexchange.com.jsonl.gz',
88
+ 'islam': 'islam.stackexchange.com.jsonl.gz',
89
+ 'datascience': 'datascience.stackexchange.com.jsonl.gz',
90
+ 'german': 'german.stackexchange.com.jsonl.gz',
91
+ 'codegolf': 'codegolf.stackexchange.com.jsonl.gz',
92
+ 'boardgames': 'boardgames.stackexchange.com.jsonl.gz',
93
+ 'economics': 'economics.stackexchange.com.jsonl.gz',
94
+ 'emacs': 'emacs.stackexchange.com.jsonl.gz',
95
+ 'buddhism': 'buddhism.stackexchange.com.jsonl.gz',
96
+ 'gardening': 'gardening.stackexchange.com.jsonl.gz',
97
+ 'astronomy': 'astronomy.stackexchange.com.jsonl.gz',
98
+ 'anime': 'anime.stackexchange.com.jsonl.gz',
99
+ 'fitness': 'fitness.stackexchange.com.jsonl.gz',
100
+ 'cstheory': 'cstheory.stackexchange.com.jsonl.gz',
101
+ 'engineering': 'engineering.stackexchange.com.jsonl.gz',
102
+ 'chinese': 'chinese.stackexchange.com.jsonl.gz',
103
+ 'linguistics': 'linguistics.stackexchange.com.jsonl.gz',
104
+ 'cogsci': 'cogsci.stackexchange.com.jsonl.gz',
105
+ 'french': 'french.stackexchange.com.jsonl.gz',
106
+ 'literature': 'literature.stackexchange.com.jsonl.gz',
107
+ 'ai': 'ai.stackexchange.com.jsonl.gz',
108
+ 'craftcms': 'craftcms.stackexchange.com.jsonl.gz',
109
+ 'health': 'health.stackexchange.com.jsonl.gz',
110
+ 'chess': 'chess.stackexchange.com.jsonl.gz',
111
+ 'interpersonal': 'interpersonal.stackexchange.com.jsonl.gz',
112
+ 'expressionengine': 'expressionengine.stackexchange.com.jsonl.gz',
113
+ 'earthscience': 'earthscience.stackexchange.com.jsonl.gz',
114
+ 'civicrm': 'civicrm.stackexchange.com.jsonl.gz',
115
+ 'joomla': 'joomla.stackexchange.com.jsonl.gz',
116
+ 'homebrew': 'homebrew.stackexchange.com.jsonl.gz',
117
+ 'latin': 'latin.stackexchange.com.jsonl.gz',
118
+ 'ham': 'ham.stackexchange.com.jsonl.gz',
119
+ 'hsm': 'hsm.stackexchange.com.jsonl.gz',
120
+ 'avp': 'avp.stackexchange.com.jsonl.gz',
121
+ 'expatriates': 'expatriates.stackexchange.com.jsonl.gz',
122
+ 'matheducators': 'matheducators.stackexchange.com.jsonl.gz',
123
+ 'genealogy': 'genealogy.stackexchange.com.jsonl.gz',
124
+ '3dprinting': '3dprinting.stackexchange.com.jsonl.gz',
125
+ 'devops': 'devops.stackexchange.com.jsonl.gz',
126
+ 'bioinformatics': 'bioinformatics.stackexchange.com.jsonl.gz',
127
+ 'computergraphics': 'computergraphics.stackexchange.com.jsonl.gz',
128
+ 'elementaryos': 'elementaryos.stackexchange.com.jsonl.gz',
129
+ 'martialarts': 'martialarts.stackexchange.com.jsonl.gz',
130
+ 'hardwarerecs': 'hardwarerecs.stackexchange.com.jsonl.gz',
131
+ 'lifehacks': 'lifehacks.stackexchange.com.jsonl.gz',
132
+ 'crafts': 'crafts.stackexchange.com.jsonl.gz',
133
+ 'italian': 'italian.stackexchange.com.jsonl.gz',
134
+ 'freelancing': 'freelancing.stackexchange.com.jsonl.gz',
135
+ 'materials': 'materials.stackexchange.com.jsonl.gz',
136
+ 'bricks': 'bricks.stackexchange.com.jsonl.gz',
137
+ 'cseducators': 'cseducators.stackexchange.com.jsonl.gz',
138
+ 'eosio': 'eosio.stackexchange.com.jsonl.gz',
139
+ 'iot': 'iot.stackexchange.com.jsonl.gz',
140
+ 'languagelearning': 'languagelearning.stackexchange.com.jsonl.gz',
141
+ 'beer': 'beer.stackexchange.com.jsonl.gz',
142
+ 'ebooks': 'ebooks.stackexchange.com.jsonl.gz',
143
+ 'coffee': 'coffee.stackexchange.com.jsonl.gz',
144
+ 'esperanto': 'esperanto.stackexchange.com.jsonl.gz',
145
+ 'korean': 'korean.stackexchange.com.jsonl.gz',
146
+ 'cardano': 'cardano.stackexchange.com.jsonl.gz',
147
+ 'conlang': 'conlang.stackexchange.com.jsonl.gz',
148
+ 'drones': 'drones.stackexchange.com.jsonl.gz',
149
+ 'iota': 'iota.stackexchange.com.jsonl.gz',
150
+ 'salesforce': 'salesforce.stackexchange.com.jsonl.gz',
151
+ 'wordpress': 'wordpress.stackexchange.com.jsonl.gz',
152
+ 'rpg': 'rpg.stackexchange.com.jsonl.gz',
153
+ 'scifi': 'scifi.stackexchange.com.jsonl.gz',
154
+ 'stats': 'stats.stackexchange.com.jsonl.gz',
155
+ 'serverfault': 'serverfault.com.jsonl.gz',
156
+ 'physics': 'physics.stackexchange.com.jsonl.gz',
157
+ 'sharepoint': 'sharepoint.stackexchange.com.jsonl.gz',
158
+ 'security': 'security.stackexchange.com.jsonl.gz',
159
+ 'worldbuilding': 'worldbuilding.stackexchange.com.jsonl.gz',
160
+ 'softwareengineering': 'softwareengineering.stackexchange.com.jsonl.gz',
161
+ 'superuser': 'superuser.com.jsonl.gz',
162
+ 'meta': 'meta.mathoverflow.net.jsonl.gz',
163
+ 'money': 'money.stackexchange.com.jsonl.gz',
164
+ 'travel': 'travel.stackexchange.com.jsonl.gz',
165
+ 'photo': 'photo.stackexchange.com.jsonl.gz',
166
+ 'webmasters': 'webmasters.stackexchange.com.jsonl.gz',
167
+ 'workplace': 'workplace.stackexchange.com.jsonl.gz',
168
+ 'ux': 'ux.stackexchange.com.jsonl.gz',
169
+ 'philosophy': 'philosophy.stackexchange.com.jsonl.gz',
170
+ 'music': 'music.stackexchange.com.jsonl.gz',
171
+ 'politics': 'politics.stackexchange.com.jsonl.gz',
172
+ 'movies': 'movies.stackexchange.com.jsonl.gz',
173
+ 'space': 'space.stackexchange.com.jsonl.gz',
174
+ 'skeptics': 'skeptics.stackexchange.com.jsonl.gz',
175
+ 'raspberrypi': 'raspberrypi.stackexchange.com.jsonl.gz',
176
+ 'rus': 'rus.stackexchange.com.jsonl.gz',
177
+ 'puzzling': 'puzzling.stackexchange.com.jsonl.gz',
178
+ 'webapps': 'webapps.stackexchange.com.jsonl.gz',
179
+ 'mechanics': 'mechanics.stackexchange.com.jsonl.gz',
180
+ 'writers': 'writers.stackexchange.com.jsonl.gz',
181
+ 'networkengineering': 'networkengineering.stackexchange.com.jsonl.gz',
182
+ 'parenting': 'parenting.stackexchange.com.jsonl.gz',
183
+ 'softwarerecs': 'softwarerecs.stackexchange.com.jsonl.gz',
184
+ 'quant': 'quant.stackexchange.com.jsonl.gz',
185
+ 'spanish': 'spanish.stackexchange.com.jsonl.gz',
186
+ 'scicomp': 'scicomp.stackexchange.com.jsonl.gz',
187
+ 'pets': 'pets.stackexchange.com.jsonl.gz',
188
+ 'sqa': 'sqa.stackexchange.com.jsonl.gz',
189
+ 'sitecore': 'sitecore.stackexchange.com.jsonl.gz',
190
+ 'vi': 'vi.stackexchange.com.jsonl.gz',
191
+ 'outdoors': 'outdoors.stackexchange.com.jsonl.gz',
192
+ 'sound': 'sound.stackexchange.com.jsonl.gz',
193
+ 'pm': 'pm.stackexchange.com.jsonl.gz',
194
+ 'reverseengineering': 'reverseengineering.stackexchange.com.jsonl.gz',
195
+ 'retrocomputing': 'retrocomputing.stackexchange.com.jsonl.gz',
196
+ 'tridion': 'tridion.stackexchange.com.jsonl.gz',
197
+ 'quantumcomputing': 'quantumcomputing.stackexchange.com.jsonl.gz',
198
+ 'sports': 'sports.stackexchange.com.jsonl.gz',
199
+ 'robotics': 'robotics.stackexchange.com.jsonl.gz',
200
+ 'russian': 'russian.stackexchange.com.jsonl.gz',
201
+ 'opensource': 'opensource.stackexchange.com.jsonl.gz',
202
+ 'woodworking': 'woodworking.stackexchange.com.jsonl.gz',
203
+ 'ukrainian': 'ukrainian.stackexchange.com.jsonl.gz',
204
+ 'opendata': 'opendata.stackexchange.com.jsonl.gz',
205
+ 'patents': 'patents.stackexchange.com.jsonl.gz',
206
+ 'mythology': 'mythology.stackexchange.com.jsonl.gz',
207
+ 'portuguese': 'portuguese.stackexchange.com.jsonl.gz',
208
+ 'tor': 'tor.stackexchange.com.jsonl.gz',
209
+ 'monero': 'monero.stackexchange.com.jsonl.gz',
210
+ 'sustainability': 'sustainability.stackexchange.com.jsonl.gz',
211
+ 'musicfans': 'musicfans.stackexchange.com.jsonl.gz',
212
+ 'poker': 'poker.stackexchange.com.jsonl.gz',
213
+ 'or': 'or.stackexchange.com.jsonl.gz',
214
+ 'windowsphone': 'windowsphone.stackexchange.com.jsonl.gz',
215
+ 'stackapps': 'stackapps.com.jsonl.gz',
216
+ 'moderators': 'moderators.stackexchange.com.jsonl.gz',
217
+ 'vegetarianism': 'vegetarianism.stackexchange.com.jsonl.gz',
218
+ 'tezos': 'tezos.stackexchange.com.jsonl.gz',
219
+ 'stellar': 'stellar.stackexchange.com.jsonl.gz',
220
+ 'pt': 'pt.stackoverflow.com.jsonl.gz',
221
+ 'unix': 'unix.stackexchange.com.jsonl.gz',
222
+ 'tex': 'tex.stackexchange.com.jsonl.gz',
223
+ 'ru': 'ru.stackoverflow.com.jsonl.gz'
224
+ }
225
+
226
+
227
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
228
+ class StackExchange(datasets.GeneratorBasedBuilder):
229
+ """The dataset is a collection of Question and Answer automatically extracted from match Stack Exchange community."""
230
+
231
+ VERSION = datasets.Version("1.1.0")
232
+
233
+ BUILDER_CONFIGS = [
234
+ datasets.BuilderConfig(name=url, version='1.1.0',
235
+ description="Includes title and body from the question as well as most upvoted answer for theme {}.".format(url)) \
236
+ for url in _URLs.keys()
237
+ ]
238
+
239
+
240
+ def _info(self):
241
+ features = datasets.Features(
242
+ {
243
+ "title_body": datasets.Value("string"),
244
+ "upvoted_answer": datasets.Value("string"),
245
+ }
246
+ )
247
+
248
+ return datasets.DatasetInfo(
249
+ # This is the description that will appear on the datasets page.
250
+ description=_DESCRIPTION,
251
+ # This defines the different columns of the dataset and their types
252
+ features=features, # Here we define them above because they are different between the two configurations
253
+ # If there's a common (input, target) tuple from the features,
254
+ # specify them here. They'll be used if as_supervised=True in
255
+ # builder.as_dataset.
256
+ supervised_keys=None,
257
+ # Homepage of the dataset for documentation
258
+ homepage=_HOMEPAGE,
259
+ # License for the dataset if available
260
+ license=_LICENSE,
261
+ # Citation for the dataset
262
+ citation=_CITATION,
263
+ )
264
+
265
+ def _split_generators(self, dl_manager):
266
+ """Returns SplitGenerators."""
267
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
268
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
269
+
270
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
271
+ # 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.
272
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
273
+ my_urls = _URLs[self.config.name]
274
+ data_file = dl_manager.download_and_extract(my_urls)
275
+ return [
276
+ datasets.SplitGenerator(
277
+ name=datasets.Split.TRAIN,
278
+ # These kwargs will be passed to _generate_examples
279
+ gen_kwargs={
280
+ "filepath": data_file,
281
+ },
282
+ )
283
+ ]
284
+
285
+ def _generate_examples(
286
+ self, filepath # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
287
+ ):
288
+ """ Yields examples as (key, example) tuples. """
289
+ # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
290
+ # The `key` is here for legacy reason (tfds) and is not important in itself.
291
+
292
+ with open(filepath, encoding="utf-8") as f:
293
+ for id_, row in enumerate(f):
294
+ data = json.loads(row)
295
+ yield id_, {
296
+ "title_body": data[0],
297
+ "upvoted_answer": data[1],
298
+ }