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

03/03/2023
by   Ramin Shahbazi, et al.
0

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 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.

READ FULL TEXT
research
03/19/2021

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

Code comments can help in program comprehension and are considered as im...
research
10/15/2018

Generating Comments From Source Code with CCGs

Good comments help developers understand software faster and provide bet...
research
09/22/2017

Code Attention: Translating Code to Comments by Exploiting Domain Features

Appropriate comments of code snippets provide insight for code functiona...
research
03/24/2021

Learning to Generate Code Comments from Class Hierarchies

Descriptive code comments are essential for supporting code comprehensio...
research
09/14/2022

Automatic Comment Generation via Multi-Pass Deliberation

Deliberation is a common and natural behavior in human daily life. For e...
research
04/05/2022

LAMNER: Code Comment Generation Using Character Language Model and Named Entity Recognition

Code comment generation is the task of generating a high-level natural l...
research
03/23/2021

Characterising the Knowledge about Primitive Variables in Java Code Comments

Primitive types are fundamental components available in any programming ...

Please sign up or login with your details

Forgot password? Click here to reset