arrow
Return

Snippet Comment Generation Based on Code Context Expansion

delete2023-11-23
delete0
PRE
AI
H
Hanyang Guo
X
Xiangping Chen
黄袁 cover
黄袁 (Yuan Huang)
Y
Yanlin Wang
X
Xi Ding
Z
Zibin Zheng *
X
Xiaocong Zhou
H
Hong‐Ning Dai
DOI:10.1145/3611664delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Code commenting plays an important role in program comprehension. Automatic comment generation helps improve software maintenance efficiency. The code comments to annotate a method mainly include header comments and snippet comments. The header comment aims to describe the functionality of the entire method, thereby providing a general comment at the beginning of the method. The snippet comment appears at multiple code segments in the body of a method, where a code segment is called a code snippet. Both of them help developers quickly understand code semantics, thereby improving code readability and code maintainability. However, existing automatic comment generation models mainly focus more on header comments, because there are public datasets to validate the performance. By contrast, it is challenging to collect datasets for snippet comments, because it is difficult to determine their scope. Even worse, code snippets are often too short to capture complete syntax and semantic information. To address this challenge, we propose a novel Snippet Comment Generation approach called SCGen. First, we utilize the context of the code snippet to expand the syntax and semantic information. Specifically, 600,243 snippet code-comment pairs are collected from 959 Java projects. Then, we capture variables from code snippets and extract variable-related statements from the context. After that, we devise an algorithm to parse and traverse abstract syntax tree (AST) information of code snippets and corresponding context. Finally, SCGen generates snippet comments after inputting the source code snippet and corresponding AST information into a sequence-to-sequence-based model. We conducted extensive experiments on the dataset we collected to evaluate our SCGen. Our approach obtains 18.23 in BLEU-4 metrics, 18.83 in METEOR, and 23.65 in ROUGE-L, which outperforms state-of-the-art comment generation models.
Keywords:
Snippet comment generation
code summarization
neural machine translation
contextual information

Journal

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
Papers:
1.2K
Citations:
3.4K

Organization

H
Hong Kong Baptist University
Scholars:
6.3K
Papers: 7.5K
Citations: 1.3W
S
Sun Yat Sen University
Scholars:
9.9W
Papers: 7.2W
Citations: 95
Cited Papers

Cited Papers

err
IF0
err
err0
errOAAI
err
errShare
errSave
Effects of a restrictive fluid regimen in pediatric patients undergoing major abdominal surgery
err2014-12-11
err0
PREAI
errSahatsa Mandee; Wassana Butmangkun; Naiyana Aroonpruksakul; Niramol Tantemsapya; Benno von Bormann; Suwannee Suraseranivongse
errShare
errSave
Homeobox Gene Involvement in Normal Hematopoiesis and in the Pathogenesis of Childhood Leukemias
err2017-01-01
err0
PREAI
errMaria Adamaki; Maria Goulielmaki; Ioannis Christodoulou; Spiros Vlahopoulos; Vassilis Zoumpourlis
errShare
errSave
Web Service QoS Prediction via Collaborative Filtering: A Survey
err2022-07-01
err66
PREAI
errZheng, Zibin; Li, Xiaoli; Tang, Mingdong; Xie, Fenfang; Lyu, Michael R.
errShare
errSave
errShare
errSave
Establishment and characterization of a new triple-negative canine mammary cancer cell line
err2018-10-01
err0
PREAI
errHong Zhang; Shimin Pei; Bin Zhou; Huanan Wang; Hongchao Du; Di Zhang; Degui Lin
errShare
errSave
SeCNN: A semantic CNN parser for code comment generation
err2021-11-01
err30
PREAI
errLi, Zheng; Wu, Yonghao; Peng, Bin; Chen, Xiang; Sun, Zeyu; Liu, Yong; Yu, Deli
errShare
errSave
A Location-Based Factorization Machine Model for Web Service QoS Prediction
err2021-09-01
err55
PREAI
errYang, Yatao; Zheng, Zibin; Niu, Xiangdong; Tang, Mingdong; Lu, Yutong; Liao, Xiangke
errShare
errSave
researcher View more