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.
翻译:代码可以帮助程序理解, 并被视为帮助软件维护开发者的重要文物。 但是, 评论大多缺失或过时, 特别是在复杂的软件项目中。 因此, 开发了几个自动评论生成模型作为解决方案。 最近的一些模型探索外部知识资源的整合, 如统一模拟语言类图表, 以改进生成的注释。 在本文件中, 我们提议 API2Com 模式, 将应用应用程序设计接口文档( API 文档) 作为生成注释的知识资源。 因此, API Documents 包含对方法的详细描述, 因此, 可以在生成的注释中提供更好的背景。 API Docs 与我们模型中的代码片断和摘要图表树一起使用。 我们将模型应用于大型 Java 数据集中, 包括130,000多种方法, 并使用变换器和 RNNN- 基架构来评估它。 有趣的是, 使用API Document Documents, 我们对所有结果进行了不同的实验, 但是, 仅包含一个 API 注释的方法, 添加 API Documents 提供更好的注释, 在生成的文档中, 4 % BLEU 平均评分, 。