Learning the Relation between Code Features and Code Transforms with Structured Prediction
arXiv:1907.09282 · doi:10.1109/TSE.2023.3275380
Abstract
To effectively guide the exploration of the code transform space for automated code evolution techniques, we present in this paper the first approach for structurally predicting code transforms at the level of AST nodes using conditional random fields (CRFs). Our approach first learns offline a probabilistic model that captures how certain code transforms are applied to certain AST nodes, and then uses the learned model to predict transforms for arbitrary new, unseen code snippets. {Our approach involves a novel representation of both programs and code transforms. Specifically, we introduce the formal framework for defining the so-called AST-level code transforms and we demonstrate how the CRF model can be accordingly designed, learned, and used for prediction}. We instantiate our approach in the context of repair transform prediction for Java programs. Our instantiation contains a set of carefully designed code features, deals with the training data imbalance issue, and comprises transform constraints that are specific to code. We conduct a large-scale experimental evaluation based on a dataset of bug fixing commits from real-world Java projects. The results show that when the popular evaluation metric \emph{top-3} is used, our approach predicts the code transforms with an accuracy varying from 41\% to 53\% depending on the transforms. Our model outperforms two baselines based on history probability and neural machine translation (NMT), suggesting the importance of considering code structure in achieving good prediction accuracy. In addition, a proof-of-concept synthesizer is implemented to concretize some repair transforms to get the final patches. The evaluation of the synthesizer on the Defects4j benchmark confirms the usefulness of the predicted AST-level repair transforms in producing high-quality patches.
References in corpus (22)
- SMOTE: Synthetic Minority Over-sampling Technique
- Efficient Estimation of Word Representations in Vector Space
- Graph Neural Networks: A Review of Methods and Applications
- SequenceR: Sequence-to-Sequence Learning for End-to-End Program Repair
- Automatic Software Repair: a Bibliography
- CURE: Code-Aware Neural Machine Translation for Automatic Program Repair
- Elixir: Effective object-oriented program repair
- FixMiner: Mining Relevant Fix Patterns for Automated Program Repair
- SWIM: Synthesizing What I Mean
- On the Efficiency of Test Suite based Program Repair: A Systematic Assessment of 16 Automated Repair Systems for Java Programs
- CODIT: Code Editing with Tree-Based Neural Models
- On Learning Meaningful Assert Statements for Unit Test Cases
- Typilus: Neural Type Hints
- Learning to Represent Edits
- Alleviating Patch Overfitting with Automatic Test Generation: A Study of Feasibility and Effectiveness for the Nopol Repair System
- Code Vectors: Understanding Programs Through Embedded Abstracted Symbolic Traces
- Neural Sketch Learning for Conditional Program Generation
- Learning to Generate Corrective Patches using Neural Machine Translation
- Path-Based Function Embedding and its Application to Specification Mining
- Towards an automated approach for bug fix pattern detection
- A Syntax-Guided Edit Decoder for Neural Program Repair
- sk_p: a neural program corrector for MOOCs