A Code Comment Generation Method Based on Information Retrieval and Code Structure
Code comments can help developers quickly understand code and reduce maintenance costs. However, due to the widespread phenomenon of code cloning and the complex syntax structure of code, existing comment generation methods, which rely solely on Syntax Tree (AST) representations of code information, often result in low-quality comments. Therefore, this paper proposes a code comment generation method based on information retrieval and code structural information. By leveraging information retrieval techniques that combine code semantics, syntax, and lexical features, the method retrieves the most similar results from a codebase and integrates abstract syntax trees with data flow graphs to further improve the accuracy of comment generation. Experimental results show that, compared to mainstream methods, this approach achieves better performance on Python datasets, and the generated comments exhibit higher readability.
Authors
- Xinran Jiang
- Daiwei Li (ORCID: https://orcid.org/0000-0001-8868-4440)
- Hai-Qing Zhang (ORCID: https://orcid.org/0000-0003-4941-7432)
- Xinguang Xiang (ORCID: https://orcid.org/0000-0002-2344-6174)
- Ying Zhou
- Hang Liu (ORCID: https://orcid.org/0000-0002-3408-3807)
Institutions
- Chengdu University of Information Technology (CN)
Publication Details
- Published
- 2024-12-20
- DOI
- https://doi.org/10.1109/aiim64537.2024.10934152
- Primary Topic
- Advanced Text Analysis Techniques
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- China Meteorological Administration