一句话:提出检索-编辑框架 EditSum,利用相似代码摘要原型并自动编辑,提升代码摘要的信息量与关键词预测。
代码摘要能帮助开发者理解和维护源代码,但项目中摘要常缺失或过时,自动生成摘要因此重要。已有研究表明代码摘要高度模式化,同时包含反映代码功能的关键词,而现有方法在关键词预测上表现不佳,导致生成摘要信息量不足。为此,本文提出检索-编辑式方法 EditSum:先从预定义语料中检索相似代码片段,将其摘要作为原型以学习模式,再自动编辑该原型,把原型中的模式化表达与输入代码的语义信息结合,从而生成关键词并复用模式化短语。作者在 200 万规模 Java 语料上实验,结果表明 EditSum 显著优于当前最佳方法;人工评估也表明生成摘要更具信息量和实用性,并验证了其在模式化词和关键词预测上的良好表现。
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. According to Gros et al., code summaries are highly structured and have repetitive patterns (e.g. "return true if..."). 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 suffer 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 prototype and generates keywords based on the semantic information of input code. We conduct experiments on a large-scale Java corpus (2M) 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.
@inproceedings{paperbot6507,
title = {EditSum: A Retrieve-and-Edit Framework for Source Code Summarization},
author = {Jia Allen Li and Yongmin Li and Ge Li and Xing Hu and Xin Xia and Zhi Jin},
booktitle = {ASE},
year = {2021},
doi = {10.1109/ase51524.2021.9678724}
}