arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2103.11118cs.SE
收藏

关键词引导方法名称生成

Keywords Guided Method Name Generation

Fan Ge, Li Kuang

摘要:

高质量的方法名具有描述性和可读性,有助于代码开发和维护。最近的大多数研究建议基于文本摘要方法的方法名称。它们将源代码的标记序列和抽象语法树作为输入,通过一个强大的基于神经网络的模型生成方法名。但是,组成方法名称的标记与其方法实现中的实体名称密切相关。实际上,方法名中的标记在其对应的方法实现中可以找到很高的比例,这使得合并这些公共共享标记信息以提高方法命名任务的性能成为可能。受这一关键观察的启发,我们提出了一个两阶段的关键字引导的方法名称生成方法来建议方法名称。具体来说,我们将方法命名任务分解为两个子任务,包括关键字提取任务和方法名称生成任务。对于关键词提取任务,我们应用基于图神经网络的模型从源代码中提取关键词。对于方法名生成任务,我们利用提取的关键字来指导方法名生成模型。在编码器中采用双选择门控制信息流,在解码器中采用双注意力机制结合输入码序列和关键字的语义。在一个开源数据集上的实验结果表明,关键词引导可以促进方法命名任务,这使得我们的模型在ROUGE指标上的性能优于竞争对手的最先进的模型1.5%-3.5%。特别是当程序与方法名称共享一个公共标记时,我们的方法将绝对ROUGE-1分数提高了7.8%。

英文摘要:

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\%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑