期刊文献+

一种用于代码注释自动生成的语法辅助复制机制 被引量:3

A Grammar-Aided Copy Mechanism for Automatic Code Comment Generation
下载PDF
导出
摘要 现有代码注释生成方法的复制机制未考虑源代码复杂多变的语法结构,导致存在准确率和鲁棒性不高等问题。通过改进指针网络使其支持结构化数据输入,提出一种语法辅助复制机制,以用于代码注释自动生成。该机制包含节点筛选策略和去冗余生成策略2个部分。节点筛选策略基于语法信息引入掩盖变量以过滤无效节点,从而降低指针网络对复杂语法的学习成本。去冗余生成策略基于时间窗口对节点概率进行动态调整,可解决代码自动注释中关键信息缺失的问题。实验结果表明,在WikiSQL数据集上,相比基准方法,该机制的BLEU、ROUGE-2和ROUGE-L指标值分别提升14.5%、10.3%和5.5%,在ATIS数据集上,上述指标值分别提升2.8%、6.6%和2.5%,验证了该机制的有效性以及引入语法信息的必要性。 The copy mechanisms of the existing code comment generation methods do not consider the complex and varying grammar structures of source code,resulting in low copy accuracy and low robustness.This paper reconstructs the pointer network to make it support structured data input,and proposes a new grammar-aided copy mechanism for automatic comment generation.The mechanism consists of two parts:node filtering strategy and de-redundant generation strategy.Node filtering strategy that introduces masking variables to filter invalid type nodes based on grammatical information,which reduces the learning cost of complex grammar in pointer networks.De-redundant generation strategy that dynamically adjusts the node probability based on the time window,which solves the problem of missing key information in the automatically generated comment.Experimental results show that compared with baseline methods,the proposed method improves BLEU by 14.5%,ROUGE-2 by 10.3%and ROUGE-L by 5.5%on the WikiSQL dataset,and improves BLEU by 2.8%,ROUGE-2 by 6.6%and ROUGE-L by 2.5%on the ATIS dataset.The results verify the effectiveness of the mechanism and the necessity of introducing grammatical information.
作者 许柏炎 蔡瑞初 梁智豪 XU Boyan;CAI Ruichu;LIANG Zhihao(School of Computers,Guangdong University of Technology,Guangzhou 510006,China)
出处 《计算机工程》 CAS CSCD 北大核心 2021年第4期92-99,共8页 Computer Engineering
基金 国家自然科学基金(61876043) 广东省自然科学基金(2014A030306004,2014A030308008) 广东特支计划(2015TQ01X140) NSFC-广东联合基金(U1501254) 广州市珠江科技新星专项(201610010101) 广州市科技计划项目(201902010058)。
关键词 代码注释生成 指针网络 自然语言生成 结构信息 复制机制 code comment generation pointer network natural language generation structured information copy mechanism
  • 相关文献

参考文献3

二级参考文献8

共引文献121

同被引文献22

引证文献3

二级引证文献2

相关作者

内容加载中请稍等...

相关机构

内容加载中请稍等...

相关主题

内容加载中请稍等...

浏览历史

内容加载中请稍等...
;
使用帮助 返回顶部