SmartPaste: Learning to Adapt Source Code
By Miltiadis Allamanis, Marc Brockschmidt. 2017
24 citations recorded by the source corpus.
Deep Neural Networks have been shown to succeed at a range of natural language tasks such as machine translation and text summarization. While tasks on source code (ie, formal languages) have been considered recently, most work in this area does not attempt to capitalize on the unique opportunities offered by its known syntax and structure. In this work, we introduce SmartPaste, a first task that requires to use such information. The task is a variant of the program repair problem that requires to adapt a given (pasted) snippet of code to surrounding, existing source code. As first solutions, we design a set of deep neural models that learn to represent the context of each variable location and variable usage in a data flow-sensitive way. Our evaluation suggests that our models can learn to solve the SmartPaste task in many cases, achieving 58.6% accuracy, while learning meaningful representation of variable usages.
Subfields: Information Systems, Information Systems and Management, Natural Language Processing
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Information Systems
- Charles Sutton
- Miltiadis Allamanis
- Michael Pradel
- Earl T. Barr
- Koushik Sen
- Premkumar T. Devanbu
- Rafael-Michael Karampatsis
- Rishabh Singh
In Information Systems and Management
- Koushik Sen
- Michael Pradel
- Tal Ben-Nun
- Alice Shoshana Jakobovits
- Torsten Hoefler
- Rohan Bavishi
- Premkumar T. Devanbu
- Miltiadis Allamanis
In Natural Language Processing
- Charles Sutton
- Miltiadis Allamanis
- Michael Pradel
- Premkumar T. Devanbu
- Earl T. Barr
- Koushik Sen
- Rafael-Michael Karampatsis
- Rohan Bavishi
Citations in the corpus
- A Survey of Machine Learning for Big Code and Naturalness (2017, background): “Allamanis and Brockschmidt [7] automate naming cleanups after copying; they use structured prediction and distributed representations to adapt/port a pasted snippet’s variables into the target context.”
- DeepBugs: a learning approach to name-based bug detection (2018, background): “Deep neural networks also help recommend API usages [Gu et al. 2016], detect code clones [White et al. 2016], classify programs into pre-defined categories [Mou et al. 2016], and adapt copied-and-pasted code to its surrounding code [Allamanis and Brockschmidt 2017].”
- WILDS: A Benchmark of in-the-Wild Distribution Shifts (2020, neutral): “One major challenge is the shifts across code bases, where systems need to adapt to the project content, coding convention, and library or API usage, etc. in each code base (Nita and Notkin, 2010; Allamanis and Brockschmidt, 2017).”
- Context2Name: A Deep Learning-Based Approach to Infer Natural Variable Names from Usage Contexts (2017, methodology): “Sequences of lexical tokens are also used by the SmartPaste framework [2] which is designed to assist a developer in extending an existing code base with snippets, by attempting to align the variables in the added snippet with the rest of the code.”
- Neural Code Comprehension: A Learnable Representation of Code Semantics (2018, methodology): “For NLP-based approaches, input code is usually processed into tokens (e.g., keywords, braces) [18] or other representations [4, 7, 53], and optionally undergoes embedding in a continuous lower-dimensional space.”
- Deep Learning to Find Bugs (2017, background): “Deep neural networks also help recommendAPI usages [13], detect code clones [44], classify programs into pre-defined categories [26], and adapt copied-and-pasted code to its surrounding code [4].”