Datasets:
Commit
·
bbbfdff
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +230 -0
- dataset_infos.json +1 -0
- dummy/Answers/1.1.0/dummy_data.zip +3 -0
- dummy/Questions/1.1.0/dummy_data.zip +3 -0
- dummy/Tags/1.1.0/dummy_data.zip +3 -0
- so_stacksample.py +180 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- no-annotation
|
4 |
+
language_creators:
|
5 |
+
- crowdsourced
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- cc-by-sa-3-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- n>1M
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- question-answering
|
18 |
+
task_ids:
|
19 |
+
- abstractive-qa
|
20 |
+
- open-domain-qa
|
21 |
+
---
|
22 |
+
|
23 |
+
# Dataset Card for SOStackSample
|
24 |
+
|
25 |
+
## Table of Contents
|
26 |
+
- [Dataset Description](#dataset-description)
|
27 |
+
- [Dataset Summary](#dataset-summary)
|
28 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
29 |
+
- [Languages](#languages)
|
30 |
+
- [Dataset Structure](#dataset-structure)
|
31 |
+
- [Data Instances](#data-instances)
|
32 |
+
- [Data Fields](#data-instances)
|
33 |
+
- [Data Splits](#data-instances)
|
34 |
+
- [Dataset Creation](#dataset-creation)
|
35 |
+
- [Curation Rationale](#curation-rationale)
|
36 |
+
- [Source Data](#source-data)
|
37 |
+
- [Annotations](#annotations)
|
38 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
39 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
40 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
41 |
+
- [Discussion of Biases](#discussion-of-biases)
|
42 |
+
- [Other Known Limitations](#other-known-limitations)
|
43 |
+
- [Additional Information](#additional-information)
|
44 |
+
- [Dataset Curators](#dataset-curators)
|
45 |
+
- [Licensing Information](#licensing-information)
|
46 |
+
- [Citation Information](#citation-information)
|
47 |
+
|
48 |
+
## Dataset Description
|
49 |
+
|
50 |
+
- **Homepage:** https://www.kaggle.com/stackoverflow/stacksample
|
51 |
+
|
52 |
+
### Dataset Summary
|
53 |
+
|
54 |
+
Dataset with the text of 10% of questions and answers from the Stack Overflow programming Q&A website.
|
55 |
+
|
56 |
+
This is organized as three tables:
|
57 |
+
|
58 |
+
Questions contains the title, body, creation date, closed date (if applicable), score, and owner ID for all non-deleted Stack Overflow questions whose Id is a multiple of 10.
|
59 |
+
Answers contains the body, creation date, score, and owner ID for each of the answers to these questions. The ParentId column links back to the Questions table.
|
60 |
+
Tags contains the tags on each of these questions.
|
61 |
+
|
62 |
+
### Supported Tasks and Leaderboards
|
63 |
+
|
64 |
+
Example projects include:
|
65 |
+
|
66 |
+
- Identifying tags from question text
|
67 |
+
- Predicting whether questions will be upvoted, downvoted, or closed based on their text
|
68 |
+
- Predicting how long questions will take to answer
|
69 |
+
- Open Domain Q/A
|
70 |
+
|
71 |
+
### Languages
|
72 |
+
|
73 |
+
English (en) and Programming Languages.
|
74 |
+
|
75 |
+
## Dataset Structure
|
76 |
+
|
77 |
+
### Data Instances
|
78 |
+
|
79 |
+
For Answers:
|
80 |
+
```
|
81 |
+
{
|
82 |
+
"Id": { # Unique ID given to the Answer post
|
83 |
+
"feature_type": "Value",
|
84 |
+
"dtype": "int32"
|
85 |
+
},
|
86 |
+
"OwnerUserId": { # The UserID of the person who generated the Answer on StackOverflow. -1 means NA
|
87 |
+
"feature_type": "Value",
|
88 |
+
"dtype": "int32"
|
89 |
+
},
|
90 |
+
"CreationDate": { # The date the Answer was generated. Follows standard datetime format.
|
91 |
+
"feature_type": "Value",
|
92 |
+
"dtype": "string"
|
93 |
+
},
|
94 |
+
"ParentId": { # Refers to the `Id` of the Question the Answer belong to.
|
95 |
+
"feature_type": "Value",
|
96 |
+
"dtype": "int32"
|
97 |
+
},
|
98 |
+
"Score": { # The sum of up and down votes given to the Answer. Can be negative.
|
99 |
+
"feature_type": "Value",
|
100 |
+
"dtype": "int32"
|
101 |
+
},
|
102 |
+
"Body": { # The body content of the Answer.
|
103 |
+
"feature_type": "Value",
|
104 |
+
"dtype": "string"
|
105 |
+
}
|
106 |
+
}
|
107 |
+
```
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
For Questions:
|
112 |
+
```
|
113 |
+
{
|
114 |
+
"Id": { # Unique ID given to the Question post
|
115 |
+
"feature_type": "Value",
|
116 |
+
"dtype": "int32"
|
117 |
+
},
|
118 |
+
"OwnerUserId": { # The UserID of the person who generated the Question on StackOverflow. -1 means NA.
|
119 |
+
"feature_type": "Value",
|
120 |
+
"dtype": "int32"
|
121 |
+
},
|
122 |
+
"CreationDate": { # The date the Question was generated. Follows standard datetime format.
|
123 |
+
"feature_type": "Value",
|
124 |
+
"dtype": "string"
|
125 |
+
},
|
126 |
+
"ClosedDate": { # The date the Question was generated. Follows standard datetime format. Can be NA.
|
127 |
+
"feature_type": "Value",
|
128 |
+
"dtype": "string"
|
129 |
+
},
|
130 |
+
"Score": { # The sum of up and down votes given to the Question. Can be negative.
|
131 |
+
"feature_type": "Value",
|
132 |
+
"dtype": "int32"
|
133 |
+
},
|
134 |
+
"Title": { # The title of the Question.
|
135 |
+
"feature_type": "Value",
|
136 |
+
"dtype": "string"
|
137 |
+
},
|
138 |
+
"Body": { # The body content of the Question.
|
139 |
+
"feature_type": "Value",
|
140 |
+
"dtype": "string"
|
141 |
+
}
|
142 |
+
}
|
143 |
+
```
|
144 |
+
|
145 |
+
For Tags:
|
146 |
+
```
|
147 |
+
{
|
148 |
+
"Id": { # ID of the Question the tag belongs to
|
149 |
+
"feature_type": "Value",
|
150 |
+
"dtype": "int32"
|
151 |
+
},
|
152 |
+
"Tag": { # The tag name
|
153 |
+
"feature_type": "Value",
|
154 |
+
"dtype": "string"
|
155 |
+
}
|
156 |
+
}
|
157 |
+
```
|
158 |
+
|
159 |
+
`
|
160 |
+
|
161 |
+
### Data Fields
|
162 |
+
|
163 |
+
For Answers:
|
164 |
+
-`Id`: Unique ID given to the Answer post
|
165 |
+
`OwnerUserId`: The UserID of the person who generated the Answer on StackOverflow. -1 means NA
|
166 |
+
"`CreationDate`": The date the Answer was generated. Follows standard datetime format.
|
167 |
+
"`ParentId`": Refers to the `Id` of the Question the Answer belong to.
|
168 |
+
"`Score`": The sum of up and down votes given to the Answer. Can be negative.
|
169 |
+
"`Body`": The body content of the Answer.
|
170 |
+
|
171 |
+
For Questions:
|
172 |
+
- `Id`: Unique ID given to the Question post.
|
173 |
+
- `OwnerUserId`: The UserID of the person who generated the Question on StackOverflow. -1 means NA.
|
174 |
+
- `CreationDate`: The date the Question was generated. Follows standard datetime format.
|
175 |
+
- `ClosedDate`: The date the Question was generated. Follows standard datetime format. Can be NA.
|
176 |
+
- `Score`: The sum of up and down votes given to the Question. Can be negative.
|
177 |
+
- `Title`: {The title of the Question.
|
178 |
+
- `Body`: The body content of the Question.
|
179 |
+
|
180 |
+
For Tags:
|
181 |
+
- `Id`: ID of the Question the tag belongs to.
|
182 |
+
- `Tag`: The tag name.
|
183 |
+
|
184 |
+
## Dataset Creation
|
185 |
+
|
186 |
+
### Curation Rationale
|
187 |
+
|
188 |
+
Datasets of all R questions and all Python questions are also available on Kaggle, but this dataset is especially useful for analyses that span many languages.
|
189 |
+
|
190 |
+
### Source Data
|
191 |
+
|
192 |
+
#### Initial Data Collection and Normalization
|
193 |
+
|
194 |
+
[More Information Needed]
|
195 |
+
|
196 |
+
#### Who are the source language producers?
|
197 |
+
|
198 |
+
StackOverflow Users.
|
199 |
+
|
200 |
+
### Personal and Sensitive Information
|
201 |
+
|
202 |
+
This data contains information that can identify individual users of StackOverflow. The information is self-reported.
|
203 |
+
|
204 |
+
[Needs More Information]
|
205 |
+
|
206 |
+
## Considerations for Using the Data
|
207 |
+
|
208 |
+
### Social Impact of Dataset
|
209 |
+
|
210 |
+
StackOverflow answers are not guarenteed to be safe, secure, or correct. Some answers may purposefully be insecure as is done in this https://stackoverflow.com/a/35571883/5768407 answer from user [`zys`](https://stackoverflow.com/users/5259310/zys), where they show a solution to purposefully bypass Google Play store security checks. Such answers can lead to biased models that use this data and can further propogate unsafe and insecure programming practices.
|
211 |
+
|
212 |
+
[Needs More Information]
|
213 |
+
|
214 |
+
### Discussion of Biases
|
215 |
+
|
216 |
+
[Needs More Information]
|
217 |
+
|
218 |
+
### Other Known Limitations
|
219 |
+
|
220 |
+
[Needs More Information]
|
221 |
+
|
222 |
+
## Additional Information
|
223 |
+
|
224 |
+
### Dataset Curators
|
225 |
+
|
226 |
+
[Needs More Information]
|
227 |
+
|
228 |
+
### Licensing Information
|
229 |
+
|
230 |
+
All Stack Overflow user contributions are licensed under CC-BY-SA 3.0 with attribution required.
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"Answers": {"description": "Dataset with the text of 10% of questions and answers from the Stack Overflow programming Q&A website.\n\nThis is organized as three tables:\n\nQuestions contains the title, body, creation date, closed date (if applicable), score, and owner ID for all non-deleted Stack Overflow questions whose Id is a multiple of 10.\nAnswers contains the body, creation date, score, and owner ID for each of the answers to these questions. The ParentId column links back to the Questions table.\nTags contains the tags on each of these questions\n", "citation": "", "homepage": "https://www.kaggle.com/stackoverflow/stacksample", "license": "All Stack Overflow user contributions are licensed under CC-BY-SA 3.0 with attribution required.", "features": {"Id": {"dtype": "int32", "id": null, "_type": "Value"}, "OwnerUserId": {"dtype": "int32", "id": null, "_type": "Value"}, "CreationDate": {"dtype": "string", "id": null, "_type": "Value"}, "ParentId": {"dtype": "int32", "id": null, "_type": "Value"}, "Score": {"dtype": "int32", "id": null, "_type": "Value"}, "Body": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "so_stack_sample", "config_name": "Answers", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"Answers": {"name": "Answers", "num_bytes": 1583232304, "num_examples": 2014516, "dataset_name": "so_stack_sample"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 1583232304, "size_in_bytes": 1583232304}, "Questions": {"description": "Dataset with the text of 10% of questions and answers from the Stack Overflow programming Q&A website.\n\nThis is organized as three tables:\n\nQuestions contains the title, body, creation date, closed date (if applicable), score, and owner ID for all non-deleted Stack Overflow questions whose Id is a multiple of 10.\nAnswers contains the body, creation date, score, and owner ID for each of the answers to these questions. The ParentId column links back to the Questions table.\nTags contains the tags on each of these questions\n", "citation": "", "homepage": "https://www.kaggle.com/stackoverflow/stacksample", "license": "All Stack Overflow user contributions are licensed under CC-BY-SA 3.0 with attribution required.", "features": {"Id": {"dtype": "int32", "id": null, "_type": "Value"}, "OwnerUserId": {"dtype": "int32", "id": null, "_type": "Value"}, "CreationDate": {"dtype": "string", "id": null, "_type": "Value"}, "ClosedDate": {"dtype": "string", "id": null, "_type": "Value"}, "Score": {"dtype": "int32", "id": null, "_type": "Value"}, "Title": {"dtype": "string", "id": null, "_type": "Value"}, "Body": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "so_stack_sample", "config_name": "Questions", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"Questions": {"name": "Questions", "num_bytes": 1913896893, "num_examples": 1264216, "dataset_name": "so_stack_sample"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 1913896893, "size_in_bytes": 1913896893}, "Tags": {"description": "Dataset with the text of 10% of questions and answers from the Stack Overflow programming Q&A website.\n\nThis is organized as three tables:\n\nQuestions contains the title, body, creation date, closed date (if applicable), score, and owner ID for all non-deleted Stack Overflow questions whose Id is a multiple of 10.\nAnswers contains the body, creation date, score, and owner ID for each of the answers to these questions. The ParentId column links back to the Questions table.\nTags contains the tags on each of these questions\n", "citation": "", "homepage": "https://www.kaggle.com/stackoverflow/stacksample", "license": "All Stack Overflow user contributions are licensed under CC-BY-SA 3.0 with attribution required.", "features": {"Id": {"dtype": "int32", "id": null, "_type": "Value"}, "Tag": {"dtype": "string", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "so_stack_sample", "config_name": "Tags", "version": {"version_str": "1.1.0", "description": null, "major": 1, "minor": 1, "patch": 0}, "splits": {"Tags": {"name": "Tags", "num_bytes": 58816824, "num_examples": 3750994, "dataset_name": "so_stack_sample"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 58816824, "size_in_bytes": 58816824}}
|
dummy/Answers/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:94a417b2c5b794569075108865310f04258a40daea27eef4d1f391222f94cfbc
|
3 |
+
size 821
|
dummy/Questions/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:491ee494ed05f466bd52263dac6a8b5b3efd8369b345cd354bb2d51385c1382c
|
3 |
+
size 1278
|
dummy/Tags/1.1.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:421a28ed68c8152f45eda6ace5e0deae3a38258a5de7d4a369f49eac3bd0b4e3
|
3 |
+
size 352
|
so_stacksample.py
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors, Stack Overflow, the authors of the questions and answers, and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""StackSample: 10% of Stack Overflow Q&A"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import csv
|
20 |
+
import os
|
21 |
+
|
22 |
+
import datasets
|
23 |
+
|
24 |
+
|
25 |
+
_DESCRIPTION = """\
|
26 |
+
Dataset with the text of 10% of questions and answers from the Stack Overflow programming Q&A website.
|
27 |
+
|
28 |
+
This is organized as three tables:
|
29 |
+
|
30 |
+
Questions contains the title, body, creation date, closed date (if applicable), score, and owner ID for all non-deleted Stack Overflow questions whose Id is a multiple of 10.
|
31 |
+
Answers contains the body, creation date, score, and owner ID for each of the answers to these questions. The ParentId column links back to the Questions table.
|
32 |
+
Tags contains the tags on each of these questions.
|
33 |
+
"""
|
34 |
+
|
35 |
+
_HOMEPAGE = "https://www.kaggle.com/stackoverflow/stacksample"
|
36 |
+
|
37 |
+
_LICENSE = "All Stack Overflow user contributions are licensed under CC-BY-SA 3.0 with attribution required."
|
38 |
+
|
39 |
+
|
40 |
+
class SOStackSample(datasets.GeneratorBasedBuilder):
|
41 |
+
"""StackSample: 10% of Stack Overflow Q&A"""
|
42 |
+
|
43 |
+
VERSION = datasets.Version("1.1.0")
|
44 |
+
|
45 |
+
BUILDER_CONFIGS = [
|
46 |
+
datasets.BuilderConfig(
|
47 |
+
name="Answers",
|
48 |
+
version=VERSION,
|
49 |
+
description="This part of the dataset contains only posts that are answers.",
|
50 |
+
),
|
51 |
+
datasets.BuilderConfig(
|
52 |
+
name="Questions",
|
53 |
+
version=VERSION,
|
54 |
+
description="This part of the dataset contains only posts that are questions.",
|
55 |
+
),
|
56 |
+
datasets.BuilderConfig(
|
57 |
+
name="Tags",
|
58 |
+
version=VERSION,
|
59 |
+
description="This part of the dataset contains only tags of the questions in the question part of the StackSample dataset.",
|
60 |
+
),
|
61 |
+
]
|
62 |
+
|
63 |
+
@property
|
64 |
+
def manual_download_instructions(self):
|
65 |
+
return """\
|
66 |
+
You must have a kaggle account. Go to https://www.kaggle.com/stackoverflow/stacksample
|
67 |
+
and manually download the language of your interest. Once it is downloaded,
|
68 |
+
go to the place where you downloaded it and unzip the folder. Three files named
|
69 |
+
`Answers.csv`, `Questions.csv`, and `Tags.csv` will have appeared in your Downloads folder
|
70 |
+
or whichever folder your browser chooses to save files to.
|
71 |
+
so_stacksample can then be loaded using the following command
|
72 |
+
`datasets.load_dataset("so_stacksample", "<csv_file_name>",data_dir="<path/to/folder>")`,
|
73 |
+
where `<path/to/folder> is the path to the unzipped folder. Example if you downloaded
|
74 |
+
and unzipped the folder in your downloads folder:
|
75 |
+
`datasets.load_dataset("so_stacksample", "Answers", data_dir="/home/<user>/Downloads")`
|
76 |
+
will load the `Answers.csv` dataset.
|
77 |
+
"""
|
78 |
+
|
79 |
+
def _info(self):
|
80 |
+
if self.config.name == "Answers": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
81 |
+
features = datasets.Features(
|
82 |
+
{
|
83 |
+
"Id": datasets.Value("int32"),
|
84 |
+
"OwnerUserId": datasets.Value("int32"),
|
85 |
+
"CreationDate": datasets.Value("string"),
|
86 |
+
"ParentId": datasets.Value("int32"),
|
87 |
+
"Score": datasets.Value("int32"),
|
88 |
+
"Body": datasets.Value("string"),
|
89 |
+
}
|
90 |
+
)
|
91 |
+
elif self.config.name == "Questions":
|
92 |
+
features = datasets.Features(
|
93 |
+
{
|
94 |
+
"Id": datasets.Value("int32"),
|
95 |
+
"OwnerUserId": datasets.Value("int32"),
|
96 |
+
"CreationDate": datasets.Value("string"),
|
97 |
+
"ClosedDate": datasets.Value("string"),
|
98 |
+
"Score": datasets.Value("int32"),
|
99 |
+
"Title": datasets.Value("string"),
|
100 |
+
"Body": datasets.Value("string"),
|
101 |
+
}
|
102 |
+
)
|
103 |
+
else:
|
104 |
+
features = datasets.Features(
|
105 |
+
{
|
106 |
+
"Id": datasets.Value("int32"),
|
107 |
+
"Tag": datasets.Value("string"),
|
108 |
+
}
|
109 |
+
)
|
110 |
+
return datasets.DatasetInfo(
|
111 |
+
description=_DESCRIPTION,
|
112 |
+
features=features,
|
113 |
+
supervised_keys=None,
|
114 |
+
homepage=_HOMEPAGE,
|
115 |
+
license=_LICENSE,
|
116 |
+
)
|
117 |
+
|
118 |
+
def _split_generators(self, dl_manager):
|
119 |
+
"""Returns SplitGenerators."""
|
120 |
+
path_to_manual_file = os.path.join(
|
121 |
+
os.path.abspath(os.path.expanduser(dl_manager.manual_dir)), self.config.name + ".csv"
|
122 |
+
)
|
123 |
+
if not os.path.exists(path_to_manual_file):
|
124 |
+
raise FileNotFoundError(
|
125 |
+
"{} does not exist. Make sure you insert a manual dir via `datasets.load_dataset('so_stacksample', '{}', data_dir=...)` that includes a file name {}. Manual download instructions: \n{})".format(
|
126 |
+
path_to_manual_file, self.config.name, self.config.name + ".csv", self.manual_download_instructions
|
127 |
+
)
|
128 |
+
)
|
129 |
+
|
130 |
+
return [
|
131 |
+
datasets.SplitGenerator(
|
132 |
+
name=self.config.name,
|
133 |
+
gen_kwargs={
|
134 |
+
"filepath": path_to_manual_file,
|
135 |
+
"split": self.config.name,
|
136 |
+
},
|
137 |
+
),
|
138 |
+
]
|
139 |
+
|
140 |
+
def _generate_examples(self, filepath, split):
|
141 |
+
""" Yields examples. """
|
142 |
+
# This method will receive as arguments the `gen_kwargs` defined in the previous `_split_generators` method.
|
143 |
+
# It is in charge of opening the given file and yielding (key, example) tuples from the dataset
|
144 |
+
# The key is not important, it's more here for legacy reason (legacy from tfds)
|
145 |
+
|
146 |
+
with open(filepath, encoding="ISO-8859-1") as f:
|
147 |
+
csv_reader = csv.reader(f, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True)
|
148 |
+
next(csv_reader, None)
|
149 |
+
for row_id, row in enumerate(csv_reader):
|
150 |
+
if split == "Answers":
|
151 |
+
id_, owner_user_id, creation_date, parent_id, score, body = row
|
152 |
+
if owner_user_id == "NA":
|
153 |
+
owner_user_id = -1 # Set N/A's to default -1 value
|
154 |
+
yield row_id, {
|
155 |
+
"Id": id_,
|
156 |
+
"OwnerUserId": owner_user_id,
|
157 |
+
"CreationDate": creation_date,
|
158 |
+
"ParentId": parent_id,
|
159 |
+
"Score": score,
|
160 |
+
"Body": body,
|
161 |
+
}
|
162 |
+
elif split == "Questions":
|
163 |
+
id_, owner_user_id, creation_date, closed_date, score, title, body = row
|
164 |
+
if owner_user_id == "NA":
|
165 |
+
owner_user_id = -1 # Set N/A's to default -1 value
|
166 |
+
yield row_id, {
|
167 |
+
"Id": id_,
|
168 |
+
"OwnerUserId": owner_user_id,
|
169 |
+
"CreationDate": creation_date,
|
170 |
+
"ClosedDate": closed_date,
|
171 |
+
"Score": score,
|
172 |
+
"Title": title,
|
173 |
+
"Body": body,
|
174 |
+
}
|
175 |
+
else:
|
176 |
+
id_, tag = row
|
177 |
+
yield row_id, {
|
178 |
+
"Id": id_,
|
179 |
+
"Tag": tag,
|
180 |
+
}
|