Keywords Guided Method Name Generation

Fan Ge, Li Kuang
3/20/2021
cs.SE

Official code: css518/Keywords-Guided-Method-Name-Generation (7 stars, Python, MIT, last commit 2021-03-11).

Abstract

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.

Show full abstract

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

View on arXivView PDF

Code Implementations(1)

MIT

A repository with the code for the paper with the same title

70Python, ShellMar 10, 20215 years agoMIT

Similar Papers

Cite this paper

@article{ge2021keywords,
  title  = {Keywords Guided Method Name Generation},
  author = {Fan Ge and Li Kuang},
  year   = {2021},
  eprint = {2103.11118},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2103.11118}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2103.11118.svg)](https://codeofpaper.com/paper/2103.11118)

Discussion