High quality method names are descriptive and readable, which are helpful for code development and maintenance. The majority of recent research suggest method names based on the text summarization approach. They take the token sequence and abstract syntax tree of the source code as input, and generate method names through a powerful neural network based model. However, the tokens composing the method name are closely related to the entity name within its method implementation. Actually, high proportions of the tokens in method name can be found in its corresponding method implementation, which makes it possible for incorporating these common shared token information to improve the performance of method naming task. Inspired by this key observation, we propose a two-stage keywords guided method name generation approach to suggest method names. Specifically, we decompose the method naming task into two subtasks, including keywords extraction task and method name generation task. For the keywords extraction task, we apply a graph neural network based model to extract the keywords from source code. For the method name generation task, we utilize the extracted keywords to guide the method name generation model. We apply a dual selective gate in encoder to control the information flow, and a dual attention mechanism in decoder to combine the semantics of input code sequence and keywords. Experiment results on an open source dataset demonstrate that keywords guidance can facilitate method naming task, which enables our model to outperform the competitive state-of-the-art models by margins of 1.5\%-3.5\% in ROUGE metrics. Especially when programs share one common token with method names, our approach improves the absolute ROUGE-1 score by 7.8\%.
翻译:高质量的方法名称是描述性的和可读的, 有助于代码开发和维护。 最近的多数研究都建议基于文本总和法的方法名称。 它们使用源代码的象征序列和抽象语法树作为输入, 并通过强大的神经网络模型生成方法名称。 然而, 方法名称的符号与实施方法范围内的实体名称密切相关。 实际上, 方法名称中的符号比例很高, 可以在相应的方法执行中找到, 从而有可能将这些共享的通用符号信息整合起来, 以改进方法命名任务的性能。 受此关键观察的启发, 我们建议使用两个阶段的正统地名生成方法, 用于建议方法名称。 具体地说, 我们将方法命名方法转换成两个子任务, 包括关键字提取任务和方法名称生成任务。 对于关键字提取任务, 我们应用一个基于图形神经网络的模型模型来从源代码中提取关键字。 对于方法生成模型, 我们使用提取的关键字来指导方法命名模式的模型 。 我们用一个双选取的 R.8 通用关键字节制方法生成方法生成方法生成方法, 用于控制信息流, 和双选的Serviclegle 标准, 将一个实验性数据序列中的数据序列指令演示,, 演示定序中,, 将一个数据序列指令排序排序排序规则规则规则规则规则路路路段路段路段路段路段路。