Code Attention:利用领域特性将代码转换为注释
Code Attention: Translating Code to Comments by Exploiting Domain Features
摘要:
适当的代码段注释提供了对代码功能的深入了解,这有助于程序的理解。但是,由于使用注释进行创作的成本很高,许多代码项目都没有包含足够的注释。已经提出了自动注释生成技术来从代码片段生成注释,以便减轻注释代码时的人工努力。大多数现有的方法试图利用代码和生成的评论之间的某些相关性(通常手动给定),如果编码模式发生变化,则很容易违反这些相关性,因此评论生成的性能下降。在本文中,我们首先构建了C2CGit,这是一个来自GitHub中开放项目的大型数据集,它比现有数据集大20多个$\times$。然后,我们提出了一个新的注意力模块称为代码注意力翻译代码的评论,这是能够利用域的代码片段的特征,如符号和标识符。我们进行消融研究,以确定代码注意的不同部分的影响。实验结果表明,该模块具有更好的性能比现有的方法在BLEU和METEOR。
英文摘要:
Appropriate comments of code snippets provide insight for code functionality, which are helpful for program comprehension. However, due to the great cost of authoring with the comments, many code projects do not contain adequate comments. Automatic comment generation techniques have been proposed to generate comments from pieces of code in order to alleviate the human efforts in annotating the code. Most existing approaches attempt to exploit certain correlations (usually manually given) between code and generated comments, which could be easily violated if the coding patterns change and hence the performance of comment generation declines. In this paper, we first build C2CGit, a large dataset from open projects in GitHub, which is more than 20$\times$ larger than existing datasets. Then we propose a new attention module called Code Attention to translate code to comments, which is able to utilize the domain features of code snippets, such as symbols and identifiers. We make ablation studies to determine effects of different parts in Code Attention. Experimental results demonstrate that the proposed module has better performance over existing approaches in both BLEU and METEOR.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。