摘 要: 现有的代码注释生成技术大多针对方法粒度,而对于面向对象程序,类才是其核心组成,因此对类生成注释是很有必要的。针对这一问题,提出一种结合类原型与深度学习技术对类生成注释的方法。首先,确定类原型并选择对应类注释模板;其次,提取类中信息填充模板,对类中的方法通过双编码器模型训练得到方法代码注释。实验结果表明,方法粒度上提出的双编码器模型在方法代码注释生成的结果评估中表现较好,类粒度的注释准确性较高。 |
关键词: 代码注释;类注释模板;类原型;双编码器;深度学习 |
中图分类号: TP311
文献标识码: A
|
基金项目: “十三五”国家密码发展基金理论项目(MMJJ20180202) |
|
Class Annotation Generation Method Based on Class Prototype and Deep Learning |
LI Rui1, ZHAO Fengyu2, LIU Ya1
|
(1.School of Optical-Electrical & Computer Engineering, University of Shanghai for Science and Technology, Shanghai 200093, China; 2. Department of Information and Intelligent Engineering, Shanghai Publishing and Printing College, Shanghai 200093, China)
lrui1999@163.com; zhaofengyv@usst.edu.cn; liuya@usst.edu.cn
|
Abstract: Most of the existing code annotation generation techniques are targeted at method granularity. For object-oriented programs, classes are their core components, so it is necessary to generate annotations for classes. To solve this problem, this paper proposes a class annotation generation method combining class prototype and deep learning technology. Firstly, the class prototype is determined and the corresponding class annotation template is selected. Secondly, information in the class is extracted to fill the template, and the method code annotation is obtained by training the bi-encoder model for the methods in the class. The experimental results show that the proposed biencoder model in terms of method granularity performs better in the result evaluation score of method code annotation generation, and the annotation accuracy of class granularity is higher. |
Keywords: code annotation; class annotation template; class prototype; bi-encoder; deep learning |