journal article·2022-12-08Open access

Bi-LSTM-Based Neural Source Code Summarization

Sarah Aljumah, Lamia Berriche

Applied Sciences· Volume 12· Issue 24

Abstract

Code summarization is a task that is often employed by software developers for fixing code or reusing code. Software documentation is essential when it comes to software maintenance. The highest cost in software development goes to maintenance because of the difficulty of code modification. To help in reducing the cost and time spent on software development and maintenance, we introduce an automated comment summarization and commenting technique using state-of-the-art techniques in summarization. We use deep neural networks, specifically bidirectional long short-term memory (Bi-LSTM), combined with an attention model to enhance performance. In this study, we propose two different scenarios: one that uses the code text and the structure of the code represented in an abstract syntax tree (AST) and another that uses only code text. We propose two encoder-based models for the first scenario that encodes the code text and the AST independently. Previous works have used different techniques in deep neural networks to generate comments. This study’s proposed methodologies scored higher than previous works based on the gated recurrent unit encoder. We conducted our experiment on a dataset of 2.1 million pairs of Java methods and comments. Additionally, we showed that the code structure is beneficial for methods’ signatures featuring unclear words.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Software Engineering Research · Topic Modeling · Natural Language Processing Techniques

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

College of Computer & Information Sciences, Prince Sultan University, Riyadh 12435, Saudi Arabia

Funding

Prince Sultan University

References (32)

Show source-provided references
1. De Souza, S.C.B., Anquetil, N., and de Oliveira, K.M. (2005, January 21–23). A study of the documentation essential to software maintenance. Proceedings of the 23rd Annual International Conference on Design of Communication Documenting & Designing for Pervasive Information—SIGDOC’05, Coventry, UK. Available online: https://www.academia.edu/18057445/A_study_of_the_documentation_essential_to_software_maintenance.10.1145/1085313.1085331 ↗
2. Moreno, L., Aponte, J., Sridhara, G., Marcus, A., Pollock, L., and Vijay-Shanker, K. (2013, January 20–21). Automatic generation of natural language summaries for Java classes. Proceedings of the IEEE International Conference on Program Comprehension, San Francisco, CA, USA.10.1109/ICPC.2013.6613830 ↗
3. Mcburney, P.W., and Mcmillan, C. (2021, December 02). Automatic Documentation Generation via Source Code Summarization of Method Context. Available online: http://www.nd.edu/~pmcburne/summaries/.
4. Roehm, T., Tiarks, R., Koschke, R., and Maalej, W. (2012, January 2–9). How do professional developers comprehend software?. Proceedings of the International Conference on Software Engineering, Zurich, Switzerland.10.1109/ICSE.2012.6227188 ↗
5. Hellendoorn, V.J., and Devanbu, P. (2017;, January 4–8). Are deep neural networks the best choice for modeling source code?. Proceedings of the ACM SIGSOFT Symposium on the Foundations of Software Engineering, Paderborn, Germany.10.1145/3106237.3106290 ↗
6. A Survey on Research of Code Comment Auto Generation10.1088/1742-6596/1345/3/032010 ↗
7. Zhang, C., Wang, J., Zhou, Q., Xu, T., Tang, K., Gui, H., and Liu, F. (2022). A Survey of Automatic Source Code Summarization. Symmetry, 14.10.3390/sym14030471 ↗
8. A Survey of Documentation Practice within Corrective Maintenance
9. Wong, E., Yang, J., and Tan, L. (2013, January 11–15). AutoComment: Mining question and answer sites for automatic comment generation. Proceedings of the 2013 28th IEEE/ACM International Conference on Automated Software Engineering, ASE 2013, Silicon Valley, CA, USA.10.1109/ASE.2013.6693113 ↗
10. Rahman, M.M., Roy, C.K., and Keivanloo, I. (2015, January 27–28). Recommending insightful comments for source code using crowdsourced knowledge. Proceedings of the2015 IEEE 15th International Working Conference on Source Code Analysis and Manipulation, SCAM 2015, Bremen, Germany.10.1109/SCAM.2015.7335404 ↗
11. Wei, B. (2019, January 11–15). Retrieve and refine: Exemplar-based neural comment generation. Proceedings of the 2019 34th IEEE/ACM International Conference on Automated Software Engineering, ASE 2019, San Diego, CA, USA.10.1109/ASE.2019.00152 ↗
12. Zhang, J., Wang, X., Zhang, H., Sun, H., and Liu, X. (2020, January 26–28). Retrieval-based neural source code summarization. Proceedings of the International Conference on Software Engineering, Seoul, Republic of Korea.10.1145/3377811.3380383 ↗
13. Leclair, A., Jiang, S., and McMillan, C. (2019, January 25–31). A Neural Model for Generating Natural Language Summaries of Program Subroutines. Proceedings of the International Conference on Software Engineering, Montreal, QC, Canada.10.1109/ICSE.2019.00087 ↗
14. Zhang, C., Zhou, Q., Qiao, M., Tang, K., Xu, L., and Liu, F. (2022). Re_Trans: Combined Retrieval and Transformer Model for Source Code Summarization. Entropy, 24.10.21203/rs.3.rs-1742575/v1 ↗
15. Wan, Y., Zhao, Z., Yang, M., Xu, G., Ying, H., Wu, J., and Yu, P.S. (2018, January 3–7). Improving Automatic Source Code Summarization via Deep Reinforcement Learning. Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, Montpellier, France.10.1145/3238147.3238206 ↗
16. Ye, W., Xie, R., Zhang, J., Hu, T., Wang, X., and Zhang, S. (2020, January 20–24). Leveraging Code Generation to Improve Code Retrieval and Summarization via Dual Learning. Proceedings of the Web Conference 2020-Proceedings of the World Wide Web Conference, WWW 2020, Taipei, Taiwan.10.1145/3366423.3380295 ↗
17. Recent trends in deep learning based natural language processing10.1109/MCI.2018.2840738 ↗
18. Glorot, X., and Bengio, Y. (2010, January 13–15). Understanding the difficulty of training deep feedforward neural networks. Proceedings of the Thirteenth International Conference on Artificial Intelligence and Statistics, Sardinia, Italy.
19. Chung, J., Gülçehre, Ç., Cho, K., and Bengio, Y. (2014). Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling. arXiv.
20. Long Short-Term Memory10.1162/neco.1997.9.8.1735 ↗
21. Cho, K., Van Merriënboer, B., Gulcehre, C., Bahdanau, D., Bougares, F., Schwenk, H., and Bengio, Y. (2014, January 25–29). Learning phrase representations using RNN encoder-decoder for statistical machine translation. Proceedings of the EMNLP 2014—2014 Conference on Empirical Methods in Natural Language Processing, Doha, Qatar.10.3115/v1/D14-1179 ↗
22. Iyer, S., Konstas, I., Cheung, A., and Zettlemoyer, L. (2016, January 7–12). Summarizing Source Code using a Neural Attention Model. Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, ACL 2016—Long Papers, Berlin, Germany.10.18653/v1/P16-1195 ↗
23. Hu, X., Li, G., Xia, X., Lo, D., and Jin, Z. (June, January 27). Deep code comment generation. Proceedings of the International Conference on Software Engineering, Gothenburg, Sweden.
24. Hu, X., Li, G., Xia, X., Lo, D., Lu, S., and Jin, Z. (2018, January 13–19). Summarizing source code with transferred API knowledge. Proceedings of the IJCAI International Joint Conference on Artificial Intelligence, Stockholm, Sweden.10.24963/ijcai.2018/314 ↗
25. Chen, Q., and Zhou, M. (2018, January 3–7). A neural framework for retrieval and summarization of source code. Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering, Montpellier, France.10.1145/3238147.3240471 ↗
26. Shido, Y., Kobayashi, Y., Yamamoto, A., Miyamoto, A., and Matsumura, T. (2019, January 14–19). Automatic Source Code Summarization with Extended Tree-LSTM. Proceedings of the International Joint Conference on Neural Networks, Budapest, Hungary.10.1109/IJCNN.2019.8851751 ↗
27. Effective approaches to combining lexical and syntactical information for code summarization10.1002/spe.2893 ↗
28. Li, B., Yan, M., Xia, X., Hu, X., Li, G., and Lo, D. (2020, January 8–13). DeepCommenter: A deep code comment generation tool with hybrid lexical and syntactical information. Proceedings of the 28th ACM Joint Meeting European Software Engineering Conference and Symposium on the Foundations of Software Engineering, Virtual Event.10.1145/3368089.3417926 ↗
29. Yang, G., Chen, X., Cao, J., Xu, S., Cui, Z., Yu, C., and Liu, K. (2021, January 11–12). ComFormer: Code Comment Generation via Transformer and Fusion Method-based Hybrid Code Representation. Proceedings of the 2021 8th International Conference on Dependable Systems and Their Applications, DSA 2021, Yinchuan, China.10.1109/DSA52907.2021.00013 ↗
30. Shahbazi, R., Sharma, R., and Fard, F.H. (2021, January 20–21). API2Com: On the Improvement of Automatically Generated Code Comments Using API Documentations. Proceedings of the 2021 IEEE/ACM 29th International Conference on Program Comprehension (ICPC), Madrid, Spain.10.1109/ICPC52881.2021.00049 ↗
31. Husain, H., Wu, H.-H., Gazit, T., Allamanis, M., and Brockschmidt, M. (2021, December 02). CodeSearchNet Challenge: Evaluating the State of Semantic Code Search. September 2019. Available online: http://arxiv.org/abs/1909.09436.
32. A Survey of Transformers10.1016/j.aiopen.2022.10.001 ↗