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.
翻译:代码评论有助于理解软件程序, 并帮助开发者节省大量软件维护时间。 代码评论生成旨在自动预测自然语言中给出代码片断的自然语言评论。 一些工作正在调查整合外部知识对生成评论质量的影响。 在本研究中, 我们提出了一个解决方案, 即 APIContext2Com, 通过纳入预定义的应用程序编程接口( API) 来提高生成的评论的有效性。 API 环境包括定义和描述在代码片断中使用的预定义的 API 。 由于详细的 API 信息表示代码片断的功能, 有助于更好地生成代码摘要。 我们引入了一个包含不同组数种编码内容的后端-2 seq encoder- decoder 神经网络模型, 以有效地将不同内容转换为目标评论。 一个排位机制, 以排除非强化的 API 。 我们使用代码SearchNet 的 PIA 数据集来评估我们的方法。 调查结果显示, 拟议的模型将最佳基线( B. L.</s>