Back to Search Start Over

EditSum: A Retrieve-and-Edit Framework for Source Code Summarization

Authors :
Li, Jia
Li, Yongmin
Li, Ge
Hu, Xing
Xia, Xin
Jin, Zhi
Publication Year :
2023

Abstract

Existing studies show that code summaries help developers understand and maintain source code. Unfortunately, these summaries are often missing or outdated in software projects. Code summarization aims to generate natural language descriptions automatically for source code. Code summaries are highly structured and have repetitive patterns. Besides the patternized words, a code summary also contains important keywords, which are the key to reflecting the functionality of the code. However, the state-of-the-art approaches perform poorly on predicting the keywords, which leads to the generated summaries suffering a loss in informativeness. To alleviate this problem, this paper proposes a novel retrieve-and-edit approach named EditSum for code summarization. Specifically, EditSum first retrieves a similar code snippet from a pre-defined corpus and treats its summary as a prototype summary to learn the pattern. Then, EditSum edits the prototype automatically to combine the pattern in the prototype with the semantic information of input code. Our motivation is that the retrieved prototype provides a good start-point for post-generation because the summaries of similar code snippets often have the same pattern. The post-editing process further reuses the patternized words in the prototype and generates keywords based on the semantic information of input code. We conduct experiments on a large-scale Java corpus and experimental results demonstrate that EditSum outperforms the state-of-the-art approaches by a substantial margin. The human evaluation also proves the summaries generated by EditSum are more informative and useful. We also verify that EditSum performs well on predicting the patternized words and keywords.<br />Comment: Accepted by the 36th IEEE/ACM International Conference on Automated Software Engineering (ASE 2021)

Details

Database :
arXiv
Publication Type :
Report
Accession number :
edsarx.2308.13775
Document Type :
Working Paper
Full Text :
https://doi.org/10.1109/ASE51524.2021.9678724