Datasets:
Tasks:
Question Answering
Modalities:
Text
Sub-tasks:
closed-domain-qa
Languages:
English
Size:
1M - 10M
License:
:books: Add documentationn and loading scripts
Browse files- README.md +302 -0
- stackexchange_titlebody_best_voted_answer_jsonl.py +298 -0
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': 'How to determine if 3 points on a 3-D graph are collinear? Let the points $A, B$ and $C$ be $(x_1, y_1, z_1), (x_2, y_2, z_2)$ and $(x_3, y_3, z_3)$ respectively. How do I prove that the 3 points are collinear? What is the formula?',
|
66 |
+
'upvoted_answer': 'From $A(x_1,y_1,z_1),B(x_2,y_2,z_2),C(x_3,y_3,z_3)$ we can get their position vectors.\n\n$\\vec{AB}=(x_2-x_1,y_2-y_1,z_2-z_1)$ and $\\vec{AC}=(x_3-x_1,y_3-y_1,z_3-z_1)$.\n\nThen $||\\vec{AB}\\times\\vec{AC}||=0\\implies A,B,C$ collinear.',
|
67 |
+
```
|
68 |
+
|
69 |
+
This particular exampe corresponds to the [following page](https://math.stackexchange.com/questions/947555/how-to-determine-if-3-points-on-a-3-d-graph-are-collinear)
|
70 |
+
|
71 |
+
### Data Fields
|
72 |
+
|
73 |
+
The fields present in the dataset contain the following informations:
|
74 |
+
|
75 |
+
- `title_body`: This is the concatenation of the title and body from the question
|
76 |
+
- `upvoted_answer`: This is the body from the most upvoted answer
|
77 |
+
|
78 |
+
### Data Splits
|
79 |
+
|
80 |
+
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:
|
81 |
+
|
82 |
+
|
83 |
+
| | Number of pairs |
|
84 |
+
| ----- | ------ |
|
85 |
+
| apple | 92,487 |
|
86 |
+
| english | 100,640 |
|
87 |
+
| codereview | 41,748 |
|
88 |
+
| dba | 71,449 |
|
89 |
+
| mathoverflow | 85,289 |
|
90 |
+
| electronics | 129,494 |
|
91 |
+
| mathematica | 59,895 |
|
92 |
+
| drupal | 67,817 |
|
93 |
+
| magento | 79,241 |
|
94 |
+
| gaming | 82,887 |
|
95 |
+
| ell | 77,892 |
|
96 |
+
| gamedev | 40,154 |
|
97 |
+
| gis | 100,254 |
|
98 |
+
| askubuntu | 267,135 |
|
99 |
+
| diy | 52,896 |
|
100 |
+
| academia | 32,137 |
|
101 |
+
| blender | 54,153 |
|
102 |
+
| cs | 30,010 |
|
103 |
+
| chemistry | 27,061 |
|
104 |
+
| judaism | 26,085 |
|
105 |
+
| crypto | 19,404 |
|
106 |
+
| android | 38,077 |
|
107 |
+
| ja | 17,376 |
|
108 |
+
| christianity | 11,498 |
|
109 |
+
| graphicdesign | 28,083 |
|
110 |
+
| aviation | 18,755 |
|
111 |
+
| ethereum | 26,124 |
|
112 |
+
| biology | 19,277 |
|
113 |
+
| datascience | 20,503 |
|
114 |
+
| law | 16,133 |
|
115 |
+
| dsp | 17,430 |
|
116 |
+
| japanese | 20,948 |
|
117 |
+
| hermeneutics | 9,516 |
|
118 |
+
| bicycles | 15,708 |
|
119 |
+
| arduino | 16,281 |
|
120 |
+
| history | 10,766 |
|
121 |
+
| bitcoin | 22,474 |
|
122 |
+
| cooking | 22,641 |
|
123 |
+
| hinduism | 8,999 |
|
124 |
+
| codegolf | 8,211 |
|
125 |
+
| boardgames | 11,805 |
|
126 |
+
| emacs | 16,830 |
|
127 |
+
| economics | 8,844 |
|
128 |
+
| gardening | 13,246 |
|
129 |
+
| astronomy | 9,086 |
|
130 |
+
| islam | 10,052 |
|
131 |
+
| german | 13,733 |
|
132 |
+
| fitness | 8,297 |
|
133 |
+
| french | 10,578 |
|
134 |
+
| anime | 10,131 |
|
135 |
+
| craftcms | 11,236 |
|
136 |
+
| cstheory | 7,742 |
|
137 |
+
| engineering | 8,649 |
|
138 |
+
| buddhism | 6,787 |
|
139 |
+
| linguistics | 6,843 |
|
140 |
+
| ai | 5,763 |
|
141 |
+
| expressionengine | 10,742 |
|
142 |
+
| cogsci | 5,101 |
|
143 |
+
| chinese | 8,646 |
|
144 |
+
| chess | 6,392 |
|
145 |
+
| civicrm | 10,648 |
|
146 |
+
| literature | 3,539 |
|
147 |
+
| interpersonal | 3,398 |
|
148 |
+
| health | 4,494 |
|
149 |
+
| avp | 6,450 |
|
150 |
+
| earthscience | 4,396 |
|
151 |
+
| joomla | 5,887 |
|
152 |
+
| homebrew | 5,608 |
|
153 |
+
| expatriates | 4,913 |
|
154 |
+
| latin | 3,969 |
|
155 |
+
| matheducators | 2,706 |
|
156 |
+
| ham | 3,501 |
|
157 |
+
| genealogy | 2,895 |
|
158 |
+
| 3dprinting | 3,488 |
|
159 |
+
| elementaryos | 5,917 |
|
160 |
+
| bioinformatics | 3,135 |
|
161 |
+
| devops | 3,462 |
|
162 |
+
| hsm | 2,517 |
|
163 |
+
| italian | 3,101 |
|
164 |
+
| computergraphics | 2,306 |
|
165 |
+
| martialarts | 1,737 |
|
166 |
+
| bricks | 3,530 |
|
167 |
+
| freelancing | 1,663 |
|
168 |
+
| crafts | 1,659 |
|
169 |
+
| lifehacks | 2,576 |
|
170 |
+
| cseducators | 902 |
|
171 |
+
| materials | 1,101 |
|
172 |
+
| hardwarerecs | 2,050 |
|
173 |
+
| iot | 1,359 |
|
174 |
+
| eosio | 1,940 |
|
175 |
+
| languagelearning | 948 |
|
176 |
+
| korean | 1,406 |
|
177 |
+
| coffee | 1,188 |
|
178 |
+
| esperanto | 1,466 |
|
179 |
+
| beer | 1,012 |
|
180 |
+
| ebooks | 1,107 |
|
181 |
+
| iota | 775 |
|
182 |
+
| cardano | 248 |
|
183 |
+
| drones | 496 |
|
184 |
+
| conlang | 334 |
|
185 |
+
| pt | 103,277 |
|
186 |
+
| stats | 115,679 |
|
187 |
+
| unix | 155,414 |
|
188 |
+
| physics | 141,230 |
|
189 |
+
| tex | 171,628 |
|
190 |
+
| serverfault | 238,507 |
|
191 |
+
| salesforce | 87,272 |
|
192 |
+
| wordpress | 83,621 |
|
193 |
+
| softwareengineering | 51,326 |
|
194 |
+
| scifi | 54,805 |
|
195 |
+
| security | 51,355 |
|
196 |
+
| ru | 253,289 |
|
197 |
+
| superuser | 352,610 |
|
198 |
+
| sharepoint | 80,420 |
|
199 |
+
| rpg | 40,435 |
|
200 |
+
| travel | 36,533 |
|
201 |
+
| worldbuilding | 26,210 |
|
202 |
+
| meta | 1,000 |
|
203 |
+
| workplace | 24,012 |
|
204 |
+
| ux | 28,901 |
|
205 |
+
| money | 29,404 |
|
206 |
+
| webmasters | 30,370 |
|
207 |
+
| raspberrypi | 24,143 |
|
208 |
+
| photo | 23,204 |
|
209 |
+
| music | 19,936 |
|
210 |
+
| philosophy | 13,114 |
|
211 |
+
| puzzling | 17,448 |
|
212 |
+
| movies | 18,243 |
|
213 |
+
| quant | 12,933 |
|
214 |
+
| politics | 11,047 |
|
215 |
+
| space | 12,893 |
|
216 |
+
| mechanics | 18,613 |
|
217 |
+
| skeptics | 8,145 |
|
218 |
+
| rus | 16,528 |
|
219 |
+
| writers | 9,867 |
|
220 |
+
| webapps | 24,867 |
|
221 |
+
| softwarerecs | 11,761 |
|
222 |
+
| networkengineering | 12,590 |
|
223 |
+
| parenting | 5,998 |
|
224 |
+
| scicomp | 7,036 |
|
225 |
+
| sqa | 9,256 |
|
226 |
+
| sitecore | 7,838 |
|
227 |
+
| vi | 9,000 |
|
228 |
+
| spanish | 7,675 |
|
229 |
+
| pm | 5,435 |
|
230 |
+
| pets | 6,156 |
|
231 |
+
| sound | 8,303 |
|
232 |
+
| reverseengineering | 5,817 |
|
233 |
+
| outdoors | 5,278 |
|
234 |
+
| tridion | 5,907 |
|
235 |
+
| retrocomputing | 3,907 |
|
236 |
+
| robotics | 4,648 |
|
237 |
+
| quantumcomputing | 4,320 |
|
238 |
+
| sports | 4,707 |
|
239 |
+
| russian | 3,937 |
|
240 |
+
| opensource | 3,221 |
|
241 |
+
| woodworking | 2,955 |
|
242 |
+
| patents | 3,573 |
|
243 |
+
| tor | 4,167 |
|
244 |
+
| ukrainian | 1,767 |
|
245 |
+
| opendata | 3,842 |
|
246 |
+
| monero | 3,508 |
|
247 |
+
| sustainability | 1,674 |
|
248 |
+
| portuguese | 1,964 |
|
249 |
+
| mythology | 1,595 |
|
250 |
+
| musicfans | 2,431 |
|
251 |
+
| or | 1,490 |
|
252 |
+
| poker | 1,665 |
|
253 |
+
| windowsphone | 2,807 |
|
254 |
+
| moderators | 504 |
|
255 |
+
| stackapps | 1,518 |
|
256 |
+
| stellar | 1,078 |
|
257 |
+
| vegetarianism | 585 |
|
258 |
+
| tezos | 1,169 |
|
259 |
+
| total | 4,750,619 |
|
260 |
+
|
261 |
+
## Dataset Creation
|
262 |
+
|
263 |
+
### Curation Rationale
|
264 |
+
|
265 |
+
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.
|
266 |
+
|
267 |
+
### Source Data
|
268 |
+
|
269 |
+
The source data are dumps from [Stack Exchange](https://archive.org/details/stackexchange)
|
270 |
+
|
271 |
+
#### Initial Data Collection and Normalization
|
272 |
+
|
273 |
+
We collected the data from the math community.
|
274 |
+
|
275 |
+
We filtered out questions which title or body length is bellow 20 characters and questions for which body length is above 4096 characters.
|
276 |
+
When extracting most upvoted answer, we filtered to pairs for which their is at least 100 votes gap between most upvoted and downvoted answers.
|
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_titlebody_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 |
+
'apple': 'apple.stackexchange.com.jsonl.gz',
|
51 |
+
'english': 'english.stackexchange.com.jsonl.gz',
|
52 |
+
'codereview': 'codereview.stackexchange.com.jsonl.gz',
|
53 |
+
'dba': 'dba.stackexchange.com.jsonl.gz',
|
54 |
+
'mathoverflow': 'mathoverflow.net.jsonl.gz',
|
55 |
+
'electronics': 'electronics.stackexchange.com.jsonl.gz',
|
56 |
+
'mathematica': 'mathematica.stackexchange.com.jsonl.gz',
|
57 |
+
'drupal': 'drupal.stackexchange.com.jsonl.gz',
|
58 |
+
'magento': 'magento.stackexchange.com.jsonl.gz',
|
59 |
+
'gaming': 'gaming.stackexchange.com.jsonl.gz',
|
60 |
+
'ell': 'ell.stackexchange.com.jsonl.gz',
|
61 |
+
'gamedev': 'gamedev.stackexchange.com.jsonl.gz',
|
62 |
+
'gis': 'gis.stackexchange.com.jsonl.gz',
|
63 |
+
'askubuntu': 'askubuntu.com.jsonl.gz',
|
64 |
+
'diy': 'diy.stackexchange.com.jsonl.gz',
|
65 |
+
'academia': 'academia.stackexchange.com.jsonl.gz',
|
66 |
+
'blender': 'blender.stackexchange.com.jsonl.gz',
|
67 |
+
'cs': 'cs.stackexchange.com.jsonl.gz',
|
68 |
+
'chemistry': 'chemistry.stackexchange.com.jsonl.gz',
|
69 |
+
'judaism': 'judaism.stackexchange.com.jsonl.gz',
|
70 |
+
'crypto': 'crypto.stackexchange.com.jsonl.gz',
|
71 |
+
'android': 'android.stackexchange.com.jsonl.gz',
|
72 |
+
'ja': 'ja.stackoverflow.com.jsonl.gz',
|
73 |
+
'christianity': 'christianity.stackexchange.com.jsonl.gz',
|
74 |
+
'graphicdesign': 'graphicdesign.stackexchange.com.jsonl.gz',
|
75 |
+
'aviation': 'aviation.stackexchange.com.jsonl.gz',
|
76 |
+
'ethereum': 'ethereum.stackexchange.com.jsonl.gz',
|
77 |
+
'biology': 'biology.stackexchange.com.jsonl.gz',
|
78 |
+
'datascience': 'datascience.stackexchange.com.jsonl.gz',
|
79 |
+
'law': 'law.stackexchange.com.jsonl.gz',
|
80 |
+
'dsp': 'dsp.stackexchange.com.jsonl.gz',
|
81 |
+
'japanese': 'japanese.stackexchange.com.jsonl.gz',
|
82 |
+
'hermeneutics': 'hermeneutics.stackexchange.com.jsonl.gz',
|
83 |
+
'bicycles': 'bicycles.stackexchange.com.jsonl.gz',
|
84 |
+
'arduino': 'arduino.stackexchange.com.jsonl.gz',
|
85 |
+
'history': 'history.stackexchange.com.jsonl.gz',
|
86 |
+
'bitcoin': 'bitcoin.stackexchange.com.jsonl.gz',
|
87 |
+
'cooking': 'cooking.stackexchange.com.jsonl.gz',
|
88 |
+
'hinduism': 'hinduism.stackexchange.com.jsonl.gz',
|
89 |
+
'codegolf': 'codegolf.stackexchange.com.jsonl.gz',
|
90 |
+
'boardgames': 'boardgames.stackexchange.com.jsonl.gz',
|
91 |
+
'emacs': 'emacs.stackexchange.com.jsonl.gz',
|
92 |
+
'economics': 'economics.stackexchange.com.jsonl.gz',
|
93 |
+
'gardening': 'gardening.stackexchange.com.jsonl.gz',
|
94 |
+
'astronomy': 'astronomy.stackexchange.com.jsonl.gz',
|
95 |
+
'islam': 'islam.stackexchange.com.jsonl.gz',
|
96 |
+
'german': 'german.stackexchange.com.jsonl.gz',
|
97 |
+
'fitness': 'fitness.stackexchange.com.jsonl.gz',
|
98 |
+
'french': 'french.stackexchange.com.jsonl.gz',
|
99 |
+
'anime': 'anime.stackexchange.com.jsonl.gz',
|
100 |
+
'craftcms': 'craftcms.stackexchange.com.jsonl.gz',
|
101 |
+
'cstheory': 'cstheory.stackexchange.com.jsonl.gz',
|
102 |
+
'engineering': 'engineering.stackexchange.com.jsonl.gz',
|
103 |
+
'buddhism': 'buddhism.stackexchange.com.jsonl.gz',
|
104 |
+
'linguistics': 'linguistics.stackexchange.com.jsonl.gz',
|
105 |
+
'ai': 'ai.stackexchange.com.jsonl.gz',
|
106 |
+
'expressionengine': 'expressionengine.stackexchange.com.jsonl.gz',
|
107 |
+
'cogsci': 'cogsci.stackexchange.com.jsonl.gz',
|
108 |
+
'chinese': 'chinese.stackexchange.com.jsonl.gz',
|
109 |
+
'chess': 'chess.stackexchange.com.jsonl.gz',
|
110 |
+
'civicrm': 'civicrm.stackexchange.com.jsonl.gz',
|
111 |
+
'literature': 'literature.stackexchange.com.jsonl.gz',
|
112 |
+
'interpersonal': 'interpersonal.stackexchange.com.jsonl.gz',
|
113 |
+
'health': 'health.stackexchange.com.jsonl.gz',
|
114 |
+
'avp': 'avp.stackexchange.com.jsonl.gz',
|
115 |
+
'earthscience': 'earthscience.stackexchange.com.jsonl.gz',
|
116 |
+
'joomla': 'joomla.stackexchange.com.jsonl.gz',
|
117 |
+
'homebrew': 'homebrew.stackexchange.com.jsonl.gz',
|
118 |
+
'expatriates': 'expatriates.stackexchange.com.jsonl.gz',
|
119 |
+
'latin': 'latin.stackexchange.com.jsonl.gz',
|
120 |
+
'matheducators': 'matheducators.stackexchange.com.jsonl.gz',
|
121 |
+
'ham': 'ham.stackexchange.com.jsonl.gz',
|
122 |
+
'genealogy': 'genealogy.stackexchange.com.jsonl.gz',
|
123 |
+
'3dprinting': '3dprinting.stackexchange.com.jsonl.gz',
|
124 |
+
'elementaryos': 'elementaryos.stackexchange.com.jsonl.gz',
|
125 |
+
'bioinformatics': 'bioinformatics.stackexchange.com.jsonl.gz',
|
126 |
+
'devops': 'devops.stackexchange.com.jsonl.gz',
|
127 |
+
'hsm': 'hsm.stackexchange.com.jsonl.gz',
|
128 |
+
'italian': 'italian.stackexchange.com.jsonl.gz',
|
129 |
+
'computergraphics': 'computergraphics.stackexchange.com.jsonl.gz',
|
130 |
+
'martialarts': 'martialarts.stackexchange.com.jsonl.gz',
|
131 |
+
'bricks': 'bricks.stackexchange.com.jsonl.gz',
|
132 |
+
'freelancing': 'freelancing.stackexchange.com.jsonl.gz',
|
133 |
+
'crafts': 'crafts.stackexchange.com.jsonl.gz',
|
134 |
+
'lifehacks': 'lifehacks.stackexchange.com.jsonl.gz',
|
135 |
+
'cseducators': 'cseducators.stackexchange.com.jsonl.gz',
|
136 |
+
'materials': 'materials.stackexchange.com.jsonl.gz',
|
137 |
+
'hardwarerecs': 'hardwarerecs.stackexchange.com.jsonl.gz',
|
138 |
+
'iot': 'iot.stackexchange.com.jsonl.gz',
|
139 |
+
'eosio': 'eosio.stackexchange.com.jsonl.gz',
|
140 |
+
'languagelearning': 'languagelearning.stackexchange.com.jsonl.gz',
|
141 |
+
'korean': 'korean.stackexchange.com.jsonl.gz',
|
142 |
+
'coffee': 'coffee.stackexchange.com.jsonl.gz',
|
143 |
+
'esperanto': 'esperanto.stackexchange.com.jsonl.gz',
|
144 |
+
'beer': 'beer.stackexchange.com.jsonl.gz',
|
145 |
+
'ebooks': 'ebooks.stackexchange.com.jsonl.gz',
|
146 |
+
'iota': 'iota.stackexchange.com.jsonl.gz',
|
147 |
+
'cardano': 'cardano.stackexchange.com.jsonl.gz',
|
148 |
+
'drones': 'drones.stackexchange.com.jsonl.gz',
|
149 |
+
'conlang': 'conlang.stackexchange.com.jsonl.gz',
|
150 |
+
'pt': 'pt.stackoverflow.com.jsonl.gz',
|
151 |
+
'stats': 'stats.stackexchange.com.jsonl.gz',
|
152 |
+
'unix': 'unix.stackexchange.com.jsonl.gz',
|
153 |
+
'physics': 'physics.stackexchange.com.jsonl.gz',
|
154 |
+
'tex': 'tex.stackexchange.com.jsonl.gz',
|
155 |
+
'serverfault': 'serverfault.com.jsonl.gz',
|
156 |
+
'salesforce': 'salesforce.stackexchange.com.jsonl.gz',
|
157 |
+
'wordpress': 'wordpress.stackexchange.com.jsonl.gz',
|
158 |
+
'softwareengineering': 'softwareengineering.stackexchange.com.jsonl.gz',
|
159 |
+
'scifi': 'scifi.stackexchange.com.jsonl.gz',
|
160 |
+
'security': 'security.stackexchange.com.jsonl.gz',
|
161 |
+
'ru': 'ru.stackoverflow.com.jsonl.gz',
|
162 |
+
'superuser': 'superuser.com.jsonl.gz',
|
163 |
+
'sharepoint': 'sharepoint.stackexchange.com.jsonl.gz',
|
164 |
+
'rpg': 'rpg.stackexchange.com.jsonl.gz',
|
165 |
+
'travel': 'travel.stackexchange.com.jsonl.gz',
|
166 |
+
'worldbuilding': 'worldbuilding.stackexchange.com.jsonl.gz',
|
167 |
+
'meta': 'meta.mathoverflow.net.jsonl.gz',
|
168 |
+
'workplace': 'workplace.stackexchange.com.jsonl.gz',
|
169 |
+
'ux': 'ux.stackexchange.com.jsonl.gz',
|
170 |
+
'money': 'money.stackexchange.com.jsonl.gz',
|
171 |
+
'webmasters': 'webmasters.stackexchange.com.jsonl.gz',
|
172 |
+
'raspberrypi': 'raspberrypi.stackexchange.com.jsonl.gz',
|
173 |
+
'photo': 'photo.stackexchange.com.jsonl.gz',
|
174 |
+
'music': 'music.stackexchange.com.jsonl.gz',
|
175 |
+
'philosophy': 'philosophy.stackexchange.com.jsonl.gz',
|
176 |
+
'puzzling': 'puzzling.stackexchange.com.jsonl.gz',
|
177 |
+
'movies': 'movies.stackexchange.com.jsonl.gz',
|
178 |
+
'quant': 'quant.stackexchange.com.jsonl.gz',
|
179 |
+
'politics': 'politics.stackexchange.com.jsonl.gz',
|
180 |
+
'space': 'space.stackexchange.com.jsonl.gz',
|
181 |
+
'mechanics': 'mechanics.stackexchange.com.jsonl.gz',
|
182 |
+
'skeptics': 'skeptics.stackexchange.com.jsonl.gz',
|
183 |
+
'rus': 'rus.stackexchange.com.jsonl.gz',
|
184 |
+
'writers': 'writers.stackexchange.com.jsonl.gz',
|
185 |
+
'webapps': 'webapps.stackexchange.com.jsonl.gz',
|
186 |
+
'softwarerecs': 'softwarerecs.stackexchange.com.jsonl.gz',
|
187 |
+
'networkengineering': 'networkengineering.stackexchange.com.jsonl.gz',
|
188 |
+
'parenting': 'parenting.stackexchange.com.jsonl.gz',
|
189 |
+
'scicomp': 'scicomp.stackexchange.com.jsonl.gz',
|
190 |
+
'sqa': 'sqa.stackexchange.com.jsonl.gz',
|
191 |
+
'sitecore': 'sitecore.stackexchange.com.jsonl.gz',
|
192 |
+
'vi': 'vi.stackexchange.com.jsonl.gz',
|
193 |
+
'spanish': 'spanish.stackexchange.com.jsonl.gz',
|
194 |
+
'pm': 'pm.stackexchange.com.jsonl.gz',
|
195 |
+
'pets': 'pets.stackexchange.com.jsonl.gz',
|
196 |
+
'sound': 'sound.stackexchange.com.jsonl.gz',
|
197 |
+
'reverseengineering': 'reverseengineering.stackexchange.com.jsonl.gz',
|
198 |
+
'outdoors': 'outdoors.stackexchange.com.jsonl.gz',
|
199 |
+
'tridion': 'tridion.stackexchange.com.jsonl.gz',
|
200 |
+
'retrocomputing': 'retrocomputing.stackexchange.com.jsonl.gz',
|
201 |
+
'robotics': 'robotics.stackexchange.com.jsonl.gz',
|
202 |
+
'quantumcomputing': 'quantumcomputing.stackexchange.com.jsonl.gz',
|
203 |
+
'sports': 'sports.stackexchange.com.jsonl.gz',
|
204 |
+
'russian': 'russian.stackexchange.com.jsonl.gz',
|
205 |
+
'opensource': 'opensource.stackexchange.com.jsonl.gz',
|
206 |
+
'woodworking': 'woodworking.stackexchange.com.jsonl.gz',
|
207 |
+
'patents': 'patents.stackexchange.com.jsonl.gz',
|
208 |
+
'tor': 'tor.stackexchange.com.jsonl.gz',
|
209 |
+
'ukrainian': 'ukrainian.stackexchange.com.jsonl.gz',
|
210 |
+
'opendata': 'opendata.stackexchange.com.jsonl.gz',
|
211 |
+
'monero': 'monero.stackexchange.com.jsonl.gz',
|
212 |
+
'sustainability': 'sustainability.stackexchange.com.jsonl.gz',
|
213 |
+
'portuguese': 'portuguese.stackexchange.com.jsonl.gz',
|
214 |
+
'mythology': 'mythology.stackexchange.com.jsonl.gz',
|
215 |
+
'musicfans': 'musicfans.stackexchange.com.jsonl.gz',
|
216 |
+
'or': 'or.stackexchange.com.jsonl.gz',
|
217 |
+
'poker': 'poker.stackexchange.com.jsonl.gz',
|
218 |
+
'windowsphone': 'windowsphone.stackexchange.com.jsonl.gz',
|
219 |
+
'moderators': 'moderators.stackexchange.com.jsonl.gz',
|
220 |
+
'stackapps': 'stackapps.com.jsonl.gz',
|
221 |
+
'stellar': 'stellar.stackexchange.com.jsonl.gz',
|
222 |
+
'vegetarianism': 'vegetarianism.stackexchange.com.jsonl.gz',
|
223 |
+
'tezos': 'tezos.stackexchange.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 |
+
}
|