Learning to Generate Comments for API-Based Code Snippets

Yangyang Lu,Zelong Zhao,Ge Li,Zhi Jin
DOI: https://doi.org/10.1007/978-981-15-0310-8_1
2017-01-01
Abstract:Comments play an important role in software developments. They can not only improve the readability and maintainability of source code, but also provide significant resource for software reuse. However, it is common that lots of code in software projects lacks of comments. Automatic comment generation is proposed to address this issue. In this paper, we present an end-to-end approach to generate comments for API-based code snippets automatically. It takes API sequences as the core semantic representations of method-level API-based code snippets and generates comments from API sequences with sequence-to-sequence neural models. In our evaluation, we extract 217K pairs of code snippets and comments from Java projects to construct the dataset. Finally, our approach gains 36.48% BLEU-4 score and 9.90% accuracy on the test set. We also do case studies on generated comments, which …
What problem does this paper attempt to address?