引用本文:李重,施超煊,潘敏学,张天,王林章,李宣东.基于语义重排序的代码注释生成方法.软件学报,2026,37(2):601-620
【打印本页】   【下载PDF全文】   查看/发表评论  【EndNote】   【RefMan】   【BibTex】
←前一篇|后一篇→ 过刊浏览    高级检索
本文已被:浏览 836次   下载 1359 本文二维码信息
码上扫一扫!
分享到: 微信 更多
基于语义重排序的代码注释生成方法
李重1,2, 施超煊1,3, 潘敏学1,2, 张天1,3, 王林章1,3, 李宣东1,3
1.计算机软件新技术全国重点实验室(南京大学), 江苏 南京 210023;2.南京大学 软件学院, 江苏 南京 210093;3.南京大学 计算机学院, 江苏 南京 210023
摘要:
代码注释是对源代码功能的自然语言描述, 其可以帮助开发人员快速地理解代码语义及功能, 从而提高软件开发和维护的效率. 然而, 书写与维护代码注释费时费力, 导致代码注释经常出现缺失、不匹配以及过时等问题. 因此, 如何自动化地为源代码生成注释引起了大量研究人员的关注. 现有方法通常利用信息检索技术或深度学习技术来进行代码注释自动生成, 但这二者均存在自身的一些局限. 目前已有一些对信息检索技术和深度学习技术进行集成的研究工作, 但它们无法有效利用这两种技术优势. 针对这些问题, 提出一种基于语义重排序的代码注释生成方法SRBCS, 该方法通过语义重排序模型对不同方法所生成代码注释进行排序选择来实现代码注释生成, 从而在实现对不同方法集成的同时最大化地利用不同方法在代码注释生成上的优势. 在两个数据集上将SRBCS与14种代码注释生成方法进行比较. 实验评估结果表明SRBCS可以有效地对不同代码注释生成方法进行集成, 实现了优于现有14种代码注释生成方法的性能.
关键词:  代码注释生成  语义重排序模型  对比学习
DOI:10.13328/j.cnki.jos.007470
分类号:TP311
基金项目:国家自然科学基金(62402214, 62372227, 62232014); 江苏省自然科学基金(BK20241194)
Code Comment Generation Method Based on Semantic Reranking
LI Zhong1,2, SHI Chao-Xuan1,3, PAN Min-Xue1,2, ZHANG Tian1,3, WANG Lin-Zhang1,3, LI Xuan-Dong1,3
1.State Key Laboratory for Novel Software Technology (Nanjing University), Nanjing 210023, China;2.Software Institute, Nanjing University, Nanjing 210093, China;3.School of Computer Science, Nanjing University, Nanjing 210023, China
Abstract:
Code comments serve as natural-language descriptions of the source code functionality, helping developers quickly understand the code’s semantics and functionality, thus improving software development and maintenance efficiency. However, writing and maintaining code comments is time-consuming and labor-intensive, often leading to issues such as absence, inconsistency, and obsolescence. Therefore, the automatic generation of comments for source code has attracted significant attention. Existing methods typically use information retrieval techniques or deep learning techniques for automatic code comment generation, but both have their limitations. Some research has integrated these two techniques, but such approaches often fail to effectively leverage the advantages of both methods. To address these issues, this study proposes a semantic reranking-based code comment generation method, SRBCS. SRBCS employs a semantic reranking model to rank and select comments generated by various approaches, thus integrating multiple methods and maximizing their respective strengths in the comment generation process. We compared SRBCS with 11 code comment generation approaches on two subject datasets. Experimental results demonstrate that SRBCS effectively integrates different approaches and outperforms existing methods in code comment generation.
Key words:  code comment generation  semantic reranking model  contrastive learning

引用本文:
【打印本页】   【下载PDF全文】   查看/发表评论  【EndNote】   【RefMan】   【BibTex】
←前一篇|后一篇→ 过刊浏览    高级检索
本文已被:浏览次   下载  
分享到: 微信 更多
摘要:
关键词:  
DOI:
分类号:
基金项目:
Abstract:
Key words: