基于双重信息检索的Bash代码注释生成方法
作者:
作者单位:

作者简介:

陈翔(1980-),男,博士,副教授,CCF高级会员,主要研究领域为智能软件工程,软件仓库挖掘,经验软件工程;濮雪莲(1979-),女,副教授,主要研究领域为智能软件工程;于池(1997-),男,硕士生,主要研究领域为代码注释自动生成;崔展齐(1984-),男,博士,副教授,CCF高级会员,主要研究领域为软件测试及分析技术;杨光(1997-),男,硕士生,主要研究领域为智能化软件工程,代码注释自动生成,代码自动生成.

通讯作者:

陈翔,xchencs@ntu.edu.cn;濮雪莲,pu.xl@ntu.edu.cn

中图分类号:

TP311

基金项目:

国家自然科学基金(61872263,61702041,61202006);信息安全国家重点实验室开放课题(2020-MS-07);江苏省前沿引领技术基础研究专项(BK20202001);江苏省重点产业专利导航项目(DH20200072-10)


Bash Code Comment Generation Method Based on Dual Information Retrieval
Author:
Affiliation:

Fund Project:

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

    Bash是Linux默认的shell命令语言.它在Linux系统的开发和维护中起到重要作用.对不熟悉Bash语言的开发人员来说,理解Bash代码的目的和功能具有一定的挑战性.针对Bash代码注释自动生成问题提出了一种基于双重信息检索的方法ExplainBash.该方法基于语义相似度和词法相似度进行双重检索,从而生成高质量代码注释.其中,语义相似度基于CodeBERT和BERT-whitening操作训练出代码语义表示,并基于欧式距离来实现;词法相似度基于代码词元构成的集合,并基于编辑距离来实现.以NL2Bash研究中共享的语料库为基础,进一步合并NLC2CMD竞赛共享的数据以构造高质量语料库.随后,选择了来自代码注释自动生成领域的9种基准方法,这些基准方法覆盖了基于信息检索的方法和基于深度学习的方法.实证研究和人本研究的结果验证了ExplainBash方法的有效性.然后设计了消融实验,对ExplainBash方法内设定(例如检索策略、BERT-whitening操作等)的合理性进行了分析.最后,基于所提方法开发出一个浏览器插件,以方便用户对Bash代码的理解.

    Abstract:

    Bash is the default shell command language for Linux, which plays an important role in the development and maintenance of Linux systems. Nevertheless, understanding the purpose and functionality of the Bash code is a challenging task. Therefore, an automatic method ExplainBash is proposed based on dual information retrieval for automatic Bash code comment generation. Specifically, the proposed method is based on semantic similarity and lexical similarity to perform dual information retrieval, which aims to generate high-quality code comments. For semantic similarity, CodeBERT and BERT-whitening operator are used to learn the code semantic representation, and Euclidean distance is resorted to compute semantic similarity; while for lexical similarity, code is represented as a set of code tokens, then the edit distance is resorted to compute lexical similarity. A high-quality corpus is constructed based on the corpus shared in the NL2Bash study and the data shared in the NLC2CMD competition. After that, nine state-of-the-art baselines are selected from the automatic code comment generation domain, which cover the information retrieval-based methods and deep learning-based methods. Results of empirical study and human study verify the effectiveness of the proposed method. Ablation experiments are also designed to analyze the rationality of the settings (such as retrieval strategy, BERT-whitening operator) in the proposed method. Finally, a browser plug-in is developed based on the proposed method to facilitate the code comprehension of the Bash code.

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

陈翔,于池,杨光,濮雪莲,崔展齐.基于双重信息检索的Bash代码注释生成方法.软件学报,2023,34(3):1310-1329

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

京公网安备 11040202500063号