Computer Science ›› 2021, Vol. 48 ›› Issue (12): 117-124.doi: 10.11896/jsjkx.201100090

• Computer Software • Previous Articles     Next Articles

Automatic Code Comments Generation Method Based on Convolutional Neural Network

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

  1. College of Information Science and Technology,Beijing University of Chemical Technology,Beijing 100029,China
  • Received:2020-11-11 Revised:2021-04-09 Online:2021-12-15 Published:2021-11-26
  • About author:PENG Bin,born in 1994,postgraduate.His main research interests include code comment generation and artificial intelligence.
    WU Yong-hao,born in 1995,Ph.D,candidate.His main research interests include software testing and fault localization.
  • Supported by:
    National Natural Science Foundation of China(61902015,61872026).

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

Key words: Code comment generation, Convolutional neural network, Long short-term memory network, Program comprehension

CLC Number: 

  • TP311
[1]XIA X,BAO L,LO D,et al.Measuring program comprehen- sion:A large-scale field study with professionals[J].IEEE Transactions on Software Engineering,2017,44(10):951-976.
[2]HU X,LI G,XIA X,et al.Deep code comment generation[C]//2018 IEEE/ACM 26th International Conference on Program Comprehension(ICPC).IEEE,2018:200-210.
[3]CHEN X,YANG G,CUI Z Q,et al.State-of-the-Art survey of Automatic Code Comment Generation[J].Journal of Software,2021,32(7):2118-2141.
[4]SONG X,SUN H,WANG X,et al.A survey of automatic gene- ration of source code comments:Algorithms and techniques[J].IEEE Access,2019,7:111411-111428.
[5]ZHU Y,PAN M.Automatic Code Summarization:A Systematic Literature Review[J].arXiv:1909.04352,2019.
[6]RODEGHERO P,LIU C,MCBURNEY P W,et al.An eye- tracking study of java programmers and application to source code summarization[J].IEEE Transactions on Software Engineering,2015,41(11):1038-1054.
[7]MORENO L,APONTE J,SRIDHARA G,et al.Automatic ge- neration of natural language summaries for java classes[C]//2013 21st International Conference on Program Comprehension(ICPC).IEEE,2013:23-32.
[8]LECLAIR A,JIANG S,MCMILLAN C.A neural model for generating natural language summaries of program subroutines[C]//2019 IEEE/ACM 41st International Conference on Software Engineering(ICSE).IEEE,2019:795-806.
[9]SUTSKEVER I,VINYALS O,LE Q V.Sequence to sequence learning with neural networks[C]//Advances in Neural Information Processing Systems.2014:3104-3112.
[10]SUN Z,ZHU Q,MOU L,et al.A grammar-based structural cnn decoder for code generation[C]//Proceedings of the AAAI Conference on Artificial Intelligence.2019,33:7055-7062.
[11]LECLAIR A,HAQUE S,WU L,et al.Improved code summarization via a graph neural network[J].arXiv:2004.02843,2020.
[12]SHIDO Y,KOBAYASHI Y,YAMAMOTO A,et al.Automatic source code summarization with extended tree-lstm[C]//2019 International Joint Conference on Neural Networks(IJCNN).IEEE,2019:1-8.
[13]CHEN Q,HU H,LIU Z.Code Summarization with Abstract Syntax Tree[C]//International Conference on Neural Information Processing.Cham:Springer,2019:652-660.
[14]LECHNER M,HASANI R.Learning Long-Term Dependencies in Irregularly-Sampled Time Series[J].arXiv:2006.04418,2020.
[15]HU X,LI G,XIA X,et al.Summarizing source code with trans- ferred api knowledge[C]//2018 27th International Joint Confe-rence on Artificial Intelligence.2018:1-9.
[16]HU X,LI G,XIA X,et al.Deep code comment generation with hybrid lexical and syntactical information[J].Empirical Software Engineering,2020,25(3):2179-2217.
[17]PAPINENI K,ROUKOS S,WARD T,et al.BLEU:a method for automatic evaluation of machine translation[C]//Procee-dings of the 40th Annual Meeting of the Association for Computational Linguistics.2002:311-318.
[18]BANERJEE S,LAVIE A.METEOR:An automatic metric for MT evaluation with improved correlation with human judgments[C]//Proceedings of the ACL Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation AND/OR Summarization.2005:65-72.
[19]XIA Q,YEH C H,CHEN X Y.A Deep Bidirectional Highway Long Short-Term Memory Network Approach to Chinese Semantic Role Labeling[C]//2019 International Joint Conference on Neural Networks(IJCNN).IEEE,2019:1-6.
[20]CHUNG J,GULCEHRE C,CHO K H,et al.Empirical evaluation of gated recurrent neural networks on sequence modeling[J].arXiv:1412.3555,2014.
[21]SZEGEDY C,LIU W,JIA Y,et al.Going deeper with convolutions[C]//Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition.2015:1-9.
[22]REN S,HE K,GIRSHICK R,et al.Faster r-cnn:Towards real-time object detection with region proposal networks[J].Advances in Neural Information Processing Systems,2015,28:91-99.
[23]GUO B,ZHANG C,LIU J,et al.Improving text classification with weighted word embeddings via a multi-channel TextCNN model[J].Neurocomputing,2019,363:366-374.
[24]SHEN Y,HE X,GAO J,et al.Learning semantic representa-tions using convolutional neural networks for web search[C]//Proceedings of the 23rd International Conference on World Wide Web.2014:373-374.
[25]GU X,ZHANG H,ZHANG D,et al.Deep API learning[C]//Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering.2016:631-642.
[26]BAHDANAU D,CHO K,BENGIO Y.Neural machine translation by jointly learning to align and translate[J].arXiv:1409.0473,2014.
[27]LI Y,WANG Q,XIAO T,et al.Neural Machine Translation with Joint Representation[C]//AAAI.2020:8285-8292.
[28]WEI B,LI G,XIA X,et al.Code generation as a dual task of code summarization[C]//Advances in Neural Information Processing Systems.2019:6563-6573.
[29]DENKOWSKI M,LAVIE A.Meteor universal:Language specific translation evaluation for any target language[C]//Proceedings of the Ninth workshop on Statistical Machine Translation.2014:376-380.
[1] ZHOU Le-yuan, ZHANG Jian-hua, YUAN Tian-tian, CHEN Sheng-yong. Sequence-to-Sequence Chinese Continuous Sign Language Recognition and Translation with Multi- layer Attention Mechanism Fusion [J]. Computer Science, 2022, 49(9): 155-161.
[2] WANG Xin-tong, WANG Xuan, SUN Zhi-xin. Network Traffic Anomaly Detection Method Based on Multi-scale Memory Residual Network [J]. Computer Science, 2022, 49(8): 314-322.
[3] CHEN Yong-quan, JIANG Ying. Analysis Method of APP User Behavior Based on Convolutional Neural Network [J]. Computer Science, 2022, 49(8): 78-85.
[4] ZHU Cheng-zhang, HUANG Jia-er, XIAO Ya-long, WANG Han, ZOU Bei-ji. Deep Hash Retrieval Algorithm for Medical Images Based on Attention Mechanism [J]. Computer Science, 2022, 49(8): 113-119.
[5] DAI Zhao-xia, LI Jin-xin, ZHANG Xiang-dong, XU Xu, MEI Lin, ZHANG Liang. Super-resolution Reconstruction of MRI Based on DNGAN [J]. Computer Science, 2022, 49(7): 113-119.
[6] LIU Yue-hong, NIU Shao-hua, SHEN Xian-hao. Virtual Reality Video Intraframe Prediction Coding Based on Convolutional Neural Network [J]. Computer Science, 2022, 49(7): 127-131.
[7] XU Ming-ke, ZHANG Fan. Head Fusion:A Method to Improve Accuracy and Robustness of Speech Emotion Recognition [J]. Computer Science, 2022, 49(7): 132-141.
[8] WU Zi-bin, YAN Qiao. Projected Gradient Descent Algorithm with Momentum [J]. Computer Science, 2022, 49(6A): 178-183.
[9] ZHANG Jia-hao, LIU Feng, QI Jia-yin. Lightweight Micro-expression Recognition Architecture Based on Bottleneck Transformer [J]. Computer Science, 2022, 49(6A): 370-377.
[10] WANG Jian-ming, CHEN Xiang-yu, YANG Zi-zhong, SHI Chen-yang, ZHANG Yu-hang, QIAN Zheng-kun. Influence of Different Data Augmentation Methods on Model Recognition Accuracy [J]. Computer Science, 2022, 49(6A): 418-423.
[11] SUN Jie-qi, LI Ya-feng, ZHANG Wen-bo, LIU Peng-hui. Dual-field Feature Fusion Deep Convolutional Neural Network Based on Discrete Wavelet Transformation [J]. Computer Science, 2022, 49(6A): 434-440.
[12] WANG Shan, XU Chu-yi, SHI Chun-xiang, ZHANG Ying. Study on Cloud Classification Method of Satellite Cloud Images Based on CNN-LSTM [J]. Computer Science, 2022, 49(6A): 675-679.
[13] YANG Yue, FENG Tao, LIANG Hong, YANG Yang. Image Arbitrary Style Transfer via Criss-cross Attention [J]. Computer Science, 2022, 49(6A): 345-352.
[14] YANG Jian-nan, ZHANG Fan. Classification Method for Small Crops Combining Dual Attention Mechanisms and Hierarchical Network Structure [J]. Computer Science, 2022, 49(6A): 353-357.
[15] ZHAO Zheng-peng, LI Jun-gang, PU Yuan-yuan. Low-light Image Enhancement Based on Retinex Theory by Convolutional Neural Network [J]. Computer Science, 2022, 49(6): 199-209.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!