Learning to Update Natural Language Comments Based on Code Changes
38112Authors
nan
Abstract
AbstractWe formulate the novel task of automatically updating an existing natural language comment based on changes in the body of code it accompanies. We propose an approach that learns to correlate changes across two distinct language representations, to generate a sequence of edits that are applied to the existing comment to reflect the source code modifications. We train and evaluate our model using a dataset that we collected from commit histories of open-source software projects, with each example consisting of a concurrent update to a method and its corresponding comment. We compare our approach against multiple baselines using both automatic metrics and human evaluation. Results reflect the challenge of this task and that our model outperforms baselines with respect to making edits.
Keywords
Full Content
Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 1853–1868 July 5 - 10, 2020. c⃝2020 Association for Computational Linguistics 1853 Learning to Update Natural Language Comments Based on Code Changes Sheena Panthaplackel1, Pengyu Nie2, Milos Gligoric2, Junyi Jessy Li3, Raymond J. Mooney1 1Department of Computer Science 2Department of Electrical and Computer Engineering 3Department of Linguistics The University of Texas at Austin spantha@cs.utexas.edu, pynie@utexas.edu, gligoric@utexas.edu, jessy@austin.utexas.edu, mooney@cs.utexas.edu Abstract We formulate the novel task of automatically updating an existing natural language com- ment based on changes in the body of code it accompanies. We propose an approach that learns to correlate changes across two dis- tinct language representations, to generate a se- quence of edits that are applied to the existing comment to reflect the source code modifica- tions. We train and evaluate our model using a dataset that we collected from commit his- tories of open-source software projects, with each example consisting of a concurrent up- date to a method and its corresponding com- ment. We compare our approach against mul- tiple baselines using both automatic metrics and human evaluation. Results reflect the chal- lenge of this task and that our model outper- forms baselines with respect to making edits. 1 Introduction Software developers include natural language com- ments alongside source code as a way to docu- ment various aspects of the code such as function- ality, use cases, pre-conditions, and post-conditions. With the growing popularity of open-source soft- ware that is widely used and jointly developed, the need for efficient communication among develop- ers about code details has increased. Consequently, comments have assumed a vital role in the devel- opment cycle. With developers regularly refactor- ing and iteratively incorporating new functionality, source code is constantly evolving; however, the accompanying comments are not always updated to reflect the code changes (Tan et al., 2007; Ratol and Robillard, 2017). Inconsistency between code and comments can not only lead time-wasting con- fusion in tight project schedules (Hu et al., 2018) but can also result in bugs (Tan et al., 2007). To address this problem, we propose an approach that can automatically suggest comment updates when the associated methods are changed. /**@return double the roll euler angle.*/ public double getRotX() { return mOrientation.getRotationX(); } Previous Version /**@return double the roll euler angle in degrees.*/ public double getRotX() { return Math.toDegrees(mOrientation.getRotationX()); } Updated Version Figure 1: Changes in the getRotX method and its corre- sponding @return comment between two subsequent com- mits of the rajawali-rajawali project, available on GitHub. Prior work explored rule-based approaches for detecting inconsistencies for a limited set of cases; however, they do not present ways to automatically fix these inconsistencies (Tan et al., 2007; Ratol and Robillard, 2017). Recent work in automatic comment generation aims to generate a comment given a code representation (Liang and Zhu, 2018; Hu et al., 2018; Fernandes et al., 2019); although these techniques could be used to produce a com- pletely new comment that corresponds to the most recent version of …
Content truncated to 500 words
Labeled Text
AbstractWe formulate the novel task of automatically updating an existing natural language comment based on changes in the body of code it accompanies. We propose an approach that learns to correlate changes across two distinct language representations, to generate a sequence of edits that are applied to the existing comment to reflect the source code modifications. We train and evaluate our model using a dataset that we collected from commit histories of open-source software projects, with each example consisting of a concurrent update to a method and its corresponding comment. We compare our approach against multiple baselines using both automatic metrics and human evaluation. Results reflect the challenge of this task and that our model outperforms baselines with respect to making edits.
Publication Details
- Paper ID:
- 38112
- Year:
- 2020
- Publication:
- TIPSTER
- Publication Type:
- conf
- DOI:
- nan