基于概念传播的软件项目代码注释生成方法
作者:
作者单位:

作者简介:

潘兴禄(1997-),男,博士生,CCF学生会员,主要研究领域为软件工程,软件复用;刘陈晓(1999-),女,硕士生,CCF学生会员,主要研究领域为软件工程,软件复用;王敏(1994-),男,博士,主要研究领域为软件工程,软件复用,代码审查;邹艳珍(1976-),女,博士,副教授,CCF专业会员,主要研究领域为软件工程,软件复用,知识图谱,智能软件开发;王涛(1984-),男,博士,副研究员,CCF高级会员,主要研究领域为开源软件工程,机器学习,数据挖掘;谢冰(1970-),男,博士,教授,博士生导师,CCF高级会员,主要研究领域为软件工程,形式化方法,软件复用,智能软件开发.

通讯作者:

邹艳珍,E-mail:zouyz@pku.edu.cn

中图分类号:

基金项目:

国家自然科学基金(61972006)


Code Comment Generation Based on Concept Propagation for Software Projects
Author:
Affiliation:

Fund Project:

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

    软件代码注释生成是软件工程领域近期研究的一个重要问题. 目前很多研究工作已经在包含大量 <代码片段, 注释语句> 对的开源数据集上取得了较好效果. 但在企业应用中, 待注释的代码往往是一个软件项目库, 其必须首先决策在哪些代码行上生成注释更好, 而且待注释的代码片段大小、粒度各不相同, 需要研究提出一种注释决策和生成一体化的、抗噪音的代码注释生成方法. 针对这个问题, 提出一个面向软件项目的代码自动注释生成方法CoComment. 所提方法能够自动抽取软件项目文档中的领域基本概念, 并基于代码解析与文本匹配进行概念传播和扩展. 在此基础上, 通过定位概念相关的代码行/段进行自动注释决策, 最终利用模板融合概念和上下文生成具有高可读性的自然语言代码注释. 目前CoComment已经在3个企业软件项目、超过4.6万条人工代码注释数据上进行了对比试验. 结果表明, 所提方法不仅能够有效地进行代码注释决策, 其注释内容与现有方法相比也能够提供更多有益于理解代码的信息, 从而为软件项目代码的注释决策和注释生成问题提供了一种一体化的解决方案.

    Abstract:

    Comment generation for software codes has been an important research task in the field of software engineering in the past few years. Several research efforts have achieved impressive results on the open-source datasets that contain copious <code snippet, comment> pairs. In the practice of software enterprises, however, the codes to be commented usually belong to a software project library, and it should be decided first on which code lines the comment generation can achieve better performance; moreover, the code snippets to be commented have different lengths and granularity. Thus, a code comment generation method is required, which can integrate commenting decisions and comment generation and is resistant to noise. To this end, CoComment, a software project-oriented code comment generation approach, is proposed in this study. This approach can automatically extract domain-specific basic concepts from software project documents and then uses code parsing and text matching to propagate and expand these concepts. On this basis, automatic code commenting decisions are made by locating code lines or segments related to these concepts, and corresponding natural language comments with high readability are generated upon the fusion of concepts and contexts with templates. Comparative experiments are conducted on three enterprise software projects containing more than 46000 manually annotated code comments. The experimental results demonstrate the proposed approach can effectively make code commenting decisions and generate more helpful code comments compared with existing methods, which provides an integrated solution to code commenting decisions and comment generation for software projects.

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

潘兴禄,刘陈晓,王敏,邹艳珍,王涛,谢冰.基于概念传播的软件项目代码注释生成方法.软件学报,2023,34(9):4114-4131

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

京公网安备 11040202500063号