Source code summarization is the task of writing natural language descriptions of source code behavior. Code summarization underpins software documentation for programmers. Short descriptions of code help programmers understand the program quickly without having to read the code itself. Lately, neural source code summarization has emerged as the frontier of research into automated code summarization techniques. By far the most popular targets for summarization are program subroutines. The idea, in a nutshell, is to train an encoder-decoder neural architecture using large sets of examples of subroutines extracted from code repositories. The encoder represents the code and the decoder represents the summary. However, most current approaches attempt to treat the subroutine as a single unit. For example, by taking the entire subroutine as input to a Transformer or RNN-based encoder. But code behavior tends to depend on the flow from statement to statement. Normally dynamic analysis may shed light on this flow, but dynamic analysis on hundreds of thousands of examples in large datasets is not practical. In this paper, we present a statement-based memory encoder that learns the important elements of flow during training, leading to a statement-based subroutine representation without the need for dynamic analysis. We implement our encoder for code summarization and demonstrate a significant improvement over the state-of-the-art.
翻译:源代码摘要是编写自然语言描述源代码行为的任务。代码摘要为程序员提供了软件文档支持。代码的简短描述有助于程序员快速理解程序,而无需直接阅读代码本身。近年来,神经源代码摘要已成为自动化代码摘要技术研究的前沿领域。目前最流行的摘要目标是程序子程序。简而言之,其思路是利用从代码库中提取的大量子程序示例来训练编码器-解码器神经架构。编码器表示代码,解码器表示摘要。然而,当前大多数方法试图将子程序视为一个整体单元。例如,将整个子程序作为输入传递给基于Transformer或RNN的编码器。但代码行为往往依赖于语句之间的流动。通常,动态分析可能揭示这种流动,但在大型数据集中对数十万个示例进行动态分析并不实际。本文提出了一种基于语句的记忆编码器,该编码器在训练过程中学习流动的重要元素,从而无需动态分析即可获得基于语句的子程序表示。我们将该编码器应用于代码摘要任务,并证明其显著优于当前最先进的方法。