An Extractive-and-Abstractive Framework for Source Code Summarization

Weisong Sun, Chunrong Fang, Yuchen Chen, Quanjun Zhang, Guanhong Tao +4 more
6/15/2022
cs.SEcs.AI

Official code: wssun/EACS (9 stars, Python, MIT, last commit 2023-12-05).

Abstract

(Source) Code summarization aims to automatically generate summaries/comments for a given code snippet in the form of natural language. Such summaries play a key role in helping developers understand and maintain source code.

Show full abstract

Existing code summarization techniques can be categorized into extractive methods and abstractive methods. The extractive methods extract a subset of important statements and keywords from the code snippet using retrieval techniques, and generate a summary that preserves factual details in important statements and keywords. However, such a subset may miss identifier or entity naming, and consequently, the naturalness of generated summary is usually poor. The abstractive methods can generate human-written-like summaries leveraging encoder-decoder models from the neural machine translation domain. The generated summaries however often miss important factual details. To generate human-written-like summaries with preserved factual details, we propose a novel extractive-and-abstractive framework. The extractive module in the framework performs a task of extractive code summarization, which takes in the code snippet and predicts important statements containing key factual details. The abstractive module in the framework performs a task of abstractive code summarization, which takes in the entire code snippet and important statements in parallel and generates a succinct and human-written-like natural language summary. We evaluate the effectiveness of our technique, called EACS, by conducting extensive experiments on three datasets involving six programming languages. Experimental results show that EACS significantly outperforms state-of-the-art techniques in terms of all three widely used metrics, including BLEU, METEOR, and ROUGH-L.

View on arXivView PDF

Code Implementations(1)

wssun/EACSOfficial100%
MIT

An Extractive-and-Abstractive Framework for Source Code Summarization

90PythonMar 18, 20222 years agoMIT

Similar Papers

Cite this paper

@article{sun2022extractiveandabstractive,
  title  = {An Extractive-and-Abstractive Framework for Source Code Summarization},
  author = {Weisong Sun and Chunrong Fang and Yuchen Chen and Quanjun Zhang and Guanhong Tao and Tingxu Han and Yifei Ge and Yudu You and Bin Luo},
  year   = {2022},
  eprint = {2206.07245},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2206.07245}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2206.07245.svg)](https://codeofpaper.com/paper/2206.07245)

Discussion