Code2tree: A Method for Automatically Generating Code Comments
Open Access
- 29 September 2022
- journal article
- research article
- Published by Wiley in Scientific Programming
- Vol. 2022, 1-9
Abstract
Source code comments can improve the efficiency of software development and maintenance. However, due to the heterogeneity of natural language and program language, the quality of code comments is not so high. So, this paper proposes a novel method Code2tree, which is based on the encoder-decoder model to automatically generate Java code comments. Code2tree firstly converts Java source code into abstract syntax tree (AST) sequences, and then the AST sequences are encoded by GRU encoder to solve the long sequence learning dependency problem. Finally, the attention mechanism is introduced in the decoding stage, and the quality of the code comment is improved by increasing the weight of the key information. We use the open dataset java-small to train the model and verify the effectiveness of Code2tree based on common-used indicators BLEU and F1-Score.Keywords
Funding Information
- College Students’ innovation and entrepreneurship training program (202110304086Y, JC2021125)
- Science and Technology Project of Nantong City (202110304086Y, JC2021125)
This publication has 6 references indexed in Scilit:
- Towards automatically generating block comments for code snippetsInformation and Software Technology, 2020
- A Survey of Automatic Generation of Source Code Comments: Algorithms and TechniquesIEEE Access, 2019
- code2vec: learning distributed representations of codeProceedings of the ACM on Programming Languages, 2019
- Measuring Program Comprehension: A Large-Scale Field Study with ProfessionalsIEEE Transactions on Software Engineering, 2017
- A Neural Architecture for Generating Natural Language Descriptions from Source Code Changes2017
- Long Short-Term MemoryNeural Computation, 1997