一句话:提出将代码词与 AST 结构分开编码的神经模型,在缺少内部文档时仍能生成连贯的程序子程序摘要。
源代码摘要是为代码行为生成自然语言描述的任务,可用于自动文档生成、程序理解和软件维护。传统方法依赖人工模板和启发式;近期神经机器翻译方法虽占主导,但大多依赖良好的内部文档和清晰的标识符,否则摘要质量下降。本文提出一种神经模型,将代码中的词与来自 AST 的代码结构结合,并把每种数据源作为独立输入处理,使模型能在不受代码文本干扰的情况下学习代码结构。作者构建了包含 210 万 Java 方法的数据集,实验表明该模型优于两个软件工程基线和一个自然语言处理基线,并且在完全没有内部文档的情况下也常能生成连贯摘要。
Source code summarization -- creating natural language descriptions of source code behavior -- is a rapidly-growing research topic with applications to automatic documentation generation, program comprehension, and software maintenance. Traditional techniques relied on heuristics and templates built manually by human experts. Recently, data-driven approaches based on neural machine translation have largely overtaken template-based systems. But nearly all of these techniques rely almost entirely on programs having good internal documentation; without clear identifier names, the models fail to create good summaries. In this paper, we present a neural model that combines words from code with code structure from an AST. Unlike previous approaches, our model processes each data source as a separate input, which allows the model to learn code structure independent of the text in code. This process helps our approach provide coherent summaries in many cases even when zero internal documentation is provided. We evaluate our technique with a dataset we created from 2.1m Java methods. We find improvement over two baseline techniques from SE literature and one from NLP literature.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-1902-01954,
title = {A Neural Model for Generating Natural Language Summaries of Program Subroutines},
author = {Alexander LeClair and Siyuan Jiang and Collin McMillan},
booktitle = {ICSE},
year = {2019},
doi = {10.1109/icse.2019.00087}
}