一种用于生成自然语言代码摘要的主题引导指针生成器模型
A Topic Guided Pointer-Generator Model for Generating Natural Language Code Summaries
摘要:
代码摘要是生成源代码的自然语言描述的任务,对程序理解和维护具有重要意义。现有方法将该任务视为机器翻译问题(例如,从Java到英语),并应用神经机器翻译模型来解决这个问题。这些方法仅考虑给定的代码单元(例如,一种方法)而没有其更广泛的上下文。上下文的缺乏可能会阻碍NMT模型收集足够的信息用于代码摘要。此外,现有的方法使用固定的词汇表,并且没有充分考虑代码中的单词,而代码摘要中的许多单词可能来自代码。在这项工作中,我们提出了一个名为ToPNN的神经网络模型用于代码摘要,它在更广泛的背景下使用主题(例如,类)来指导神经网络,该神经网络将新词的生成与代码中现有单词的复制相结合。基于该模型,我们提出了一种在方法级生成自然语言代码摘要的方法(即,方法注释)。我们使用一个包含4,203,565个注释Java方法的数据集来评估我们的方法。结果表明,国家的最先进的方法显着改善,并确认类主题和复制机制的积极影响。
英文摘要:
Code summarization is the task of generating natural language description of source code, which is important for program understanding and maintenance. Existing approaches treat the task as a machine translation problem (e.g., from Java to English) and applied Neural Machine Translation models to solve the problem. These approaches only consider a given code unit (e.g., a method) without its broader context. The lacking of context may hinder the NMT model from gathering sufficient information for code summarization. Furthermore, existing approaches use a fixed vocabulary and do not fully consider the words in code, while many words in the code summary may come from the code. In this work, we present a neural network model named ToPNN for code summarization, which uses the topics in a broader context (e.g., class) to guide the neural networks that combine the generation of new words and the copy of existing words in code. Based on the model we present an approach for generating natural language code summaries at the method level (i.e., method comments). We evaluate our approach using a dataset with 4,203,565 commented Java methods. The results show significant improvement over state-of-the-art approaches and confirm the positive effect of class topics and the copy mechanism.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。