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

API2Com:使用API文档改进自动生成的代码注释

API2Com: On the Improvement of Automatically Generated Code Comments Using API Documentations

University of British Columbia(英属哥伦比亚大学)

Ramin Shahbazi, Rishab Sharma, Fatemeh H. Fard

摘要:

代码注释可以帮助程序理解,并被认为是帮助开发人员进行软件维护的重要工件。然而,注释大多缺失或过时,特别是在复杂的软件项目中。作为一个结果,几个自动评论生成模型的开发作为一个解决方案。最近的模型探索了外部知识资源(如统一建模语言类图)的集成,以改进生成的注释。在本文中,我们提出了API2Com,一个模型,利用应用程序编程接口文档(API文档)作为知识资源的评论生成。API接口包含了更详细的方法描述,因此可以在生成的注释中提供更好的上下文。在我们的模型中,API树与代码片段和抽象树一起使用。我们将该模型应用于包含超过130,000个方法的大型Java数据集,并使用Transformer和基于RNN的架构对其进行评估。有趣的是,当使用API接口时,性能的提高可以忽略不计。因此,我们运行不同的实验来推理结果。对于只包含一个API的方法,添加API翻译平均将结果提高4% BLEU分数(BLEU分数是机器翻译中使用的自动评估指标)。然而,随着方法中使用的API数量的增加,由于输入中使用的文档很长,模型生成注释的性能会降低。我们的研究结果证实,API接口可以在生成更好的评论是有用的,但是,需要新的技术来确定最翔实的方法,而不是同时使用所有的文档。

英文摘要:

Code comments can help in program comprehension and are considered as important artifacts to help developers in software maintenance. However, the comments are mostly missing or are outdated, specially in complex software projects. As a result, several automatic comment generation models are developed as a solution. The recent models explore the integration of external knowledge resources such as Unified Modeling Language class diagrams to improve the generated comments. In this paper, we propose API2Com, a model that leverages the Application Programming Interface Documentations (API Docs) as a knowledge resource for comment generation. The API Docs include the description of the methods in more details and therefore, can provide better context in the generated comments. The API Docs are used along with the code snippets and Abstract Syntax Trees in our model. We apply the model on a large Java dataset of over 130,000 methods and evaluate it using both Transformer and RNN-base architectures. Interestingly, when API Docs are used, the performance increase is negligible. We therefore run different experiments to reason about the results. For methods that only contain one API, adding API Docs improves the results by 4% BLEU score on average (BLEU score is an automatic evaluation metric used in machine translation). However, as the number of APIs that are used in a method increases, the performance of the model in generating comments decreases due to long documentations used in the input. Our results confirm that the API Docs can be useful in generating better comments, but, new techniques are required to identify the most informative ones in a method rather than using all documentations simultaneously.

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

↑