arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2103.07845cs.SEcs.AIcs.CL
收藏

基于分块抽象树分裂的代码摘要算法

Improving Code Summarization with Block-wise Abstract Syntax Tree Splitting

Xiamen University(厦门大学)

Chen Lin, Zhichao Ouyang, Junqing Zhuang, Jianqiang Chen, Hui Li, Rongxin Wu

摘要:

自动代码摘要将软件开发人员从手动注释的沉重负担中解放出来,有利于软件开发和维护。抽象语法树(AST)描述了源代码的语法结构,它被用来指导代码摘要的生成。然而,现有的基于AST的方法遭受训练的困难,并产生不充分的代码摘要。本文提出了一种基于块的抽象树分割方法(BASTS),该方法充分利用了AST丰富的树形语法结构,提高了代码摘要的质量。BASTS基于控制流图的支配者树中的块来分割方法的代码,并为每个代码分割生成分割AST。然后,每个分割的AST由Tree-LSTM使用预训练策略来建模,以捕获本地非线性语法编码。学习的语法编码与代码编码相结合,并输入到Transformer中以生成高质量的代码摘要。基准测试的综合实验表明,BASTS显着优于国家的最先进的方法在各种评估指标。为了便于再现,我们的实现可在https://github.com/XMUDM/BASTS上获得。

英文摘要:

Automatic code summarization frees software developers from the heavy burden of manual commenting and benefits software development and maintenance. Abstract Syntax Tree (AST), which depicts the source code's syntactic structure, has been incorporated to guide the generation of code summaries. However, existing AST based methods suffer from the difficulty of training and generate inadequate code summaries. In this paper, we present the Block-wise Abstract Syntax Tree Splitting method (BASTS for short), which fully utilizes the rich tree-form syntax structure in ASTs, for improving code summarization. BASTS splits the code of a method based on the blocks in the dominator tree of the Control Flow Graph, and generates a split AST for each code split. Each split AST is then modeled by a Tree-LSTM using a pre-training strategy to capture local non-linear syntax encoding. The learned syntax encoding is combined with code encoding, and fed into Transformer to generate high-quality code summaries. Comprehensive experiments on benchmarks have demonstrated that BASTS significantly outperforms state-of-the-art approaches in terms of various evaluation metrics. To facilitate reproducibility, our implementation is available at https://github.com/XMUDM/BASTS.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑