# Syntax and Stack Overflow: A methodology for extracting a corpus of   syntax errors and fixes

**Authors:** Alexander William Wong, Amir Salimi, Shaiful Chowdhury, Abram Hindle

arXiv: 1907.07803 · 2019-07-19

## TL;DR

This paper presents a methodology to extract a large, natural corpus of Python syntax errors and fixes from Stack Overflow, addressing the lack of representative datasets for syntax error research.

## Contribution

The authors introduce a novel approach using a Python AST parser and execution validation to create a publicly available dataset of syntax errors and corrections from Stack Overflow.

## Key findings

- Errors from Stack Overflow differ from student errors and random mutations.
- The dataset contains 62,965 Python code snippets with errors and fixes.
- The approach enables the collection of natural, real-world syntax error data.

## Abstract

One problem when studying how to find and fix syntax errors is how to get natural and representative examples of syntax errors. Most syntax error datasets are not free, open, and public, or they are extracted from novice programmers and do not represent syntax errors that the general population of developers would make. Programmers of all skill levels post questions and answers to Stack Overflow which may contain snippets of source code along with corresponding text and tags. Many snippets do not parse, thus they are ripe for forming a corpus of syntax errors and corrections. Our primary contribution is an approach for extracting natural syntax errors and their corresponding human made fixes to help syntax error research. A Python abstract syntax tree parser is used to determine preliminary errors and corrections on code blocks extracted from the SOTorrent data set. We further analyzed our code by executing the corrections in a Python interpreter. We applied our methodology to produce a public data set of 62,965 Python Stack Overflow code snippets with corresponding tags, errors, and stack traces. We found that errors made by Stack Overflow users do not match errors made by student developers or random mutations, implying there is a serious representativeness risk within the field. Finally we share our dataset openly so that future researchers can re-use and extend our syntax errors and fixes.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1907.07803/full.md

## Figures

1 figure with captions in the complete paper: https://tomesphere.com/paper/1907.07803/full.md

## References

14 references — full list in the complete paper: https://tomesphere.com/paper/1907.07803/full.md

---
Source: https://tomesphere.com/paper/1907.07803