Abstract

Code summarization has long been viewed as a challenge in software engineering because of the difficulties of understanding source code and generating natural language. Some mainstream methods combine abstract syntax trees with language models to capture the structural information of the source code and generate relatively satisfactory comments. However, these methods are still deficient in code understanding and limited by the long dependency problem. In this paper, we propose a novel model called Fret, which stands for Functional REinforced Transformer with BERT. The model provides a new way to generate code comments by learning code functionalities and deepening code understanding while alleviating the problem of long dependency. For this purpose, a novel reinforcer is proposed for learning the functional contents of code so that more accurate summaries to describe the code functionalities can be generated. In addition, a more efficient algorithm is newly designed to capture the source code structure. The experimental results show that the effectiveness of our model is remarkable. Fret significantly outperforms all the state-of-the-art methods we examine. It pushes the BLEU-4 score to 24.32 for Java code summarization (14.23% absolute improvement) and the ROUGE-L score to 40.12 for Python. An ablation test is also conducted to further explore the impact of each component of our method.

Highlights

  • Programmers are keyboard pianists who write beautiful pieces of code by striking keys

  • CONTRIBUTION In this paper, we propose a code summarization model called Fret, which stands for Functional REinforced Transformer with Bidirectional encoder representations from Transformers (BERT)

  • It can be seen from the experimental results that our model outperforms the state-of-the-art models on all metrics: BLEU, METEOR, ROUGE-L, and RIBES

Read more

Summary

Introduction

Programmers are keyboard pianists who write beautiful pieces of code by striking keys. They create great software through efficient collaboration and program optimisation. Programmers need to update and maintain code over a long period. Iterations of functionality are often based on existing code. A high-quality code comment can point out key functions directly and enable programmers to innovate efficiently, whereas a piece of messy code with a useless comment may force our pianists to improvise. For fast code comment generation, researchers have begun to explore methods of source code summarization

Methods
Results
Discussion
Conclusion
Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call