Translating source code from one programming language to another is a critical, time-consuming task in modernizing legacy applications and codebases. Recent work in this space has drawn inspiration from the software naturalness hypothesis by applying natural language processing techniques towards automating the code translation task. However, due to the paucity of parallel data in this domain, supervised techniques have only been applied to a limited set of popular programming languages. To bypass this limitation, unsupervised neural machine translation techniques have been proposed to learn code translation using only monolingual corpora. In this work, we propose to use document similarity methods to create noisy parallel datasets of code, thus enabling supervised techniques to be applied for automated code translation without having to rely on the availability or expensive curation of parallel code datasets. We explore the noise tolerance of models trained on such automatically-created datasets and show that these models perform comparably to models trained on ground truth for reasonable levels of noise. Finally, we exhibit the practical utility of the proposed method by creating parallel datasets for languages beyond the ones explored in prior work, thus expanding the set of programming languages for automated code translation.
翻译:将源代码从一种编程语言转换到另一种编程语言是一项关键、耗时的任务,使遗留应用程序和代码库现代化。最近,这一空间的工作通过应用自然语言处理技术实现代码翻译自动化,从软件自然假设中得到启发。然而,由于这一领域缺乏平行数据,监督技术只应用于有限的一套流行编程语言。为绕过这一限制,提议了未经监督的神经机器翻译技术,只使用单语语种来学习代码翻译。在这项工作中,我们提议使用类似方法,创造噪音的平行代码数据集,从而能够将受监督的技术用于自动代码翻译,而不必依赖平行代码数据集的可用性或昂贵的翻译。我们探索了在这种自动创建数据集方面受过培训的模型的噪音容忍度,并表明这些模型与在地面真相方面受过培训的模型具有可比性,以获得合理程度的噪音。最后,我们展示了拟议方法的实际效用,为先前工作所探讨的语文制作的平行数据集,从而扩大了自动代码翻译的成套编程语言。