一句话:提出先检索相似代码的注释作为示例,再用 seq2seq 进行基于示例的代码注释生成,显著超越已有方法。
代码注释生成是自动化软件开发中的重要任务。多数已有神经注释生成系统采用编码器-解码器结构,仅以源代码为输入,未能利用软件开发中常见的代码复用信息。受传统基于信息检索的方法启发,本文提出以相似源代码的已有注释作为示例来指导注释生成。方法上,先基于开源搜索引擎检索相似代码,并将其注释作为示例,再使用 seq2seq 神经模型进行基于示例的注释生成。作者在大规模 Java 语料上评估,实验结果表明该模型显著优于当时最先进方法。
Code comment generation is a crucial task in the field of automatic software development. Most previous neural comment generation systems used an encoder-decoder neural network and encoded only information from source code as input. Software reuse is common in software development. However, this feature has not been introduced to existing systems. Inspired by the traditional IR-based approaches, we propose to use the existing comments of similar source code as exemplars to guide the comment generation process. Based on an open source search engine, we first retrieve a similar code and treat its comment as an exemplar. Then we applied a seq2seq neural network to conduct an exemplar-based comment generation. We evaluate our approach on a large-scale Java corpus, and experimental results demonstrate that our model significantly outperforms the state-of-the-art methods.
DOI 原文 ·
@inproceedings{paperbot5312,
title = {Retrieve and Refine: Exemplar-Based Neural Comment Generation},
author = {Bolin Wei},
booktitle = {ASE},
year = {2019},
doi = {10.1109/ase.2019.00152}
}