arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.01645cs.SEcs.CLcs.LG
收藏

APIContext2Com:通过验证预定义的API文档生成代码注释

APIContext2Com: Code Comment Generation by Incorporating Pre-Defined API Documentation

University of British Columbia Okanagan(不列颠哥伦比亚大学奥肯那根分校)

Ramin Shahbazi, Fatemeh Fard

摘要:

代码注释对理解软件程序有很大的帮助,也可以帮助开发人员节省大量的软件维护时间。代码注释生成的目的是自动预测给定代码片段的自然语言中的注释。一些作品调查的影响,整合外部知识的质量生成的评论。在这项研究中,我们提出了一个解决方案,即APIContext 2Com,通过将预定义的应用程序编程接口(API)上下文,以提高生成的评论的有效性。API上下文包括在代码片段中使用的预定义API的定义和描述。由于详细的API信息表达了代码段的功能,因此它有助于更好地生成代码摘要。我们引入了一个seq-2-seq编码器-解码器神经网络模型,该模型具有不同的多个编码器集合,以有效地将不同的输入转换为目标评论。还开发了一个排名机制来排除非信息性的API,以便我们可以过滤掉不相关的API。我们使用CodeSearchNet的Java数据集来评估我们的方法。结果表明,该模型对BLEU 1、BLEU 2、BLEU 3、BLEU 4、METEOR、ROUGE-L的最佳基线分别提高了1.88(8.24%)、2.16(17.58%)、1.38(18.3%)、0.73(14.17%)、1.58(14.98%)和1.9(6.92%)。人类评估和消融研究证实了生成的评论的质量以及架构和排名API的效果。

英文摘要:

Code comments are significantly helpful in comprehending software programs and also aid developers to save a great deal of time in software maintenance. Code comment generation aims to automatically predict comments in natural language given a code snippet. Several works investigate the effect of integrating external knowledge on the quality of generated comments. In this study, we propose a solution, namely APIContext2Com, to improve the effectiveness of generated comments by incorporating the pre-defined Application Programming Interface (API) context. The API context includes the definition and description of the pre-defined APIs that are used within the code snippets. As the detailed API information expresses the functionality of a code snippet, it can be helpful in better generating the code summary. We introduce a seq-2-seq encoder-decoder neural network model with different sets of multiple encoders to effectively transform distinct inputs into target comments. A ranking mechanism is also developed to exclude non-informative APIs, so that we can filter out unrelated APIs. We evaluate our approach using the Java dataset from CodeSearchNet. The findings reveal that the proposed model improves the best baseline by 1.88 (8.24 %), 2.16 (17.58 %), 1.38 (18.3 %), 0.73 (14.17 %), 1.58 (14.98 %) and 1.9 (6.92 %) for BLEU1, BLEU2, BLEU3, BLEU4, METEOR, ROUGE-L respectively. Human evaluation and ablation studies confirm the quality of the generated comments and the effect of architecture and ranking APIs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑