|
--- |
|
configs: |
|
- config_name: default |
|
data_files: |
|
- split: train |
|
path: "stackoverflow/train_clean.csv" |
|
- config_name: raw |
|
data_files: |
|
- split: train |
|
path: "stackoverflow/train.csv" |
|
--- |
|
|
|
# StackExchange Dataset |
|
|
|
Working doc: https://docs.google.com/document/d/1h585bH5sYcQW4pkHzqWyQqA4ape2Bq6o1Cya0TkMOQc/edit?usp=sharing |
|
|
|
<!-- 1. We run the following query on StackExchange Data Explorer (note that this can be done programmatically using BigQuery for the StackOverflow site, but not the other sites) |
|
``` |
|
SELECT * |
|
FROM Posts p |
|
WHERE p.PostTypeId = 2 |
|
AND LOWER(p.Body) LIKE '%arxiv%' |
|
``` |
|
|
|
2. Download the csv results |
|
|
|
3. |
|
|
|
``` |
|
CREATE TEMPORARY TABLE answers AS |
|
SELECT * |
|
FROM Posts |
|
WHERE PostTypeId = 2 |
|
AND LOWER(a.Body) LIKE '%arxiv%' |
|
|
|
CREATE TEMPORARY TABLE questions AS |
|
SELECT * |
|
FROM Posts |
|
WHERE PostTypeId = 1; |
|
|
|
SELECT * |
|
FROM answers a |
|
JOIN questions q ON q.Id = a.ParentId |
|
``` --> |
|
|
|
BigQuery query (see [so_bigquery.ipynb](so_bigquery.ipynb)): |
|
``` |
|
CREATE TEMP TABLE answers AS |
|
SELECT * |
|
FROM bigquery-public-data.stackoverflow.posts_answers |
|
WHERE LOWER(Body) LIKE '%arxiv%'; |
|
|
|
CREATE TEMPORARY TABLE questions AS |
|
SELECT * |
|
FROM bigquery-public-data.stackoverflow.posts_questions; |
|
|
|
SELECT * |
|
FROM answers |
|
JOIN questions ON questions.id = answers.parent_id; |
|
``` |
|
|
|
NOTE: BigQuery only has the StackOverflow site data, not the other sites. |
|
So if we want to query the other sites, we would probably want to download the data dump to a cluster and run a SQL server. |
|
|
|
Columns in the raw query output: |
|
``` |
|
'id', |
|
'title', |
|
'body', |
|
'accepted_answer_id', |
|
'answer_count', |
|
'comment_count', |
|
'community_owned_date', # present only if post is community wiki'd |
|
'creation_date', |
|
'favorite_count', |
|
'last_activity_date', |
|
'last_edit_date', |
|
'last_editor_display_name', |
|
'last_editor_user_id', |
|
'owner_display_name', |
|
'owner_user_id', |
|
'parent_id', # if post is answer, then this is the question id; if post is question, this is None |
|
'post_type_id', # 1 = QUESTION, 2 = ANSWER |
|
'score', |
|
'tags', |
|
'view_count', |
|
``` |
|
|
|
(Official database schema)[https://meta.stackexchange.com/questions/2677/database-schema-documentation-for-the-public-data-dump-and-sede/2678#2678] |
|
|
|
## File structure |
|
|
|
Each folder represents the different StackExchange [sites](https://stackexchange.com/sites#oldest) (~182). The largest one is StackOverflow. |