A Syntactic Neural Model for General-Purpose Code Generation

40077

Authors

nan

Abstract

AbstractWe consider the problem of parsing natural language descriptions into source code written in a general-purpose programming language like Python. Existing data-driven methods treat this problem as a language generation task without considering the underlying syntax of the target programming language. Informed by previous work in semantic parsing, in this paper we propose a novel neural architecture powered by a grammar model to explicitly capture the target syntax as prior knowledge. Experiments find this an effective way to scale up to generation of complex programs from natural language descriptions, achieving state-of-the-art results that well outperform previous code generation and semantic parsing approaches.

Keywords

nan

Full Content

Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, pages 440–450 Vancouver, Canada, July 30 - August 4, 2017. c⃝2017 Association for Computational Linguistics https://doi.org/10.18653/v1/P17-1041 Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics, pages 440–450 Vancouver, Canada, July 30 - August 4, 2017. c⃝2017 Association for Computational Linguistics https://doi.org/10.18653/v1/P17-1041 A Syntactic Neural Model for General-Purpose Code Generation Pengcheng Yin Language Technologies Institute Carnegie Mellon University pcyin@cs.cmu.edu Graham Neubig Language Technologies Institute Carnegie Mellon University gneubig@cs.cmu.edu Abstract We consider the problem of parsing natu- ral language descriptions into source code written in a general-purpose programming language like Python. Existing data- driven methods treat this problem as a lan- guage generation task without considering the underlying syntax of the target pro- gramming language. Informed by previ- ous work in semantic parsing, in this pa- per we propose a novel neural architecture powered by a grammar model to explicitly capture the target syntax as prior knowl- edge. Experiments find this an effective way to scale up to generation of complex programs from natural language descrip- tions, achieving state-of-the-art results that well outperform previous code generation and semantic parsing approaches. 1 Introduction Every programmer has experienced the situation where they know what they want to do, but do not have the ability to turn it into a concrete im- plementation. For example, a Python programmer may want to “sort my list in descending order,” but not be able to come up with the proper syn- tax sorted(my list, reverse=True) to real- ize his intention. To resolve this impasse, it is common for programmers to search the web in natural language (NL), find an answer, and mod- ify it into the desired form (Brandt et al., 2009, 2010). However, this is time-consuming, and thus the software engineering literature is ripe with methods to directly generate code from NL descriptions, mostly with hand-engineered meth- ods highly tailored to specific programming lan- guages (Balzer, 1985; Little and Miller, 2009; Gvero and Kuncak, 2015). In parallel, the NLP community has developed methods for data-driven semantic parsing, which attempt to map NL to structured logical forms ex- ecutable by computers. These logical forms can be general-purpose meaning representations (Clark and Curran, 2007; Banarescu et al., 2013), for- malisms for querying knowledge bases (Tang and Mooney, 2001; Zettlemoyer and Collins, 2005; Berant et al., 2013) and instructions for robots or personal assistants (Artzi and Zettlemoyer, 2013; Quirk et al., 2015; Misra et al., 2015), among oth- ers. While these methods have the advantage of being learnable from data, compared to the pro- gramming languages (PLs) in use by program- mers, the domain-specific languages targeted by these works have a schema and syntax that is rela- tively simple. Recently, Ling et al. (2016) have proposed a data-driven code generation method for high-level, general-purpose PLs like Python and Java. This work treats code generation as a sequence-to- sequence modeling problem, and introduce meth- ods to generate words from character-level mod- els, and copy variable names …

Content truncated to 500 words

Labeled Text

AbstractWe consider the problem of parsing natural language descriptions into source code written in a general-purpose programming language like Python. Existing data-driven methods treat this problem as a language generation task without considering the underlying syntax of the target programming language. Informed by previous work in semantic parsing, in this paper we propose a novel neural architecture powered by a grammar model to explicitly capture the target syntax as prior knowledge. Experiments find this an effective way to scale up to generation of complex programs from natural language descriptions, achieving state-of-the-art results that well outperform previous code generation and semantic parsing approaches.

Publication Details

Paper ID:
40077
Year:
2017
Publication:
TIPSTER
Publication Type:
conf
DOI:
nan