一种面向源代码摘要的抽取-生成式框架
An Extractive-and-Abstractive Framework for Source Code Summarization
AI总结:
针对现有代码摘要方法难以兼顾事实准确性与自然度的问题,提出抽取-生成式框架EACS,结合抽取模块提取关键语句与生成模块并行输入生成摘要,在多语言数据集上全面超越现有最优方法。
摘要:
源代码摘要旨在以自然语言形式为给定代码片段自动生成摘要/注释,这类摘要在帮助开发者理解和维护源代码方面发挥着关键作用。现有代码摘要技术可分为抽取式方法和生成式方法两类:抽取式方法利用检索技术从代码片段中提取重要语句和关键词的子集,生成的摘要能够保留重要语句与关键词中的事实细节,但这类子集可能遗漏标识符或实体命名,因此生成摘要的自然度通常较差;生成式方法借助神经机器翻译领域的编码器-解码器模型,能够生成类似人工撰写的摘要,但生成的摘要往往会遗漏重要的事实细节。\n为生成既保留事实细节又具备类人工撰写质量的摘要,我们提出了一种新颖的抽取-生成式框架。该框架的抽取模块执行抽取式代码摘要任务,接收代码片段并预测包含关键事实细节的重要语句;框架的生成模块执行生成式代码摘要任务,并行接收完整代码片段和重要语句,生成简洁且类似人工撰写的自然语言摘要。我们通过在涉及6种编程语言的3个数据集上开展大量实验,评估了所提技术EACS的有效性。实验结果表明,在BLEU、METEOR和ROUGE-L这三个广泛使用的评价指标上,EACS的性能均显著优于当前最优技术。
英文摘要:
(Source) Code summarization aims to automatically generate summaries/comments for a given code snippet in the form of natural language. Such summaries play a key role in helping developers understand and maintain source code. Existing code summarization techniques can be categorized into extractive methods and abstractive methods. The extractive methods extract a subset of important statements and keywords from the code snippet using retrieval techniques, and generate a summary that preserves factual details in important statements and keywords. However, such a subset may miss identifier or entity naming, and consequently, the naturalness of generated summary is usually poor. The abstractive methods can generate human-written-like summaries leveraging encoder-decoder models from the neural machine translation domain. The generated summaries however often miss important factual details. To generate human-written-like summaries with preserved factual details, we propose a novel extractive-and-abstractive framework. The extractive module in the framework performs a task of extractive code summarization, which takes in the code snippet and predicts important statements containing key factual details. The abstractive module in the framework performs a task of abstractive code summarization, which takes in the entire code snippet and important statements in parallel and generates a succinct and human-written-like natural language summary. We evaluate the effectiveness of our technique, called EACS, by conducting extensive experiments on three datasets involving six programming languages. Experimental results show that EACS significantly outperforms state-of-the-art techniques in terms of all three widely used metrics, including BLEU, METEOR, and ROUGH-L.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。