arrow
Return

Summarizing source code with hierarchical code representation

delete2022-03-01
delete14
PRE
AI
Z
Ziyi Zhou
余
余慧群 (Huiqun Yu) *
G
Guisheng Fan
Z
Zijie Huang
X
Xingguang Yang
DOI:10.1016/j.infsof.2021.106761delete
deleteOriginal
deleteShare
deleteSave
Abstract

Abstract

En 中文
Context: Code summarization aims to automatically generate natural language descriptions for code, and has become a rapidly expanding research area. Data-driven code summarization models based on neural networks have proliferated in recent few years. Objective: Almost all of existing neural models are built upon the granularity of token or AST node. This has several drawbacks: a) Code summarization requires high-level knowledge of code while token representations are limited to provide a global view; b) Such approaches can hardly model the hierarchy of code; c) Long input codes challenge such models to handle long-range dependencies due to the large number of tokens and AST nodes. Method: To address these issues, we propose a novel framework to utilize hierarchical representation of code to generate better summaries. We consider two levels of code hierarchy: token-level and statement-level. Our framework contains a pair of customized encoder-decoder models for tokens and AST of code respectively. Each of them has a hierarchical encoder that aims to extract both token and statement-level code features, and an attentional decoder with the ability to attend to those different levels of representation during decoding. They are then combined to predict summaries via ensemble learning. Results: We conduct extensive experiments to evaluate our models on a large Java corpus. The experimental results show that our approach outperforms several state-of-the-art baselines by a substantial margin. Conclusion: In conclusion, our approach could better learn global information of code and shift attention between important statements during summary generation. With the help of hierarchical attention, the models are able to locate keywords more accurately in a top-down way. Ensemble learning is also proved to be an effective way to benefit from multiple input sources.
Keywords:
Code summarization
Program comprehension
Deep learning
Hierarchical attention
Reinforcement-Learning-Guided Source Code Summarization Using Hierarchical Attention
err2022-01-01
err61
errOAAI
errWang, Wenhua; Zhang, Yuqun; Sui, Yulei; Wan, Yao; Zhao, Zhou; Wu, Jian; Yu, Philip S.; Xu, Guandong
errShare
errSave
An Extractive-and-Abstractive Framework for Source Code Summarization
err2024-03-14
err5
errOAAI
errSun, Weisong; Fang, Chunrong; Chen, Yuchen; Zhang, Quanjun; Tao, Guanhong; You, Yudu; Han, Tingxu; Ge, Yifei; Hu, Yuling; Luo, Bin; Chen, Zhenyu
errShare
errSave
Autofolding for Source Code Summarization
err2017-12-01
err37
errOAAI
errFowkes, Jaroslav; Chanthirasegaran, Pankajan; Ranca, Razvan; Allamanis, Miltiadis; Lapata, Mirella; Sutton, Charles
errShare
errSave
ClassSum: a deep learning model for class-level code summarization
err2022-10-10
err0
PREAI
errMingchen Li; Huiqun Yu; Guisheng Fan; Ziyi Zhou; Jiawen Huang
errShare
errSave
Esale: Enhancing Code-Summary Alignment Learning for Source Code Summarization
err2024-08-01
err2
PREAI
errFang, Chunrong; Sun, Weisong; Chen, Yuchen; Chen, Xiao; Wei, Zhao; Zhang, Quanjun; You, Yudu; Luo, Bin; Liu, Yang; Chen, Zhenyu
errShare
errSave

Journal

Information and Software Technology cover
Information and Software Technology
IF:
4.3
Papers:
3.8K
Citations:
9.5K

Organization

No organization information available
Cited Papers

Cited Papers

Measuring Program Comprehension: A Large-Scale Field Study with Professionals
err2018-10-01
err195
errOAAI
errXia, Xin; Bao, Lingfeng; Lo, David; Xing, Zhenchang; Hassan, Ahmed E.; Li, Shanping
errShare
errSave
errShare
errSave