HatCUP:基于混合分析和注意力的即时评论更新
HatCUP: Hybrid Analysis and Attention based Just-In-Time Comment Updating
摘要:
在更改代码时,开发人员有时会忽略更新相关注释,从而带来不一致或过时的注释。这些注释增加了程序理解的成本,大大降低了软件的可维护性。研究人员已经提出了一些解决方案,如CUP和HEBCUP,它们可以有效地更新简单代码更改(即修改单个令牌)的注释,但对于复杂的代码更改则不够好。在本文中,我们提出了一种方法,命名为HatCUP(混合分析和注意力的评论更新器),提供了一个新的机制,评论更新任务。HatCUP注重混合分析和信息。首先,HatCUP考虑代码结构变化信息,引入结构引导的注意力机制,结合代码变化图分析和乐观数据流依赖分析。HatCUP采用普遍流行的基于RNN的编码器-解码器架构,将代码编辑、语法、语义和结构代码更改以及旧注释作为输入,并生成当前代码片段中更改的结构化表示。此外,HatCUP提出了一种新的编辑或非编辑机制来模仿人类的编辑行为,而不是直接生成新的评论,方法是生成一系列编辑动作,并构建一个修改的RNN模型来集成新开发的组件。在一个流行的数据集上进行的评估表明,HatCUP在准确率、召回率和METEOR方面分别比最先进的基于深度学习的方法(CUP)高出53.8%、31.3%和14.3%。HatCUP与基于启发式算法的方法(HEBCUP)相比,具有更好的整体性能。
英文摘要:
When changing code, developers sometimes neglect updating the related comments, bringing inconsistent or outdated comments. These comments increase the cost of program understanding and greatly reduce software maintainability. Researchers have put forward some solutions, such as CUP and HEBCUP, which update comments efficiently for simple code changes (i.e. modifying of a single token), but not good enough for complex ones. In this paper, we propose an approach, named HatCUP (Hybrid Analysis and Attention based Comment UPdater), to provide a new mechanism for comment updating task. HatCUP pays attention to hybrid analysis and information. First, HatCUP considers the code structure change information and introduces a structure-guided attention mechanism combined with code change graph analysis and optimistic data flow dependency analysis. With a generally popular RNN-based encoder-decoder architecture, HatCUP takes the action of the code edits, the syntax, semantics and structure code changes, and old comments as inputs and generates a structural representation of the changes in the current code snippet. Furthermore, instead of directly generating new comments, HatCUP proposes a new edit or non-edit mechanism to mimic human editing behavior, by generating a sequence of edit actions and constructing a modified RNN model to integrate newly developed components. Evaluation on a popular dataset demonstrates that HatCUP outperforms the state-of-the-art deep learning-based approaches (CUP) by 53.8% for accuracy, 31.3% for recall and 14.3% for METEOR of the original metrics. Compared with the heuristic-based approach (HEBCUP), HatCUP also shows better overall performance.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。