Improving Code Summarization with Block-wise Abstract Syntax Tree Splitting
Authors:
- 1 May 2021
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 184-195
Abstract
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.Keywords
All Related Versions
Funding Information
- National Natural Science Foundation of China
- National Natural Science Foundation of China
- Natural Science Foundation of Fujian Province
- National Natural Science Foundation of China
This publication has 38 references indexed in Scilit:
- Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks2015
- Automatic documentation generation via source code summarization of method context2014
- Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation2014
- Towards automatically generating summary comments for Java methods2010
- An information-theoretic perspective of tf–idf measuresInformation Processing & Management, 2003
- Long Short-Term MemoryNeural Computation, 1997
- Indexing by latent semantic analysisJournal of the American Society for Information Science, 1990
- Learning representations by back-propagating errorsNature, 1986
- A vector space model for automatic indexingCommunications of the ACM, 1975
- Control flow analysisACM SIGPLAN Notices, 1970