项目上下文增强的自动代码摘要
作者:
作者单位:

作者简介:

胡天翔(1993-),男,博士生,主要研究领域为自然语言处理,程序语言理解;叶蔚(1985-),男,博士,副研究员,主要研究领域为自然语言处理,程序语言理解,软件安全;谢睿(1991-),男,博士,助理研究员,主要研究领域为程序语言理解,缺陷自动检测;张世琨(1969-),男,博士,研究员,博士生导师,CCF高级会员,主要研究领域为软件工程,网络安全,知识计算.

通讯作者:

中图分类号:

基金项目:

中国博士后科学基金(2021M700216)


Contextual Information Enhanced Source Code Summarization
Author:
Affiliation:

Fund Project:

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

    代码摘要通过生成源代码片段的简短自然语言描述, 可帮助开发人员理解代码并减少文档工作. 近期, 关于代码摘要的研究工作主要采用深度学习模型, 这些模型中的大多数都在由独立代码摘要对组成的大型数据集上进行训练. 尽管取得了良好的效果, 这些工作普遍忽略了代码片段和摘要的项目级上下文信息, 而开发人员在编写文档时往往高度依赖这些信息. 针对该问题, 研究了一种与开发者行为和代码摘要工具实现更加一致的代码摘要场景——项目级代码摘要, 其中, 创建了用于项目特定代码摘要的数据集, 该数据集包含800k方法摘要对及其生命周期信息, 用于构建特定时刻准确的项目项目上下文; 提出了一种新颖的深度学习方法, 利用高度相关的代码片段及其相应的摘要来表征上下文语义, 并通过迁移学习整合从大规模跨项目数据集中学到的常识. 实验结果表明: 基于项目级上下文的代码摘要模型不仅能够比通用代码摘要模型获得显著的性能提升, 同时, 针对特定项目能够生成更一致的摘要.

    Abstract:

    Code summarization generates brief natural language descriptions of source code pieces, which can assist developers to understand code and reduce documentation workload. Recent research efforts on code summarization mainly adopt deep learning models. Most of these models are trained on large datasets, consisting of independent code-summary pairs. Despite the technical advances, most of these works, referred as general code summarization models, ignore the project-level contextual information of code pieces and summaries, which developers would heavily rely on when writing documentation. This study investigates project-specific code summarization, a scenario that is much more consistent with human behavior and tool implementation of code summarization. Specifically, a novel deep learning approach is proposed that leverages highly relevant code pieces and their corresponding summaries to characterize contextual semantics, and integrates common knowledge learned from large-scale cross-project dataset via transfer learning. The dataset is created and released for project-specific code summarization, consisting of 800k method-summary pairs along with their lifecycle information for re-producing accurate code context. Experimental results on this dataset demonstrate that the proposed technique can not only gain huge improvement over general code summarization model, but also generates more consistent summaries within a project.

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

胡天翔,谢睿,叶蔚,张世琨.项目上下文增强的自动代码摘要.软件学报,2023,34(4):1695-1710

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

京公网安备 11040202500063号