Automatic Generation of Comments Based on Code Structure Enhancements

Xiaodong Ren,Yubei Shuai,Shengyin Zang,Hao Cheng,Hao Liu,Jiagui Wu
DOI: https://doi.org/10.1109/bdai56143.2022.9862730
2022-01-01
Abstract:Code comments play a significant role in software maintenance as they can greatly improve the efficiency of software developers' program understanding and reduce maintenance costs. However, due to the bad programming habits of developers and tight project development time, the annotations of many projects are incomplete. Studies have shown that project maintainers spend almost half of their time on understanding programs. Accordingly, this paper proposes a dual-encoder-based deep learning method code structure-enhanced comment generation (CSE-GC) to automatically generate annotation texts for Java methods. CSE-GC uses the CSE traversal method to traverse the abstract syntax tree of the Java method; input the structure information obtained by the traversal and vocabulary information of the source code into the gate recurrent unit encoder and convolutional neural network encoder, respectively; and use the attention mechanism to guide the decoder to generate annotations. This study obtained 131,823 Java methods as the training set data to train the model. The final METEOR value on the test set is 30.95%, and the BLEU-4 value is 45.01%. The results demonstrate that the method proposed in this paper has better performance compared to state-of-the-art models.
What problem does this paper attempt to address?