Looking for breakthrough ideas for innovation challenges? Try Patsnap Eureka!

Method for automatically generating Python codes from natural language

A natural language and automatic generation technology, applied in the direction of creating/generating source code, code compilation, program code conversion, etc., can solve problems such as semantic loss and lack of semantic constraints

Active Publication Date: 2019-11-22
NORTHEASTERN UNIV
View PDF4 Cites 7 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

However, when the above-mentioned Encoder-Decoder model handles the conversion from natural language to programming language, Encoder and Decoder process two different languages ​​respectively. Due to the difference in the neural network used by Encoder and Decoder, and the depth of the network, natural language description The semantics of the program will be gradually lost in the process of code generation, so there is a lack of a training model with strong semantic constraints

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Method for automatically generating Python codes from natural language
  • Method for automatically generating Python codes from natural language
  • Method for automatically generating Python codes from natural language

Examples

Experimental program
Comparison scheme
Effect test

Embodiment Construction

[0036] The specific embodiments of the present invention will be described in detail below in conjunction with the technical solutions and accompanying drawings.

[0037] A method to automatically generate Python code from natural language. The proposed GANCoder system is generally a generative confrontation network, including two parts, the generator and the discriminator, such as image 3 shown. Where the generator is an Encoder-Decoder model, such as Figure 4 As shown, the Encoder is responsible for encoding the natural language description sequence, using a two-way LSTM network, while the Decoder decodes the semantics encoded by the Encoder into the abstract syntax tree of the program, using a one-way LSTM network; and the discriminator is mainly responsible for judging the natural language description and Whether the semantics of the abstract syntax tree are consistent, the generator Encoder is used for the semantic encoding of the natural language description, and the ...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention belongs to the technical field of natural language processing, and particularly relates to a method for automatically generating Python codes from natural languages. The method comprisesthe following steps of: 1, generating an abstract syntax tree of a program fragment according to natural language description by adopting a generator of the GAN; 2, judging whether the semanteme of the abstract syntax tree generated by the generator is consistent with the semanteme described by a given natural language or not by adopting a GAN discriminator; and 3, training a generator and a discriminator of the GAN together. According to the method, a code generation system is generated through generative adversarial network optimization training, and the system can generate a section of program code with the same function according to natural language description of one function given by a user. Compared with a traditional optimization method, the generative adversarial network is usedfor adversarial game training, and the generator can learn language models of natural languages and programming languages more effectively.

Description

technical field [0001] The invention belongs to the technical field of natural language processing, and in particular relates to a method for automatically generating Python codes from natural language. Background technique [0002] Semantic analysis task is a type of task in the field of natural language processing. It mainly studies how to convert a given natural language description text into a logical representation that a computer can understand and execute, such as SQL, Python, Java, etc. . The traditional method is to design a fixed template according to the characteristics of the programming language, and then use pattern matching to parse the natural language description into each instance in the template. With the development of deep learning technology, deep learning frameworks such as Encoder-Decoder have also been introduced into semantic analysis and analysis tasks, such as using machine translation to directly translate natural description language sequences ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
IPC IPC(8): G06F8/30G06F8/41
CPCG06F8/30G06F8/436
Inventor 祝亚兵张岩峰
Owner NORTHEASTERN UNIV
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Patsnap Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Patsnap Eureka Blog
Learn More
PatSnap group products