Publication Type
Journal Article
Version
publishedVersion
Publication Date
1-2021
Abstract
Code summarization aims at generating a code comment given a block of source code and it is normally performed by training machine learning algorithms on existing code block-comment pairs. Code comments in practice have different intentions. For example, some code comments might explain how the methods work, while others explain why some methods are written. Previous works have shown that a relationship exists between a code block and the category of a comment associated with it. In this article, we aim to investigate to which extent we can exploit this relationship to improve code summarization performance. We first classify comments into six intention categories and manually label 20,000 code-comment pairs. These categories include “what,” “why,” “how-to-use,” “how-it-is-done,” “property,” and “others.” Based on this dataset, we conduct an experiment to investigate the performance of different state-of-the-art code summarization approaches on the categories. We find that the performance of different code summarization approaches varies substantially across the categories. Moreover, the category for which a code summarization model performs the best is different for the different models. In particular, no models perform the best for “why” and “property” comments among the six categories. We design a composite approach to demonstrate that comment category prediction can boost code summarization to reach better results. The approach leverages classified code-category labeled data to train a classifier to infer categories. Then it selects the most suitable models for inferred categories and outputs the composite results. Our composite approach outperforms other approaches that do not consider comment categories and obtains a relative improvement of 8.57% and 16.34% in terms of ROUGE-L and BLEU-4 score, respectively.
Keywords
Code summarization, code comment, comment classification
Discipline
Databases and Information Systems | Software Engineering
Research Areas
Data Science and Engineering
Publication
ACM Transactions on Software Engineering and Methodology
Volume
30
Issue
2
First Page
1
Last Page
29
ISSN
1049-331X
Identifier
10.1145/3434280
Publisher
Association for Computing Machinery (ACM)
Citation
CHEN, Qiuyuan; XIA, Xin; HU, Han; LO, David; and LI, Shanping.
Why my code summarization model does not Work: Code comment improvement with category prediction. (2021). ACM Transactions on Software Engineering and Methodology. 30, (2), 1-29.
Available at: https://ink.library.smu.edu.sg/sis_research/6706
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-No Derivative Works 4.0 International License.