返回
Towards automatically generating block comments for code snippets
DOI:10.1016/j.infsof.2020.106373.png)
摘要
En 中文
Code commenting is a common programming practice of practical importance to help developers review and comprehend source code. There are two main types of code comments for a method: header comments that summarize the method functionality located before a method, and block comments that describe the functionality of the code snippets within a method. Inspired by the effectiveness of deep learning techniques in the NLP field, many studies focus on using the machine translation model to automatically generate comment for the source code. Because the data set of block comments is difficult to collect, current studies focus more on the automatic generation of header comments than that of block comments. However, block comments are important for program comprehension due to their explanation role for the code snippets in a method. To fill the gap, we have proposed an approach that combines heuristic rules and learning-based method to collect a large number of comment-code pairs from 1,032 open source projects in our previous study. In this paper, we propose a reinforcement learning-based method, RL-BlockCom, to automatically generate block comments for code snippets based on the collected comment-code pairs. Specifically, we utilize the abstract syntax tree (i.e., AST) of a code snippet to generate a token sequence with a statement-based traversal way. Then we propose a composite learning model, which combines the actor-critic algorithm of reinforcement learning with the encoder-decoder algorithm, to generate block comments. On the data set of the comment-code pairs, the BLEU-4 score of our method is 24.28, which outperforms the baselines and state-of-the-art in comment generation.
Keyword:
Automatic comment generation
Source code summarization
Code comment scope
Reinforcement learning
AI总结
对已上传原文的论文进行重点信息的提取,主要内容包括:简要概述、研究摘要、背景介绍、关键亮点、图文解析、展望与总结。
期刊
IF:
4.3
论文数:
3.8K
被引数:
7.7K
机构
引用论文
Identifying self-admitted technical debt through code comment analysis with a contextualized vocabulary通过使用上下文词汇进行代码注释分析来识别自我承认的技术债务
Enhanced thermal conductivity and mechanical property through boron nitride hot string in polyvinylidene fluoride fibers by electrospinning通过电纺在聚偏氟乙烯纤维中通过氮化硼热丝增强热导率和机械性能
没有更多内容

