On the Significance of Category Prediction for Code-Comment Synchronization

Author:

Yang Zhen1ORCID,Keung Jacky Wai1ORCID,Yu Xiao2ORCID,Xiao Yan3ORCID,Jin Zhi4ORCID,Zhang Jingyu1ORCID

Affiliation:

1. Department of Computer Science, City University of Hong Kong, Hong Kong, China

2. School of Computer Science and Artificial Intelligence, Wuhan University of Technology, and Software Engineering Application Technology Lab, Huawei, Wuhan, Hubei, China

3. School of Computing, National University of Singapore, Singapore

4. Key Laboratory of High Confidence Software Technologies, Ministry of Education, and School of Computer Science, Peking University, Beijing, China

Abstract

Software comments sometimes are not promptly updated in sync when the associated code is changed. The inconsistency between code and comments may mislead the developers and result in future bugs. Thus, studies concerning code-comment synchronization have become highly important, which aims to automatically synchronize comments with code changes. Existing code-comment synchronization approaches mainly contain two types, i.e., (1) deep learning-based (e.g., CUP), and (2) heuristic-based (e.g., HebCUP). The former constructs a neural machine translation-structured semantic model, which has a more generalized capability on synchronizing comments with software evolution and growth. However, the latter designs a series of rules for performing token-level replacements on old comments, which can generate the completely correct comments for the samples fully covered by their fine-designed heuristic rules. In this article, we propose a composite approach named CBS (i.e., Classifying Before Synchronizing ) to further improve the code-comment synchronization performance, which combines the advantages of CUP and HebCUP with the assistance of inferred categories of Code-Comment Inconsistent (CCI) samples. Specifically, we firstly define two categories (i.e., heuristic-prone and non-heuristic-prone) for CCI samples and propose five features to assist category prediction. The samples whose comments can be correctly synchronized by HebCUP are heuristic-prone, while others are non-heuristic-prone. Then, CBS employs our proposed Multi-Subsets Ensemble Learning (MSEL) classification algorithm to alleviate the class imbalance problem and construct the category prediction model. Next, CBS uses the trained MSEL to predict the category of the new sample. If the predicted category is heuristic-prone, CBS employs HebCUP to conduct the code-comment synchronization for the sample, otherwise, CBS allocates CUP to handle it. Our extensive experiments demonstrate that CBS statistically significantly outperforms CUP and HebCUP, and obtains an average improvement of 23.47%, 22.84%, 3.04%, 3.04%, 1.64%, and 19.39% in terms of Accuracy, Recall@5, Average Edit Distance (AED) , Relative Edit Distance (RED) , BLEU-4, and Effective Synchronized Sample (ESS) ratio, respectively, which highlights that category prediction for CCI samples can boost the code-comment synchronization performance.

Funder

General Research Fund

Research Grants Council of Hong Kong

City University of Hong Kong

National Natural Science Foundation of China

Singapore National Research Foundation and National University of Singapore

National Satellite of Excellence in Trustworthy Software Systems

Trustworthy Software Systems Core Technologies Grant

The Natural Science Foundation of Chongqing City

Publisher

Association for Computing Machinery (ACM)

Subject

Software

Reference100 articles.

1. 2018. A Commit in Apache Wicket. https://github.com/apache/wicket/pull/283/commits/8dcf2e34927e0c164235f5bea79c7026d22192dc. (Accessed on 02/24/2022).

2. 2019. A Commit in Google Nomulus. https://github.com/google/nomulus/commit/cf507dad6d7bfc9e30eb520da0c08a75d054b2bd. (Accessed on 02/24/2022).

3. 2022. apache/hive: Apache Hive. https://github.com/apache/hive. (Accessed on 02/25/2022).

4. 2022. Difflib – Helpers for Computing Deltas – Python 3.10.2 Documentation. https://docs.python.org/3/library/difflib.html. (Accessed on 03/07/2022).

5. 2022. Facebook/fresco: An Android Library for Managing Images and the Memory They Use. https://github.com/facebook/fresco. (Accessed on 02/25/2022).

Cited by 17 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3