Learning to Generate Pseudo-Code from Source Code Using Statistical Machine Translation (T)
By Yusuke Oda, Hiroyuki Fudaba, Graham Neubig, Hideaki Hata, Sakriani Watiasri Sakti, Tomoki Toda, Satoshi Nakamura. 2015
319 citations recorded by the source corpus.
Pseudo-code written in natural language can aid the comprehension of source code in unfamiliar programming languages. However, the great majority of source code has no corresponding pseudo-code, because pseudo-code is redundant and laborious to create. If pseudo-code could be generated automatically and instantly from given source code, we could allow for on-demand production of pseudo-code without human effort. In this paper, we propose a method to automatically generate pseudo-code from source code, specifically adopting the statistical machine translation (SMT) framework. SMT, which was originally designed to translate between two natural languages, allows us to automatically learn the relationship between source code/pseudo-code pairs, making it possible to create a pseudo-code generator with less human effort. In experiments, we generated English or Japanese pseudo-code from Python statements using SMT, and find that the generated pseudo-code is largely accurate, and aids code understanding.
Subfields: Artificial Intelligence, Information Systems, Natural Language Processing
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Graham Neubig
- Luke S. Zettlemoyer
- Percy Liang
- Mohit Bansal
- Jianfeng Gao
- Caiming Xiong
- Jonathan Berant
- Richard Socher
In Information Systems
- Miltiadis Allamanis
- Charles Sutton
- Michael Pradel
- Graham Neubig
- Ge Li
- Percy Liang
- Earl T. Barr
- Zhi Jin
In Natural Language Processing
- Graham Neubig
- Luke S. Zettlemoyer
- Percy Liang
- Mohit Bansal
- Mirella Lapata
- Jonathan Berant
- Jianfeng Gao
- Caiming Xiong
Citations in the corpus
- SPoC: Search-based Pseudocode to Code (2019, background): “Table 1 shows that most existing datasets [22, 27, 16] have some varying levels of description, but lack mechanisms to validate the correctness of programs.”
- A Survey of Machine Learning for Big Code and Naturalness (2017, methodology): “odeling and resolving ambiguities in text and in code. Generating natural language from source code, i.e. code-to-text, has applications to code documentation and readability. For example, Oda et al. [146] translate Python code to pseudocode (in natural language) using machine translation techniques”
- Measuring Coding Challenge Competence With APPS (2021, methodology): “Oda et al. (2015) provide a language-to-code dataset using simple code comments.”
- Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Task (2018, background): “, 2015), DJANGO (Oda et al., 2015), HEARTHSTONE (Ling et al.”
- Latent Predictor Networks for Code Generation (2016, background): “Additionally, to test the model’s ability of generalize to other domains, we report results in the Django dataset (Oda et al., 2015), comprising of 16000 training, 1000 development and 1805 test annotations.”
- CodeBLEU: a Method for Automatic Evaluation of Code Synthesis (2020, methodology): “…rapid progress of code synthesis such as text-to-code synthesis, code translation and code change prediction (Karaivanov, Raychev, and Vechev 2014; Oda et al. 2015; Barone and Sennrich 2017; Chen, Liu, and Song 2018; Kanade et al. 2019; Husain et al. 2019; Feng et al. 2020; Dinella et al. 2020;…”
- Unsupervised Translation of Programming Languages (2020, methodology): “[37] trained a PBSMT model to generate pseudo-code.”
- A Convolutional Attention Network for Extreme Summarization of Source Code (2016, methodology): “e topic model. Allamanis et al. (2015b) create a generative model of source code snipA Convolutional Attention Network for Extreme Summarization of Source Code pets given a natural language query and Oda et al. (2015) use machine translation to convert source code into pseudocode. Closer to our work”
- Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflow (2018, methodology): “ore fine-grained, sub-code-block sized candidates, aiming to recover code solutions that exactly answer the intent. Finally, some work has asked programmers to manually write NL descriptions for code [20, 30], or vice-versa [41]. This allows for the generation of high-quality data, but is time consu”
- NL2Bash: A Corpus and Semantic Parser for Natural Language Interface to the Linux Operating System (2018, methodology): “Some other works (Oda et al., 2015) have adopted fuzzy evaluation metrics, such as BLEU, which is widely used to measure the translation quality between natural languages (Dod-dington, 2002).”
- Tree-to-tree Neural Networks for Program Translation (2018, methodology): “Some recent work have applied statistical machine translation techniques to program translation [2, 16, 22, 21, 23, 24].”
- JuICe: A Large Scale Distantly Supervised Dataset for Open Domain Context-based Code Generation (2019, background): “…NL utterance (Zettlemoyer and Collins, 2005; Iyer et al., 2017) to generate database queries (semantic parsing), single line python code (Yin et al., 2018; Oda et al., 2015), multi-line domain-specific code (Ling et al., 2016; Rabinovich et al., 2017), or sequences of API calls (Gu et al., 2016b).”
- Coarse-to-Fine Decoding for Neural Semantic Parsing (2018, methodology): “D JANGO is a diverse dataset, spanning various real-world use cases and as a result models are often faced with out-of-vocabulary (OOV) tokens (e.g., variable names, and numbers) that are un-seen during training.”
- TRANX: A Transition-based Neural Abstract Syntax Parser for Semantic Parsing and Code Generation (2018, methodology): “The DJANGO dataset (Oda et al., 2015) consists of 18,805 lines of Python source code extracted from the Django Web framework, with each line paired with an NL description.”
- StructVAE: Tree-structured Latent Variable Models for Semi-supervised Semantic Parsing (2018, methodology): “Code Generation The DJANGO dataset (Oda et al., 2015) contains 18,805 lines of Python source code extracted from the Django web framework.”
- Retrieval-Based Neural Code Generation (2018, methodology): “HS consists of Python classes that implement Hearthstone card descriptions while Django contains pairs of Python source code and English pseudo-code from Django web framework.”