Preprint Article Version 1 Preserved in Portico This version is not peer-reviewed

Statement-grained Hierarchy Enhanced Code Summarization

Version 1 : Received: 16 January 2024 / Approved: 17 January 2024 / Online: 17 January 2024 (15:55:21 CET)

A peer-reviewed article of this Preprint also exists.

Zhang, Q.; Jin, D.; Wang, Y.; Gong, Y. Statement-Grained Hierarchy Enhanced Code Summarization. Electronics 2024, 13, 765. Zhang, Q.; Jin, D.; Wang, Y.; Gong, Y. Statement-Grained Hierarchy Enhanced Code Summarization. Electronics 2024, 13, 765.

Abstract

Code summarization plays a vital role in aiding developers with program comprehension by generating corresponding textual descriptions for code snippets. While recent approaches have concentrated on encoding the textual and structural characteristics of source code, they often neglect the global hierarchical features causing limited code representation. Addressing this gap, our paper introduces the Statement-grained Hierarchy enhanced Transformer model (SHT), a novel framework that integrates global hierarchy, syntax, and token sequences to automatically generate summaries for code snippets. SHT is distinctively designed with two encoders to learn both hierarchical and sequential features of code. One relational attention encoder processes the statement-grained hierarchical graph, producing hierarchical embeddings. Subsequently, another sequence encoder integrates these hierarchical structures with token sequences. The resulting enriched representation is then fed into a vanilla Transformer decoder, which effectively generates concise and informative summarizations. Our extensive experiments demonstrate that SHT significantly outperforms state-of-the-art approaches on two widely used Java benchmarks. This underscores the effectiveness of incorporating global hierarchical information in enhancing the quality of code summarizations.

Keywords

Source code summarization; Code representation learning; Code static analysis; Program comprehension; Transformer

Subject

Computer Science and Mathematics, Software

Comments (0)

We encourage comments and feedback from a broad range of readers. See criteria for comments and our Diversity statement.

Leave a public comment
Send a private comment to the author(s)
* All users must log in before leaving a comment
Views 0
Downloads 0
Comments 0
Metrics 0


×
Alerts
Notify me about updates to this article or when a peer-reviewed version is published.
We use cookies on our website to ensure you get the best experience.
Read more about our cookies here.