CN109614111B - Method and apparatus for generating code - Google Patents

Method and apparatus for generating code Download PDF

Info

Publication number
CN109614111B
CN109614111B CN201811628283.9A CN201811628283A CN109614111B CN 109614111 B CN109614111 B CN 109614111B CN 201811628283 A CN201811628283 A CN 201811628283A CN 109614111 B CN109614111 B CN 109614111B
Authority
CN
China
Prior art keywords
statement
code
sentence
input
programming language
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201811628283.9A
Other languages
Chinese (zh)
Other versions
CN109614111A (en
Inventor
王硕寰
孙宇
王丽杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201811628283.9A priority Critical patent/CN109614111B/en
Publication of CN109614111A publication Critical patent/CN109614111A/en
Application granted granted Critical
Publication of CN109614111B publication Critical patent/CN109614111B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

The embodiment of the application discloses a method and a device for generating codes. One embodiment of the method comprises: acquiring an input statement submitted by a user, wherein the input statement is a command statement described in a natural language; selecting a statement described by a natural language as an input and a statement described by a target programming language as an output code statement generation model; and inputting the input sentence into the code sentence generation model to obtain the code sentence which corresponds to the semantics of the input sentence and is described by the target programming language. The implementation method can construct a natural language interactive programming technology, so that a person who does not know the details of the programming language can write a program by using the ordinary natural language, and the cost of the programming is reduced.

Description

Method and apparatus for generating code
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for generating codes.
Background
Programming refers to a process of specifying a certain operation mode for a certain computing system by a computer to solve a certain problem, operating the computing system according to the operation mode, and finally obtaining a corresponding result. In order for a computer to understand human intent, the idea, method, and means of solving the problem must be told to the computer in a form that the computer can understand (i.e., converting human intent into program code) so that the computer can work step by step according to human instructions to accomplish a certain task.
Currently, programming languages include imperative programming languages (e.g., SHELL, etc.), compiled class programming languages (e.g., C + +, JAVA, etc.), scripting languages (e.g., Python, Perl), database query languages, and the like. In general, different programming languages have different syntax specifications.
In any programming language, only professional developers (e.g., developers) who have deep knowledge of the details of the programming language can master the programming language, and the system has high cost for other non-background-knowledge industry personnel, so that the programming technology is difficult to popularize to other industry personnel.
It takes a lot of time and effort for a developer to grasp the grammar rules of different languages when programming using different languages is involved.
Disclosure of Invention
The embodiment of the application provides a method and a device for generating codes.
In a first aspect, an embodiment of the present application provides a method for generating a code, where the method includes: acquiring an input statement submitted by a user, wherein the input statement is a command statement described in a natural language; selecting a statement described by a natural language as an input and a statement described by a target programming language as an output code statement generation model; and inputting the input sentence into the code sentence generation model to obtain the code sentence which corresponds to the semantics of the input sentence and is described by the target programming language.
In some embodiments, the code statement generation model is trained by: acquiring a training sample set, wherein the training sample comprises a command statement described in a natural language and a code statement described in a target programming language corresponding to the semantics of the command statement; and taking the command sentences in the training samples in the training sample set as input, taking the code sentences corresponding to the input command sentences as output, and training the initial neural network by using a machine learning method to obtain a code sentence generation model.
In some embodiments, the code statement generation model includes an encoder and a decoder. Inputting an input statement into a code statement generation model to obtain a code statement which corresponds to the semantics of the input statement and is described in a target programming language, and the method comprises the following steps: inputting the input sentence into an encoder to obtain the encoded representation of the input sentence; taking the coded representation of the input statement as the current input information of a decoder, and executing a hierarchical semantic analysis step: inputting the current input information into a decoder to obtain an output statement; determining whether an identifier to be decoded exists in an output statement; and if the identifier to be decoded does not exist in the output statement, determining the output statement as a code statement.
In some embodiments, inputting the input sentence into the code sentence generation model, obtaining a code sentence described in the target programming language corresponding to the semantics of the input sentence, further comprising: if the identifier to be decoded exists in the output statement, the output statement is input into a decoder to obtain the coded representation of the output statement; and weighting the coded representation of the input statement and the coded representation of the output statement by adopting an attention mechanism, taking the processing result as the current input information of the decoder, and continuously executing the step of hierarchical semantic analysis.
In some embodiments, the encoder is a bi-directional recurrent neural network.
In a second aspect, an embodiment of the present application provides a method for transcoding, where the method includes: acquiring a source code statement described in a first programming language; selecting a sentence described by a first programming language as input and a sentence described by a natural language as output natural sentence generation model; inputting a source code statement into a natural statement generation model to obtain an intermediate statement which corresponds to the semantic meaning of the source code statement and is described in a natural language; selecting a statement described by a natural language as an input and a statement described by a second programming language as an output code statement generation model; and inputting the intermediate statement into the code statement generation model to obtain a target code statement which corresponds to the semantics of the intermediate statement and is described in the second programming language.
In some embodiments, the natural sentence generation model is trained by: acquiring a training sample set, wherein the training sample comprises a code statement described in a first programming language and a command statement described in a natural language corresponding to the semantics of the code statement; and taking the code sentences in the training samples in the training sample set as input, taking the command sentences corresponding to the input code sentences as output, and training the initial neural network by using a machine learning method to obtain a natural sentence generation model.
In a third aspect, an embodiment of the present application provides an apparatus for generating a code, where the apparatus includes: an input sentence acquisition unit configured to acquire an input sentence submitted by a user, wherein the input sentence is a command sentence described in a natural language; a model selecting unit configured to select a code sentence generation model in which a sentence described in a natural language is input and a sentence described in a target programming language is output; and a code sentence generation unit configured to input the input sentence into the code sentence generation model, resulting in a code sentence described in the target programming language corresponding to the semantics of the input sentence.
In some embodiments, the code statement generation model is trained by: acquiring a training sample set, wherein the training sample comprises a command statement described in a natural language and a code statement described in a target programming language corresponding to the semantics of the command statement; and taking the command sentences in the training samples in the training sample set as input, taking the code sentences corresponding to the input command sentences as output, and training the initial neural network by using a machine learning method to obtain a code sentence generation model.
In some embodiments, the code statement generation model includes an encoder and a decoder. The code statement generation unit includes: a first encoding module configured to input an input sentence into an encoder, resulting in an encoded representation of the input sentence; a hierarchical semantic parsing module configured to take the encoded representation of the input sentence as current input information of the decoder, perform a hierarchical semantic parsing step: inputting the current input information into a decoder to obtain an output statement; determining whether an identifier to be decoded exists in an output statement; and if the identifier to be decoded does not exist in the output statement, determining the output statement as a code statement.
In some embodiments, the code statement generation unit further comprises: the second coding module is configured to input the output statement into the decoder to obtain a coded representation of the output statement if the identifier to be decoded exists in the output statement; and the weighting processing module is configured to perform weighting processing on the coded representation of the input statement and the coded representation of the output statement by adopting an attention mechanism, and continue to perform the hierarchical semantic analysis step by taking a processing result as the current input information of the decoder.
In some embodiments, the encoder is a bi-directional recurrent neural network.
In a fourth aspect, an embodiment of the present application provides an apparatus for transcoding, where the apparatus includes: a source code statement acquisition unit configured to acquire a source code statement described in a first programming language; a first model selecting unit configured to select a natural sentence generation model in which a sentence described in a first programming language is input and a sentence described in a natural language is output; an intermediate sentence generation unit configured to input a source code sentence into a natural sentence generation model, resulting in an intermediate sentence described in a natural language corresponding to a semantic of the source code sentence; a second model selecting unit configured to select a code sentence generation model in which a sentence described in a natural language is input and a sentence described in a second programming language is output; and the target code statement generation unit is configured to input the intermediate statement into the code statement generation model, and obtain the target code statement which corresponds to the semantics of the intermediate statement and is described in the second programming language.
In some embodiments, the natural sentence generation model is trained by: acquiring a training sample set, wherein the training sample comprises a code statement described in a first programming language and a command statement described in a natural language corresponding to the semantics of the code statement; and taking the code sentences in the training samples in the training sample set as input, taking the command sentences corresponding to the input code sentences as output, and training the initial neural network by using a machine learning method to obtain a natural sentence generation model.
In a fifth aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when executed by one or more processors, cause the one or more processors to implement a method as described in any of the implementations of the first or second aspects.
In a sixth aspect, the present application provides a computer-readable medium, on which a computer program is stored, which, when executed by a processor, implements the method as described in any implementation manner of the first aspect or the second aspect.
According to the method and the device for generating the code, the command statement which is submitted by the user and described in the natural language is obtained, then the code statement generation model matched with the natural language and the target programming language is selected, and finally the command statement is input into the code statement generation model to obtain the code statement, so that a natural language interactive programming technology can be constructed, a person who does not know details of the programming language can write the program by using the normal natural language, and the cost of the programming is reduced.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a method for generating code in accordance with the present application;
FIG. 3 is a schematic diagram of an application scenario of a method for generating code according to the present application;
FIG. 4 is a flow diagram for one embodiment of a method for transcoding according to the present application;
FIG. 5 is a schematic block diagram of one embodiment of an apparatus for generating code according to the present application;
FIG. 6 is a schematic block diagram illustrating one embodiment of an apparatus for transcoding according to the present application;
FIG. 7 is a block diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of the present methods for generating code, methods for translating code, apparatuses for generating code, or apparatuses for translating code may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various communication client applications, such as a programming application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices that support programming, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server providing various services, such as a background server providing support for programming class applications running on the terminal devices 101, 102, 103. The server 105 can perform processing such as analysis on the received data such as the input sentence and feed back the processing result (e.g., code sentence) to the terminal apparatuses 101, 102, 103.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the method for generating code or the method for converting code provided by the embodiment of the present application is generally performed by the server 105, and accordingly, the apparatus for generating code or the apparatus for converting code is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for generating code in accordance with the present application is shown. The method for generating a code may include the steps of:
step 201, obtaining an input statement submitted by a user.
In this embodiment, an execution subject (e.g., the server 105 of fig. 1) on which the method for generating a code is executed may acquire an input sentence submitted by a user from a terminal device (e.g., the terminal devices 101, 102, 103 of fig. 1) by a wired connection manner or a wireless connection manner. The input sentence may be a command sentence described in a natural language. For example, "go through even numbers within 0 to 10", "calculate list3 so that each value thereof is the sum of the corresponding values of list1 and list 2", and so on. Here, the input sentence may be a sentence that the user inputs into the terminal device through an input device (e.g., a mouse, a keyboard, a touch screen, a microphone, etc.).
Natural language generally refers to a language that naturally evolves with culture, e.g., chinese, english, japanese, etc.
It should be noted that the Wireless connection manner may include, but is not limited to, a 3G (the 3rd generation)/4G (the 4th generation)/5G (the 5th generation), a Wi-Fi (Wireless-Fidelity) connection, a bluetooth connection, a WiMAX (Worldwide Interoperability for Microwave Access) connection, a Zigbee (also called Zigbee protocol) connection, an UWB (Ultra wide band) connection, and other Wireless connection manners now known or developed in the future.
Step 202, selecting a statement described in a natural language as an input and a statement described in a target programming language as an output code statement generation model.
In the present embodiment, an execution subject (for example, the server 105 of fig. 1) on which the method for generating code is executed may select a code statement generation model in which a statement described in a natural language is input and a statement described in a target programming language is output from a plurality of code statement generation models trained in advance. For example, a code statement generation model with an input statement in chinese and an output statement in Python programming statement is selected. The target programming language may be a predetermined programming language, such as Python, C + +, or the like.
Programming language (programming language), colloquially known as computer language, is a formal language used to define computer programs. It is a standardized communication technique used to instruct computers. Computer languages allow programmers to accurately define the data that the computer needs to use and accurately define the actions that should be taken under different circumstances.
In the present embodiment, the execution body may store a plurality of pre-trained code statement generation models, each of which corresponds to one programming language (in the case of natural language determination). The code statement generation model may be used to characterize a correspondence of a command statement described in a natural language and a code statement described in a programming language. As an example, the code sentence generation model may be a correspondence table in which correspondence between a plurality of command sentences and code sentences is stored, which is prepared in advance by a technician based on statistics of a large number of command sentences and code sentences.
In some optional implementations of this embodiment, the code statement generation model may be trained according to the following steps:
first, a set of training samples is obtained. Wherein each training sample may include command statements described in a natural language and code statements described in a target programming language. The code statements may correspond to the semantics of the command statements. Taking the target programming language as Python as an example, the command statement is "even number within 0 to 10, and the corresponding code statement may be" for i in range (0,10,2) ". The code statements may be obtained by annotating the command statements.
And then, taking the command sentence in each training sample in the training sample set as input, taking the code sentence corresponding to the input command sentence as output, and training the initial neural network by using a machine learning method to obtain a code sentence generation model. The initial neural network may include an Encoder and a Decoder (i.e., an Encoder-Decoder model). Here, the training method of the code statement generation model corresponding to each programming language may be the same.
Step 203, inputting the input sentence into the code sentence generation model to obtain the code sentence described in the target programming language corresponding to the semantics of the input sentence.
In this embodiment, an execution subject (for example, the server 105 in fig. 1) on which the method for generating code is executed may input the input sentence acquired in step 201 into the code sentence generation model selected in step 202, and obtain a code sentence described in the target programming language corresponding to the semantics of the input sentence. As an example, an input sentence "even number within 0 to 10 is traversed" is input to the selected code sentence generation model, and a code sentence "for i in range (0,10, 2)" is obtained.
As can be seen from the above, compared with the case of directly writing the program code using the designated programming language, the scheme provided by the embodiment does not need to spend a lot of time and effort to master the grammar rules of the programming language, and can realize the generation of the code statements using the natural language at ordinary times, thereby reducing the cost of the programming.
In some optional implementation manners of this embodiment, step 203 may specifically include the following steps:
first, the input sentence obtained in step 201 is input to the encoder of the code sentence generation model selected in step 202, and a coded representation (which may also be referred to as a context vector) of the input sentence is obtained.
Secondly, taking the coded representation in the first step as the current input information of the decoder of the code statement generation model selected in the step 202, and executing the following hierarchical semantic parsing steps: firstly, inputting current input information into a decoder to obtain an output statement, wherein the output statement can comprise a function described in a target programming language, a parameter (such as "pow (3, 3)"), and the like, and can also comprise an identifier to be decoded (such as "pow (# 2)", wherein "# 2" is the identifier to be decoded and indicates that the function "pow ()" has two parameters to be resolved); then, it is determined whether an identifier to be decoded exists in the output statement, if the identifier to be decoded does not exist in the output statement, it indicates that the hierarchical semantic analysis is completed, and the output statement may be determined as a code statement to be generated, otherwise, the third step and the fourth step to be described below are performed.
And thirdly, if the identifier to be decoded exists in the output statement, inputting the output statement into an encoder to obtain the encoded representation of the output statement.
And fourthly, weighting the coded representation of the input statement and the coded representation of the output statement by adopting an attention mechanism, taking the coded representation after weighting as the current input information of a decoder, and continuously executing the hierarchical semantic analysis step.
The following is a description by specific examples. In this example, the input statement is "calculate the square of x". The input sentence is encoded by the encoder and then input to the decoder to obtain an output sentence "pow (# 2)". At this time, since the output sentence has an identifier "# 2" to be decoded (that is, the hierarchical semantic analysis has not been completed and the semantic analysis of the next layer needs to be performed), the output sentence is encoded by the encoder and weighted with the vector of the input sentence. The weighted vector is again input into the decoder, resulting in another output statement "pow (x, 2)". At this time, the output statement "pow (x, 2)" is a Python code statement corresponding to the input statement "calculate the square of x", because there is no identifier to be decoded in the output statement.
It should be noted that the parameter value in the function may be obtained by parsing the word in the command statement (e.g., "2" for "square") or may be directly copied from the command statement (e.g., "x").
In some optional implementations of this embodiment, the encoder may be a Bi-directional Recurrent Neural Networks (BRNN). In a classical Recurrent Neural Network (RNN), the transmission of states is unidirectional from front to back, i.e. only "above" in the context is considered. And the BRNN can retain not only the information from front to back, but also the information from back to front. In this implementation, the BRNN is used as an encoder, which makes the code statement parsed by the decoder more accurate (because the function/parameter is related to both the preceding and following words in some cases).
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for generating a code according to the present embodiment. In the application scenario, a code statement of Python language needs to be generated by using a chinese statement, and the code statement generation model is obtained by training an initial encoder-decoder model using parallel corpora of natural language and Python language, where the encoder is BRNN and the decoder is RNN. Layer 1 decoding is performed first: the command statement submitted by the user is encoded by an encoder through calculation of x and then addition of 2 square, the encoding of the command statement is input into a decoder, and the code of the outermost layer is decoded into a pow function which has two parameters (indicated by #2), namely, the output statement of the layer 1 decoding is 'pow (# 2)'. In the figure, "< s >" represents the start of decoding, and "< e >" represents the end of decoding. Since there is an identifier "# 2" to be decoded in the output statement of layer 1 decoding, layer 2 decoding is continued: the output sentence of layer 1 is encoded, the encoding of the command sentence and the encoding of the output sentence of layer 1 are weighted and combined by the attention mechanism, and the combined encoding is input to the decoder, so that the output sentence "pow (#1+ #1, # 1)" decoded by layer 2 is obtained. Since the identifier to be decoded "# 1" still exists in the output statement of the layer 2 decoding, the layer 3 decoding is continued: the output sentence of the layer 2 is encoded, the encoding of the command sentence and the encoding of the output sentence of the layer 2 are weighted and combined by adopting an attention mechanism, and the combined encoding is input into a decoder, so that the output sentence 'point (int (#1) +2, 2)' decoded by the layer 3 is obtained. … … and so on, the weighted combination of the coding of the command statement and the coding of the (n-1) th layer (n is a natural number larger than 3) is used as the input of the decoding of the nth layer until the obtained output statement has no identifier to be decoded, thus obtaining the output statement "point (int (x) +2, 2)", and the statement is used as the Python language code statement of the command statement.
According to the method provided by the embodiment of the application, the command statement which is submitted by the user and described in the natural language is obtained, then the code statement generation model matched with the natural language and the target programming language is selected, and finally the command statement is input into the code statement generation model to obtain the code statement, so that a natural language interactive programming technology can be established, a person who does not know details of the programming language can write a program by using the natural language at ordinary times, and the cost of the programming is reduced.
With continued reference to FIG. 4, a flow 400 of one embodiment of a method for transcoding in accordance with the present application is shown. The method for converting code may include the steps of:
in step 401, a source code statement described in a first programming language is obtained.
In this embodiment, the execution subject (e.g., the server 105 of fig. 1) on which the method for converting code operates may acquire the source code statements from the terminal device (e.g., the terminal devices 101, 102, 103 of fig. 1) by a wired connection manner or a wireless connection manner. Wherein the source code statement may be a code statement described in a first encoding language. For example, Python statements "for i in range (0,10, 2)", "list 3 ═ [ (a + b) for a, b in zip (list1, list2) ], and the like. Here, the first programming language may be a preset programming language, for example, Python, C + +, or the like.
Step 402, selecting a natural language sentence generation model using a sentence described in a first programming language as an input and a sentence described in a natural language as an output.
In the present embodiment, an execution subject (e.g., the server 105 of fig. 1) on which the method for converting code is executed may select a natural sentence generation model in which a sentence described in a first programming language is input and a sentence described in a natural language is output from a plurality of natural sentence generation models trained in advance. For example, a natural sentence generation model with an input sentence being Python and an output sentence being chinese is selected.
In the present embodiment, the execution body may store a plurality of pre-trained natural language sentence generation models, each of which corresponds to one programming language (in the case where a natural language is determined). The natural language sentence generation model may be used to characterize the correspondence of code sentences described in a programming language and command sentences described in a natural language. As an example, the natural sentence generation model may be a correspondence table in which correspondence between a plurality of code sentences and command sentences is stored, which is prepared in advance by a technician based on statistics of a large number of code sentences and command sentences.
In some optional implementations of this embodiment, the natural language sentence generation model may be trained according to the following steps:
first, a set of training samples is obtained. Wherein each training sample may include a code statement described in a first programming language and a command statement described in a natural language. The command statement may correspond to the semantics of the code statement. Taking the first programming language as Python as an example, the code statement may be "for i in range (0,10, 2)", and the corresponding command statement is "even number within 0 to 10. The command statement may be obtained by annotating the code statement.
And then, taking the code sentence in each training sample in the training sample set as input, taking the command sentence corresponding to the input code sentence as output, and training the initial neural network by using a machine learning method to obtain a natural sentence generation model. The initial neural network may include an Encoder and a Decoder (i.e., an Encoder-Decoder model). Here, the training method of the natural sentence generation model corresponding to each programming language may be the same.
Step 403, inputting the source code statement into the natural language statement generation model, and obtaining an intermediate statement described in the natural language corresponding to the semantic meaning of the source code statement.
In this embodiment, an execution subject (for example, the server 105 in fig. 1) on which the method for converting code operates may input the source code statement acquired in step 401 into the natural language statement generation model selected in step 402, and obtain an intermediate statement described in a natural language corresponding to the semantic meaning of the source code statement. As an example, a source code sentence "for i in range (0,10, 2)" is input into the selected natural sentence generation model, resulting in an intermediate sentence "even number within 0 to 10 traversed".
Step 404, selecting a code statement generation model using a statement described in a natural language as an input and a statement described in a second programming language as an output.
In the present embodiment, an execution subject (e.g., the server 105 of fig. 1) on which the method for converting code is executed may select a code statement generation model in which a statement described in a natural language is input and a statement described in a second programming language is output from among a plurality of code statement generation models trained in advance. For example, a code statement generation model is selected in which an input statement is a chinese language and an output statement is a JAVA programming statement. Here, the second programming language may be a different programming language from the first programming language. For example, the first programming language is Python and the second programming language is Perl. Alternatively, the first programming language is JAVA and the second programming language is C + +.
Step 405, inputting the intermediate statement into the code statement generation model, and obtaining the target code statement described in the second programming language corresponding to the semantics of the intermediate statement.
In this embodiment, the execution subject (for example, the server 105 in fig. 1) on which the method for converting code operates may input the intermediate statement generated in step 403 into the code statement generation model selected in step 404, and obtain a code statement described in the second programming language corresponding to the semantics of the intermediate statement. As an example, an intermediate statement "traverse an even number within 0 to 10" is input to the selected code statement generation model, resulting in a JAVA code statement "for (i ═ 0; i ≦ 10; i ═ i + 2)".
In the method provided by the above embodiment of the application, the source code statement described by the first programming language is acquired, then the source code statement is input into the natural statement generation model matched with the first programming language to obtain the intermediate statement, and finally the intermediate statement is input into the code statement generation model matched with the second programming language to obtain the target code statement, so that code conversion can be performed between different programming languages without mastering grammatical details of the programming languages.
With further reference to fig. 5, as an implementation of the method shown in fig. 2, the present application provides an embodiment of an apparatus for generating a code, which corresponds to the embodiment of the method shown in fig. 2, and which is particularly applicable in a server.
As shown in fig. 5, the apparatus 500 for generating a code of the present embodiment may include an input sentence acquisition unit 501, a model selection unit 502, and a code sentence generation unit 503. The input sentence acquisition unit 501 may be configured to acquire an input sentence submitted by a user, where the input sentence is a command sentence described in a natural language. The model selection unit 502 may be configured to select a code statement generation model in which a statement described in a natural language is input and a statement described in a target programming language is output. The code sentence generation unit 503 may be configured to input an input sentence into the code sentence generation model, resulting in a code sentence described in the target programming language corresponding to the semantics of the input sentence.
In this embodiment, the input sentence acquisition unit 501 of the apparatus 500 for generating a code of this embodiment may acquire an input sentence submitted by a user from a terminal device (e.g., the terminal devices 101, 102, 103 of fig. 1) by a wired connection manner or a wireless connection manner.
The input sentence may be a command sentence described in a natural language. For example, "go through even numbers within 0 to 10", "calculate list3 so that each value thereof is the sum of the corresponding values of list1 and list 2", and so on. Here, the input sentence may be a sentence that the user inputs into the terminal device through an input device (e.g., a mouse, a keyboard, a touch screen, a microphone, etc.).
In this embodiment, the model selecting unit 502 may select a code sentence generation model in which a sentence described in a natural language is input and a sentence described in a target programming language is output from a plurality of code sentence generation models trained in advance. For example, a code statement generation model with an input statement in chinese and an output statement in Python programming statement is selected. The target programming language may be a predetermined programming language, such as Python, C + +, or the like.
In some optional implementations of this embodiment, the code statement generation model may be trained according to the following steps:
first, a set of training samples is obtained. Wherein each training sample may include command statements described in a natural language and code statements described in a target programming language. The code statements may correspond to the semantics of the command statements. Taking the target programming language as Python as an example, the command statement is "even number within 0 to 10, and the corresponding code statement may be" for i in range (0,10,2) ". The code statements may be obtained by annotating the command statements.
And then, taking the command sentence in each training sample in the training sample set as input, taking the code sentence corresponding to the input command sentence as output, and training the initial neural network by using a machine learning method to obtain a code sentence generation model. The initial neural network may include an Encoder and a Decoder (i.e., an Encoder-Decoder model). Here, the training method of the code statement generation model corresponding to each programming language may be the same.
In this embodiment, the code sentence generating unit 503 inputs the input sentence acquired by the input sentence acquiring unit 501 into the code sentence generation model selected by the model selecting unit 502, and obtains a code sentence described in the target programming language corresponding to the semantics of the input sentence. As an example, an input sentence "even number within 0 to 10 is traversed" is input to the selected code sentence generation model, and a code sentence "for i in range (0,10, 2)" is obtained.
As can be seen from the above, compared with the case of directly writing the program code using the designated programming language, the scheme provided by the embodiment does not need to spend a lot of time and effort to master the grammar rules of the programming language, and can realize the generation of the code statements using the natural language at ordinary times, thereby reducing the cost of the programming.
In some optional implementations of this embodiment, the code statement generating unit 503 may specifically include a first encoding module and a hierarchical semantic parsing module. Wherein the first encoding module may be configured to input the input sentence into the encoder, resulting in an encoded representation of the input sentence. The hierarchical semantic parsing module may be configured to perform the hierarchical semantic parsing step with the encoded representation of the input sentence as current input information to the decoder: inputting the current input information into a decoder to obtain an output statement; determining whether an identifier to be decoded exists in an output statement; and if the identifier to be decoded does not exist in the output statement, determining the output statement as a code statement.
In some optional implementations of this embodiment, the code statement generating unit 503 may further include a second encoding module and a weighting processing module. The second encoding module may be configured to, if the identifier to be decoded exists in the output statement, input the output statement into the decoder, so as to obtain an encoded representation of the output statement. The weighting processing module can be configured to apply an attention mechanism to carry out weighting processing on the coded representation of the input statement and the coded representation of the output statement, take the processing result as the current input information of the decoder, and continue to execute the hierarchical semantic parsing step.
In some optional implementations of this embodiment, the encoder may be a Bi-directional Recurrent Neural Networks (BRNN).
According to the device provided by the embodiment of the application, the command statement which is submitted by the user and described in the natural language is obtained, then the code statement generation model matched with the natural language and the target programming language is selected, and finally the command statement is input into the code statement generation model to obtain the code statement, so that a natural language interactive programming technology can be established, a person who does not know details of the programming language can write a program by using the natural language at ordinary times, and the cost of the programming is reduced.
With continuing reference to fig. 6, as an implementation of the method shown in fig. 4, the present application provides an embodiment of an apparatus for transcoding, which corresponds to the embodiment of the method shown in fig. 4, and which may be applied in a server in particular.
As shown in fig. 6, the apparatus 600 for converting code of the present embodiment may include a source code statement acquisition unit 601, a first model selection unit 602, an intermediate statement generation unit 603, a second model selection unit 604, and a target code statement generation unit 605. Among them, the source code statement acquisition unit 601 may be configured to acquire a source code statement described in the first programming language. The first model selecting unit 602 may be configured to select a natural sentence generation model in which a sentence described in a first programming language is an input and a sentence described in a natural language is an output. The intermediate sentence generation unit 603 may be configured to input the source code sentence into the natural sentence generation model, resulting in an intermediate sentence described in the natural language corresponding to the semantics of the source code sentence. The second model selecting unit 604 may be configured to select a code statement generation model in which a statement described in a natural language is an input and a statement described in a second programming language is an output. The object code statement generation unit 605 may be configured to input the intermediate statement into the code statement generation model, resulting in the object code statement described in the second programming language corresponding to the semantics of the intermediate statement.
In this embodiment, the source code statement acquisition unit 601 of the apparatus 600 for transcoding acquires a source code statement from a terminal device (e.g., the terminal devices 101, 102, 103 of fig. 1) by a wired connection manner or a wireless connection manner. Wherein the source code statement may be a code statement described in a first encoding language. For example, Python statements "for i in range (0,10, 2)", "list 3 ═ [ (a + b) for a, b in zip (list1, list2) ], and the like. Here, the first programming language may be a preset programming language, for example, Python, C + +, or the like.
In the present embodiment, the first model selecting unit 602 selects a natural language sentence generation model in which a sentence described in a first programming language is input and a sentence described in a natural language is output from a plurality of natural language sentence generation models trained in advance. For example, a natural sentence generation model with an input sentence being Python and an output sentence being chinese is selected.
In this embodiment, the intermediate sentence generating unit 603 may input the source code sentence acquired by the source code sentence acquiring unit 601 into the natural sentence generating model selected by the first model selecting unit 602, and obtain an intermediate sentence described in a natural language corresponding to the semantic meaning of the source code sentence. As an example, a source code sentence "for i in range (0,10, 2)" is input into the selected natural sentence generation model, resulting in an intermediate sentence "even number within 0 to 10 traversed".
In the present embodiment, the second model selecting unit 604 selects a code sentence generating model in which a sentence described in a natural language is input and a sentence described in a second programming language is output from among a plurality of code sentence generating models trained in advance. For example, a code statement generation model is selected in which an input statement is a chinese language and an output statement is a JAVA programming statement. Here, the second programming language may be a different programming language from the first programming language. For example, the first programming language is Python and the second programming language is Perl. Alternatively, the first programming language is JAVA and the second programming language is C + +.
In this embodiment, the target code sentence generating unit 605 may input the intermediate sentence generated by the intermediate sentence generating unit 603 to the code sentence generation model selected by the second model selecting unit 604, and obtain the code sentence described in the second programming language corresponding to the semantic meaning of the intermediate sentence. As an example, an intermediate statement "traverse an even number within 0 to 10" is input to the selected code statement generation model, resulting in a JAVA code statement "for (i ═ 0; i ≦ 10; i ═ i + 2)".
In some optional implementations of this embodiment, the natural language sentence generation model may be trained according to the following steps:
first, a set of training samples is obtained. Wherein each training sample may include a code statement described in a first programming language and a command statement described in a natural language. The command statement may correspond to the semantics of the code statement. Taking the first programming language as Python as an example, the code statement may be "for i in range (0,10, 2)", and the corresponding command statement is "even number within 0 to 10. The command statement may be obtained by annotating the code statement.
And then, taking the code sentence in each training sample in the training sample set as input, taking the command sentence corresponding to the input code sentence as output, and training the initial neural network by using a machine learning method to obtain a natural sentence generation model. The initial neural network may include an Encoder and a Decoder (i.e., an Encoder-Decoder model). Here, the training method of the natural sentence generation model corresponding to each programming language may be the same.
The apparatus provided in the foregoing embodiment of the present application obtains a source code statement described in a first programming language, inputs the source code statement into a natural statement generation model matched with the first programming language to obtain an intermediate statement, and inputs the intermediate statement into a code statement generation model matched with a second programming language to obtain a target code statement, so that code conversion can be performed between different programming languages without mastering details of the programming languages.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use in implementing a server according to embodiments of the present application. The server shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse (or a microphone), and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program performs the above-described functions defined in the method of the embodiment of the present application when executed by the Central Processing Unit (CPU) 701.
It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for embodiments of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an input sentence acquisition unit, a model selection unit, and a code sentence generation unit. Here, the names of these units do not constitute a limitation to the unit itself in some cases, and for example, the input sentence acquisition unit may also be described as a "unit that acquires an input sentence submitted by a user".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: acquiring an input statement submitted by a user, wherein the input statement is a command statement described in a natural language; selecting a statement described by a natural language as an input and a statement described by a target programming language as an output code statement generation model; and inputting the input sentence into the code sentence generation model to obtain the code sentence which corresponds to the semantics of the input sentence and is described by the target programming language. Alternatively, the one or more programs, when executed by the apparatus, cause the apparatus to: acquiring a source code statement described in a first programming language; selecting a sentence described by a first programming language as input and a sentence described by a natural language as output natural sentence generation model; inputting a source code statement into a natural statement generation model to obtain an intermediate statement which corresponds to the semantic meaning of the source code statement and is described in a natural language; selecting a statement described by a natural language as an input and a statement described by a second programming language as an output code statement generation model; and inputting the intermediate statement into the code statement generation model to obtain a target code statement which corresponds to the semantics of the intermediate statement and is described in the second programming language.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (11)

1. A method for generating code, comprising:
acquiring an input statement submitted by a user, wherein the input statement is a command statement described in a natural language;
selecting a code statement generation model which takes a statement described in the natural language as input and a statement described in a target programming language as output from a plurality of pre-trained code statement generation models, wherein each code statement generation model in the plurality of code statement generation models corresponds to one programming language;
and inputting the input statement into the code statement generation model to obtain a code statement which corresponds to the semantics of the input statement and is described by the target programming language.
2. The method of claim 1, wherein the code statement generation model is trained by:
acquiring a training sample set, wherein the training sample comprises a command statement described in the natural language and a code statement described in the target programming language corresponding to the semantics of the command statement;
and taking the command sentences in the training samples in the training sample set as input, taking the code sentences corresponding to the input command sentences as output, and training the initial neural network by using a machine learning method to obtain the code sentence generation model.
3. The method of claim 1 or 2, wherein the code statement generation model comprises an encoder and a decoder; and
the inputting the input statement into the code statement generation model to obtain a code statement described in the target programming language and corresponding to the semantics of the input statement includes:
inputting the input sentence into the encoder to obtain an encoded representation of the input sentence;
taking the coded representation of the input statement as the current input information of the decoder, and executing a hierarchical semantic parsing step: inputting the current input information into the decoder to obtain an output statement; determining whether an identifier to be decoded exists in an output statement; and if the identifier to be decoded does not exist in the output statement, determining the output statement as a code statement.
4. The method of claim 3, wherein the inputting the input statement into the code statement generation model resulting in a code statement described in the target programming language corresponding to semantics of the input statement, further comprising:
if the identifier to be decoded exists in the output statement, the output statement is input into the decoder to obtain the coded representation of the output statement;
and weighting the coded representation of the input statement and the coded representation of the output statement by adopting an attention mechanism, taking a processing result as the current input information of the decoder, and continuously executing the hierarchical semantic analysis step.
5. The method of claim 3, wherein the encoder is a bi-directional recurrent neural network.
6. A method for transcoding, comprising:
acquiring a source code statement described in a first programming language;
selecting a sentence described by the first programming language as an input and a sentence described by a natural language as an output natural sentence generation model;
inputting the source code statement into the natural statement generation model to obtain an intermediate statement which corresponds to the semantic of the source code statement and is described in the natural language;
selecting a statement described by the natural language as an input and a statement described by a second programming language as an output code statement generation model;
and inputting the intermediate statement into the code statement generation model to obtain a target code statement which corresponds to the semantics of the intermediate statement and is described by the second programming language.
7. The method of claim 6, wherein the natural sentence generation model is trained by:
acquiring a training sample set, wherein the training sample comprises a code statement described in the first programming language and a command statement described in the natural language corresponding to the semantics of the code statement;
and taking the code sentences in the training samples in the training sample set as input, taking the command sentences corresponding to the input code sentences as output, and training the initial neural network by using a machine learning method to obtain the natural sentence generation model.
8. An apparatus for generating code, comprising:
an input sentence acquisition unit configured to acquire an input sentence submitted by a user, wherein the input sentence is a command sentence described in a natural language;
a model selecting unit configured to select a code sentence generation model, which is described in the natural language as an input and a sentence described in a target programming language as an output, from among a plurality of code sentence generation models trained in advance, wherein each of the plurality of code sentence generation models corresponds to one programming language;
a code sentence generation unit configured to input the input sentence into the code sentence generation model, resulting in a code sentence described in the target programming language corresponding to a semantic of the input sentence.
9. An apparatus for transcoding, comprising:
a source code statement acquisition unit configured to acquire a source code statement described in a first programming language;
a first model selecting unit configured to select a natural sentence generation model in which a sentence described in the first programming language is input and a sentence described in a natural language is output;
an intermediate sentence generation unit configured to input the source code sentence into the natural sentence generation model, resulting in an intermediate sentence described in the natural language corresponding to a semantic of the source code sentence;
a second model selecting unit configured to select a code sentence generation model in which a sentence described in the natural language is input and a sentence described in a second programming language is output;
a target code statement generation unit configured to input the intermediate statement into the code statement generation model, resulting in a target code statement described in the second programming language corresponding to a semantic of the intermediate statement.
10. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
11. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN201811628283.9A 2018-12-28 2018-12-28 Method and apparatus for generating code Active CN109614111B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811628283.9A CN109614111B (en) 2018-12-28 2018-12-28 Method and apparatus for generating code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811628283.9A CN109614111B (en) 2018-12-28 2018-12-28 Method and apparatus for generating code

Publications (2)

Publication Number Publication Date
CN109614111A CN109614111A (en) 2019-04-12
CN109614111B true CN109614111B (en) 2022-02-01

Family

ID=66016136

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811628283.9A Active CN109614111B (en) 2018-12-28 2018-12-28 Method and apparatus for generating code

Country Status (1)

Country Link
CN (1) CN109614111B (en)

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111857677A (en) * 2019-04-18 2020-10-30 天津五八到家科技有限公司 Software development method and device, electronic equipment and system
CN110442333A (en) * 2019-07-11 2019-11-12 北京磨刀刻石科技有限公司 Method and apparatus based on design drawing automatically generating program code
CN110488755A (en) * 2019-08-21 2019-11-22 江麓机电集团有限公司 A kind of conversion method of numerical control G code
CN110941427B (en) * 2019-11-15 2023-10-20 珠海豹趣科技有限公司 Code generation method and code generator
CN112987653B (en) * 2019-12-17 2022-04-15 深圳市恒控科技有限公司 Method and device for converting Chinese program into G code
US20210232873A1 (en) * 2020-01-24 2021-07-29 Nvidia Corporation Instruction generation using one or more neural networks
CN112255962A (en) * 2020-10-30 2021-01-22 浙江佳乐科仪股份有限公司 PLC programming system based on artificial intelligence
CN112306497B (en) * 2020-11-03 2024-04-26 高炼 Method and system for converting natural language into program code
CN112732264A (en) * 2020-12-30 2021-04-30 中国船舶重工集团公司第七0九研究所 Automatic code conversion method between high-level programming languages
CN112346737B (en) * 2021-01-08 2021-04-13 深圳壹账通智能科技有限公司 Method, device and equipment for training programming language translation model and storage medium
CN112799655A (en) * 2021-01-26 2021-05-14 浙江香侬慧语科技有限责任公司 Multi-type code automatic generation method, device and medium based on pre-training
CN116719520B (en) * 2023-08-07 2023-11-17 支付宝(杭州)信息技术有限公司 Code generation method and device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106980683A (en) * 2017-03-30 2017-07-25 中国科学技术大学苏州研究院 Blog text snippet generation method based on deep learning
CN108073392A (en) * 2017-12-29 2018-05-25 上海宽全智能科技有限公司 Intelligence programming method, equipment and storage medium based on natural language
CN108304436A (en) * 2017-09-12 2018-07-20 深圳市腾讯计算机系统有限公司 The generation method of style sentence, the training method of model, device and equipment
CN108733359A (en) * 2018-06-14 2018-11-02 北京航空航天大学 A kind of automatic generation method of software program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106980683A (en) * 2017-03-30 2017-07-25 中国科学技术大学苏州研究院 Blog text snippet generation method based on deep learning
CN108304436A (en) * 2017-09-12 2018-07-20 深圳市腾讯计算机系统有限公司 The generation method of style sentence, the training method of model, device and equipment
CN108073392A (en) * 2017-12-29 2018-05-25 上海宽全智能科技有限公司 Intelligence programming method, equipment and storage medium based on natural language
CN108733359A (en) * 2018-06-14 2018-11-02 北京航空航天大学 A kind of automatic generation method of software program

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"A Grammar-Based Structural CNN Decoder for Code Generation";Zeyu Suny,Qihao Zhu等;《https://arxiv.org/abs/1811.06837》;20181114;正文第1-8页 *
"北大新成果!首次成功地将CNN解码器用于代码生成";企鹅号-谈科技的雅韵;《https://cloud.tencent.com/developer/news/361318》;20181125;全文 *
Zeyu Suny,Qihao Zhu等."A Grammar-Based Structural CNN Decoder for Code Generation".《https://arxiv.org/abs/1811.06837》.2018,正文第1-8页. *

Also Published As

Publication number Publication date
CN109614111A (en) 2019-04-12

Similar Documents

Publication Publication Date Title
CN109614111B (en) Method and apparatus for generating code
KR102401942B1 (en) Method and apparatus for evaluating translation quality
CN108388425B (en) Method for automatically completing codes based on LSTM
CN109063174B (en) Query answer generation method and device, computer storage medium and electronic equipment
CN110032633B (en) Multi-turn dialogue processing method, device and equipment
CN108563433B (en) Device based on LSTM automatic completion code
CN111159220B (en) Method and apparatus for outputting structured query statement
KR20190073525A (en) Implicit bridging of machine learning tasks
JP2021108094A (en) Method and device for generating interactive models
CN109657251B (en) Method and device for translating sentences
CN109739483B (en) Method and device for generating statement
CN109635197B (en) Searching method, searching device, electronic equipment and storage medium
CN111382261B (en) Abstract generation method and device, electronic equipment and storage medium
CN112668338B (en) Clarification problem generation method and device and electronic equipment
CN111104796B (en) Method and device for translation
CN114154518A (en) Data enhancement model training method and device, electronic equipment and storage medium
CN115238045A (en) Method, system and storage medium for extracting generation type event argument
Zheng et al. BIM-GPT: a prompt-based virtual Assistant framework for BIM information retrieval
CN111027333B (en) Chapter translation method and apparatus
CN116662496A (en) Information extraction method, and method and device for training question-answering processing model
CN111125154B (en) Method and apparatus for outputting structured query statement
CN115810068A (en) Image description generation method and device, storage medium and electronic equipment
US11669307B2 (en) Code injection from natural language derived intent
CN115620726A (en) Voice text generation method, and training method and device of voice text generation model
CN109800438B (en) Method and apparatus for generating information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant