Learning to Generate Pseudo-code from Source Code using Statistical Machine Translation Yusuke Oda, Hiroyuki Fudaba, Graham Neubig, Hideaki Hata, Sakriani Sakti, Tomoki Toda, and Satoshi Nakamura Graduate School of Information Science, Nara Institute of Science and Technology 8916-5 Takayama, Ikoma, Nara 630-0192, Japan foda.yusuke.on9, fudaba.hiroyuki.ev6, neubig, hata, ssakti, tomoki,
[email protected] Abstract—Pseudo-code written in natural language can aid comprehension of beginners because it explicitly describes the comprehension of source code in unfamiliar programming what the program is doing, but is more readable than an languages. However, the great majority of source code has no unfamiliar programming language. corresponding pseudo-code, because pseudo-code is redundant and laborious to create. If pseudo-code could be generated Fig. 1 shows an example of Python source code, and En- automatically and instantly from given source code, we could glish pseudo-code that describes each corresponding statement allow for on-demand production of pseudo-code without human in the source code.1 If the reader is a beginner at Python effort. In this paper, we propose a method to automatically (or a beginner at programming itself), the left side of Fig. generate pseudo-code from source code, specifically adopting the 1 may be difficult to understand. On the other hand, the statistical machine translation (SMT) framework. SMT, which was originally designed to translate between two natural lan- right side of the figure can be easily understood by most guages, allows us to automatically learn the relationship between English speakers, and we can also learn how to write specific source code/pseudo-code pairs, making it possible to create a operations in Python (e.g.