Using machine translation for converting Python 2 to Python 3 code

Department of Computing Science, University of Alberta, Edmonton, Alberta, Canada
DOI
10.7287/peerj.preprints.1459v1
Subject Areas
Natural Language and Speech, Software Engineering
Keywords
Machine transliteration, Programming languages, Software engineering, Python
Copyright
© 2015 Aggarwal et al.
Licence
This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, reproduction and adaptation in any medium and for any purpose provided that it is properly attributed. For attribution, the original author(s), title, publication source (PeerJ PrePrints) and either DOI or URL of the article must be cited.
Cite this article
Aggarwal K, Salameh M, Hindle A. 2015. Using machine translation for converting Python 2 to Python 3 code. PeerJ PrePrints 3:e1459v1

Abstract

In this paper, we have tried to use statistical machine translation in order to convert Python 2 code to Python 3 code. We use data from two projects and achieve a high BLEU score. We also investigate the cross-project training and testing to analyze the errors so as to ascertain differences with previous case. We have described a pilot study on modeling programming languages as natural language to build translation models on the lines of natural languages. This can be further worked on to translate between versions of a programming language or cross-programming-languages code translation.

Author Comment

This is a tech report of course project done by Karan Aggarwal at UAlberta as a part of Natural Language Processing course (CMPUT 650) during Winter'14.