无线电通信技术2024,Vol.50Issue(4) :807-814.DOI:10.3969/j.issn.1003-3114.2024.04.024

基于类型辅助引导的代码注释生成模型

Code Comment Generation Model Based on Type-assisted Guidance

刘利 吕韦岑 汪洋
无线电通信技术2024,Vol.50Issue(4) :807-814.DOI:10.3969/j.issn.1003-3114.2024.04.024

基于类型辅助引导的代码注释生成模型

Code Comment Generation Model Based on Type-assisted Guidance

刘利 1吕韦岑 2汪洋1
扫码查看

作者信息

  • 1. 泸州职业技术学院人工智能与大数据学院,四川 泸州 646000
  • 2. 成都工贸职业技术学院信息工程学院,四川 成都 611731
  • 折叠

摘要

代码注释生成方法通常基于结构-序列(Structure-Sequence,Struct2Seq)框架,但忽略了代码注释的类型信息,例如操作符、字符串等.由于类型信息之间的层次具有依赖性,将类型信息引入已有的Struct2Seq框架并不适用.为了解决上述问题,提出一种基于类型辅助引导的代码注释生成(Code Comment Generation based on Type-assisted Guid-ance,CCG-TG)模型,将源代码视为带有类型信息的n元树.该模型包含一个关联类型编码器和一个限制类型解码器,可以对源代码进行自适应总结.此外,提出一种多级强化学习(Multi-level Reinforcement Learning,MRL)方法来优化所提模型的训练过程.在多个数据集上进行实验,与多种基准模型对比,证明所提CCG-TG模型在所有评价指标上的性能最优.

Abstract

Code comment generation methods are usually based on the Structure-Sequence(Struct2Seq)framework,but ignore the type information of code comments,such as operators,strings,and so on.Introducing type information into existing Struct2Seq frameworks is not suitable because of the dependency of hierarchy of type information.To solve above problems,a Code Comment Gener-ation based on Type-assisted Guidance(CCG-TG)model is proposed,which treats source code as an n-ary tree with type information.The model includes an associative type encoder and a restricted type decoder,which allows adaptive summary of source codes.In addi-tion,a Multi-level Reinforcement Learning(MRL)method is proposed to optimize training phase of the proposed model.Experiments are conducted on several datasets,the performance of the proposed CCG-TG model is the best on all evaluation metrics by comparing with many benchmark models.

关键词

代码注释生成/类型信息/结构序列框架/类型辅助引导/强化学习

Key words

code comment generation/type information/Struct2Seq framework/type-assisted guidance/reinforcement learning

引用本文复制引用

出版年

2024
无线电通信技术
中国电子科技集团公司第五十四研究所

无线电通信技术

北大核心
影响因子:0.745
ISSN:1003-3114
段落导航相关论文