基于语义重排序的代码注释生成方法
作者:
作者单位:

作者简介:

通讯作者:

中图分类号:

TP311

基金项目:

国家自然科学基金(62402214, 62372227, 62232014); 江苏省自然科学基金(BK20241194)


Code Comment Generation Method Based on Semantic Reranking
Author:
Affiliation:

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    代码注释是对源代码功能的自然语言描述, 其可以帮助开发人员快速地理解代码语义及功能, 从而提高软件开发和维护的效率. 然而, 书写与维护代码注释费时费力, 导致代码注释经常出现缺失、不匹配以及过时等问题. 因此, 如何自动化地为源代码生成注释引起了大量研究人员的关注. 现有方法通常利用信息检索技术或深度学习技术来进行代码注释自动生成, 但这二者均存在自身的一些局限. 目前已有一些对信息检索技术和深度学习技术进行集成的研究工作, 但它们无法有效利用这两种技术优势. 针对这些问题, 提出一种基于语义重排序的代码注释生成方法SRBCS, 该方法通过语义重排序模型对不同方法所生成代码注释进行排序选择来实现代码注释生成, 从而在实现对不同方法集成的同时最大化地利用不同方法在代码注释生成上的优势. 在两个数据集上将SRBCS与14种代码注释生成方法进行比较. 实验评估结果表明SRBCS可以有效地对不同代码注释生成方法进行集成, 实现了优于现有14种代码注释生成方法的性能.

    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.

    参考文献
    相似文献
    引证文献
引用本文

李重,施超煊,潘敏学,张天,王林章,李宣东.基于语义重排序的代码注释生成方法.软件学报,2026,37(2):601-620

复制
相关视频

分享
文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2024-12-16
  • 最后修改日期:2025-02-05
  • 录用日期:
  • 在线发布日期: 2025-09-17
  • 出版日期: 2026-02-06
文章二维码
您是第位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京市海淀区中关村南四街4号,邮政编码:100190
电话:010-62562563 传真:010-62562533 Email:jos@iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号