CodeQG: Automated Multiple Question Generation for Source Code Comprehension
During software maintenance and evolution, developers spend more than half of their time on code comprehension activities. In order to understand an unfamiliar code base, they would naturally ask different types of questions related to code snippets and try to find the answers. In this paper, we conduct an initial work to explore the possibility of automatic question generation for program comprehension. We construct a large-scale data set containing pairs of source code and questions that are automatically transformed from inline comments based on dependency analysis and semantic role labeling. We also build a comprehensive taxonomy of question types so as to generate questions concerning different aspects of code snippets, such as purpose, implementation details and so on. Then, we propose a deep learning-based prototype CodeQG to automatically generates multiple types of questions for code snippets. We evaluate CodeQG by using both typical performance metrics and manual evaluation. The results show that (1) we can achieve a value of 42.02 on BLEU4 and 60.81 on ROUGE-L for the generated questions; (2) overall, the questions are very correct in grammatical, semantic and format; (3) the questions are related to the corresponding code snippet and are helpful for developers in source code comprehension activities. Our work gives insights into automatically generating multiple types of questions for code comprehension. We expect this exploration will improve the applicability and generality of machine code comprehension.
Authors
- Weiqin Zou (ORCID: https://orcid.org/0000-0002-0913-1539)
- Kaiyuan Qi (ORCID: https://orcid.org/0009-0005-9043-106X)
- Xiaowei Zhang (ORCID: https://orcid.org/0000-0003-1481-5158)
- Lianfa Zhang (ORCID: https://orcid.org/0009-0004-2927-7318)
- David Zhang (ORCID: https://orcid.org/0000-0002-5027-5286)
- Peng Zhang (ORCID: https://orcid.org/0000-0003-4278-0036)
- Lin Chen (ORCID: https://orcid.org/0000-0003-2352-2226)
- Guanqun Xu
- Liye Pang (ORCID: https://orcid.org/0009-0007-3065-1698)
Institutions
- Nanjing Tech University (CN)
- Shandong University (CN)
- Jinan Institute of Quantum Technology (CN)
- Coal Industry Jinan Design & Research Institute (China) (CN)
- Inspur (China) (CN)
- Nanjing University (CN)
- Nanjing University of Aeronautics and Astronautics (CN)
Publication Details
- Journal
- International Journal of Software Engineering and Knowledge Engineering
- Published
- 2025-03-22
- DOI
- https://doi.org/10.1142/s0218194025500214
- Primary Topic
- Web Application Security Vulnerabilities
- Type
- article
- Field-Weighted Citation Impact
- 0.00