arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1901.09102cs.SEcs.CLcs.LG
收藏

基于神经机器翻译的有意义代码变化学习

On Learning Meaningful Code Changes via Neural Machine Translation

College of William and Mary(威廉与玛丽学院);Università della Svizzera italiana (USI)(瑞士意大利语大学)

Michele Tufano, Jevgenija Pantiuchina, Cody Watson, Gabriele Bavota, Denys Poshyvanyk

摘要:

近年来,应用于源代码的深度学习(DL)技术已经兴起。研究人员已经利用DL自动化了几项开发和维护任务,例如编写提交消息,生成评论和检测漏洞等。将深度学习应用于源代码的一个长久的梦想是使非平凡的编码活动自动化。虽然已经朝着这个方向采取了一些步骤(例如,学习如何修复错误),仍然明显缺乏关于DL可以学习和自动应用的代码更改类型的经验证据。我们的目标是通过定量和定性地研究神经机器翻译(NMT)模型的能力来学习如何在拉取请求期间自动应用开发人员实现的代码更改,从而迈出重要的第一步。在实现拉取请求中提供的更改之前和之后,我们在一组236 k对代码组件上对NMT模型进行了训练和实验。我们表明,当应用在一个足够狭窄的背景下(即,在Pull请求更改之前/之后的小型/中型方法对),NMT可以在高达36%的情况下自动复制开发人员在Pull请求期间实现的更改。此外,我们的定性分析表明,该模型能够学习和复制各种有意义的代码更改,特别是重构和错误修复活动。我们的研究结果铺平了道路,新的研究领域的DL代码,如自动学习和重构的应用。

英文摘要:

Recent years have seen the rise of Deep Learning (DL) techniques applied to source code. Researchers have exploited DL to automate several development and maintenance tasks, such as writing commit messages, generating comments and detecting vulnerabilities among others. One of the long lasting dreams of applying DL to source code is the possibility to automate non-trivial coding activities. While some steps in this direction have been taken (e.g., learning how to fix bugs), there is still a glaring lack of empirical evidence on the types of code changes that can be learned and automatically applied by DL. Our goal is to make this first important step by quantitatively and qualitatively investigating the ability of a Neural Machine Translation (NMT) model to learn how to automatically apply code changes implemented by developers during pull requests. We train and experiment with the NMT model on a set of 236k pairs of code components before and after the implementation of the changes provided in the pull requests. We show that, when applied in a narrow enough context (i.e., small/medium-sized pairs of methods before/after the pull request changes), NMT can automatically replicate the changes implemented by developers during pull requests in up to 36% of the cases. Moreover, our qualitative analysis shows that the model is capable of learning and replicating a wide variety of meaningful code changes, especially refactorings and bug-fixing activities. Our results pave the way for novel research in the area of DL on code, such as the automatic learning and applications of refactoring.

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

↑