arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2108.12987cs.SE
收藏

CAST:利用抽象树的分层分裂和重构增强代码摘要

CAST: Enhancing Code Summarization with Hierarchical Splitting and Reconstruction of Abstract Syntax Trees

Ensheng Shi, Yanlin Wang, Lun Du, Hongyu Zhang, Shi Han, Dongmei Zhang, Hongbin Sun

摘要:

代码摘要旨在生成源代码的简洁自然语言描述,这有助于提高程序的理解和维护。最近的研究表明,从抽象语法树(AST)中提取的语法和结构信息有助于摘要生成。然而,现有的方法不能完全捕捉到丰富的信息,因为大尺寸/深度的AST。在本文中,我们提出了一种新的模型CAST,分层分裂和重建AST。首先,我们分层地将一个大的AST分成一组子树,并利用递归神经网络来编码子树。然后,我们通过重构分裂的AST来聚合子树的嵌入,以得到完整AST的表示。最后,AST表示,连同源代码嵌入获得的香草代码令牌编码器,用于代码摘要。广泛的实验,包括消融研究和人体评估,对基准已经证明了CAST的力量。为了便于再现,我们的代码和数据可在https://anonymous.4open.science/r/CAST/上获得。

英文摘要:

Code summarization aims to generate concise natural language descriptions of source code, which can help improve program comprehension and maintenance. Recent studies show that syntactic and structural information extracted from abstract syntax trees (ASTs) is conducive to summary generation. However, existing approaches fail to fully capture the rich information in ASTs because of the large size/depth of ASTs. In this paper, we propose a novel model CAST that hierarchically splits and reconstructs ASTs. First, we hierarchically split a large AST into a set of subtrees and utilize a recursive neural network to encode the subtrees. Then, we aggregate the embeddings of subtrees by reconstructing the split ASTs to get the representation of the complete AST. Finally, AST representation, together with source code embedding obtained by a vanilla code token encoder, is used for code summarization. Extensive experiments, including the ablation study and the human evaluation, on benchmarks have demonstrated the power of CAST. To facilitate reproducibility, our code and data are available at https://anonymous.4open.science/r/CAST/.

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

↑