Jisuanji kexue (Dec 2021)

Automatic Code Comments Generation Method Based on Convolutional Neural Network

  • PENG Bin, LI Zheng, LIU Yong, WU Yong-hao

DOI
https://doi.org/10.11896/jsjkx.201100090
Journal volume & issue
Vol. 48, no. 12
pp. 117 – 124

Abstract

Read online

Automatic code comment generation technology can analyze the semantic information of source code and generate corresponding natural language descriptions,which can help developers understand the program and reduce the time cost during software maintenance.Most of the existing technologies are based on the encoder and decoder model of the recurrent neural network(RNN).However,this method suffers from long-term dependency problem,which means it cannot generate high-quality comments when analyzing far-away code blocks.To solve this problem,this paper proposes an automatic code comment generation method,which uses the convolutional neural network(CNN) to alleviate the inaccurate comments information caused by the long-term dependence problem.More specifically,this paper uses two CNNs,one source-code based CNN and one AST-based CNN,to capture source code's semantic information.The experimental results indicate that,compared to the two most recent methods,DeepCom and Hybrid-DeepCom,the method proposed in this paper generates more useful code comments and takes less time to execute.

Keywords