CN110442332A - Natural language is converted into the method, apparatus and computer equipment of program language - Google Patents

Natural language is converted into the method, apparatus and computer equipment of program language Download PDF

Info

Publication number
CN110442332A
CN110442332A CN201910600648.5A CN201910600648A CN110442332A CN 110442332 A CN110442332 A CN 110442332A CN 201910600648 A CN201910600648 A CN 201910600648A CN 110442332 A CN110442332 A CN 110442332A
Authority
CN
China
Prior art keywords
entity
natural language
template
slot
program
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.)
Pending
Application number
CN201910600648.5A
Other languages
Chinese (zh)
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.)
OneConnect Smart Technology Co Ltd
Original Assignee
OneConnect Smart 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 OneConnect Smart Technology Co Ltd filed Critical OneConnect Smart Technology Co Ltd
Priority to CN201910600648.5A priority Critical patent/CN110442332A/en
Publication of CN110442332A publication Critical patent/CN110442332A/en
Priority to PCT/CN2019/122480 priority patent/WO2021000512A1/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3347Query execution using vector based model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • 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)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Stored Programmes (AREA)
  • Machine Translation (AREA)

Abstract

This application discloses method, apparatus and computer equipment that natural language is converted into program language, wherein the method that natural language is converted into program language, comprising: obtains the natural language sentence of user's input;All entity types for including in the natural language sentence are distinguished, and extract the corresponding entity of all entity types;Natural language template is matched according to all entity types;The natural language template is converted into program language template by the neural network model of pre-training, wherein described program language template carries slot to be filled;All entities are respectively corresponded into the slot to be filled filled into described program template, generate the corresponding program language of the natural language sentence.Making to have reserved slot to be filled in to-fill procedure template by training design, for filling the entity in natural language sentence into process template, forming the corresponding program language of natural language sentence.

Description

Natural language is converted into the method, apparatus and computer equipment of program language
Technical field
This application involves computer field is arrived, the method, apparatus that natural language is converted into program language is especially related to And computer equipment.
Background technique
In the prior art, without the paginal translation tool of program language and natural language sentence, programmer is being compiled under normal conditions Can be potentially encountered during journey can he has conceived with natural language description implementation, but be transcribed into code Technical difficulty is encountered in the process;And existing Internet resources, such as the website of question and answer type, the programming that programmer is submitted Program table is made in problem, when design new task or composite task, when needing the programming content in conjunction with history, can not pass through nature Language statement realizes the effective lookup and calling to corresponding programming content.
Summary of the invention
The main purpose of the application is the method for providing natural language and being converted into program language, it is intended to which solving can not be by certainly Right language statement realizes the technical issues of effective lookup and calling to corresponding programming content.
The application proposes a kind of method that natural language is converted into program language, comprising:
Obtain the natural language sentence of user's input;
All entity types for including in the natural language sentence are distinguished, and it is right respectively to extract all entity types The entity answered;
Natural language template is matched according to all entity types;
The natural language template is converted into program language template by the neural network model of pre-training, wherein described Program language template carries slot to be filled;
All entities are respectively corresponded into the slot to be filled filled into described program template, generate the nature The corresponding program language of language statement.
It is preferably, described that all entities are respectively corresponded into the slot to be filled filled into described program template, The step of generating the natural language sentence corresponding program language, comprising:
It is determining with the matched first instance of the first slot according to preset matching calculation formula, wherein the first instance includes In all entities, first slot is contained in all slots to be filled;
If so, filling the first instance into first slot;
The filling of all slots to be filled in described program template is completed according to the filling process of first slot, it is raw At described program language.
Preferably, the step of first instance matched with the first slot determining according to preset matching calculation formula, comprising:
Pass through calculation formulaCalculate separately all entities with Matching fractional value between first slot, wherein d(i,j),(c,d)=cos ((hi,hj`),(hc,hd`)),hiIndicate the corresponding vector of all entities, hj` indicates that first slot is corresponding Vector, (ec,sd) it is the second instance and the second slot for having marked matching status, hcIndicate the second instance ecIt is corresponding to Amount, hd` indicates the second slot sdCorresponding vector;
When determining the matching fractional value maximum, designated entities corresponding with first slot;
The designated entities are determined as the first instance.
Preferably, the neural network model includes coding-decoded model, described to pass through the natural language template in advance Trained neural network model is converted into the step of program language template, comprising:
By in the hidden layer of the decoding encoding model of natural language template input pre-training, it is fitted and is fitted State natural language template simultaneously exports, wherein the hidden layer of the decoding encoding model includes the form of the first specified quantity, described The quantity of entity type for including in first specified quantity and the natural language template is identical;
By the hidden layer of the decoded model of the fitting state natural language template input pre-training, is inputted and calculated by iteration The list of ordering described program language template and output are converted to, wherein described program language template is protected according to preset format Stay the slot to be filled.
Preferably, the hidden layer of the decoded model by the fitting state natural language template input pre-training, passes through Iteration input calculates the step of being converted to list and the output of ordering described program language template, comprising:
Using the fitting state natural language template as the first input data, it is input to the first of the hidden layer of decoded model Gradient layer determines the corresponding first instance type of the highest vector of weight coefficient and exports;
Using the first instance type and the calculating data of the first gradient layer as the second input data, it is input to solution Second gradient layer of the hidden layer of code model determines the weight coefficient time high corresponding second instance type of vector and exports, Described in first gradient layer and the second gradient layer be adjacent connection in the hidden layer of the decoded model iteration layer;
According to the iterative process for inputting data into second input data by described first, successively iteration is input to described The hidden layer of decoded model, until all trunk words of the natural language sentence are determined, wherein each trunk word point It is not determined according to the sequence of corresponding weight coefficient, and according to the sequence of weight coefficient, forms the described program language of sequence Say the list of template.
Preferably, described to distinguish all entity types for including in the natural language sentence, and extract all realities The step of body type corresponding entity, comprising:
The regular expression being pre-configured according to the constituent element of described program template is called, wherein the regular expression Type includes at least two kinds;
Judged in the natural language sentence according to the first regular expression, if include and first regular expression The given entity type of adaptation, wherein first regular expression is contained in all regular expressions;
If so, extracting the corresponding entity of the given entity type by first regular expression.
Preferably, the entity type includes mode class entity and quantity class entity, described according to all entity class Type matches the step of natural language template, comprising:
The corresponding entity of the mode class entity and physical quantities and the corresponding reality of the quantity class entity are obtained respectively Body and physical quantities;
According to the corresponding entity of the mode class entity and physical quantities and the corresponding reality of the quantity class entity Body and physical quantities, according to preset order arrange the corresponding entity of the mode class entity with and the quantity class entity it is corresponding Entity, form the natural language template.
Present invention also provides the devices that a kind of natural language is converted into program language, comprising:
Module is obtained, for obtaining the natural language sentence of user's input;
Discriminating module for distinguishing all entity types for including in the natural language sentence, and is extracted all described The corresponding entity of entity type;
Matching module, for matching natural language template according to all entity types;
Conversion module, for the natural language template to be converted into program language by the neural network model of pre-training Template, wherein described program language template carries slot to be filled;
Module is filled, it is described to be filled into described program template for all entities to be respectively corresponded filling Slot generates the corresponding program language of the natural language sentence.
Present invention also provides a kind of computer equipment, including memory and processor, the memory is stored with calculating The step of machine program, the processor realizes the above method when executing the computer program.
Present invention also provides a kind of computer readable storage mediums, are stored thereon with computer program, the computer The step of above-mentioned method is realized when program is executed by processor.
The application is generated by extracting the entity type in natural language sentence, and according to the entity type of extraction Then natural language template is input in trained neural network by natural language template, natural language template is passed through quasi- It is total to calculate and iterative calculation, it is converted into process template, and by training design make to have reserved in to-fill procedure template to be filled Slot forms the corresponding program language of natural language sentence for filling the entity in natural language sentence into process template. By the way that natural language sentence is converted directly into program language, realization can allow programming personnel to express expection using natural language Operation, facilitate programmer examine and use.K- nearest neighbor algorithm is improved to complete by local matching function, is solved existing Euclidean distance etc. in k- nearest neighbor algorithm is not suitable for the problem of matching of slot and entity in the application, by will be apart from nearest Entity and slot composition data pair, be spliced into a long vector, by calculate two long vectors between similarity, and then Matching degree between slot and entity to be matched.The accurate alignment for realizing slot and entity through the above way, is improved from nature Accurate correspondence of the language statement to program language.Different entity types is identified by matching different regular expressions, And corresponding entity is extracted, method is easy, and calculation amount is small and identifies that the accuracy for extracting entity is high.By by natural language sentence It is sequentially inputted in each regular expression, to judge in natural language sentence whether to include reality with current regular expression matching Body type, and if it exists, then extract the entity.
Detailed description of the invention
The natural language of one embodiment of Fig. 1 the application is converted into the method flow schematic diagram of program language;
The natural language of one embodiment of Fig. 2 the application is converted into the apparatus structure schematic diagram of program language;
The computer equipment schematic diagram of internal structure of one embodiment of Fig. 3 the application.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not For limiting the application.
Referring to Fig.1, the method that the natural language of one embodiment of the application is converted into program language, comprising:
S1: the natural language sentence of user's input is obtained.
S2: distinguishing all entity types for including in the natural language sentence, and extracts all entity types point Not corresponding entity.
S3: natural language template is matched according to all entity types.
S4: the natural language template is converted into program language template by the neural network model of pre-training, wherein Described program language template carries slot to be filled.
S5: all entities being respectively corresponded and fill the slot to be filled into described program template, described in generation The corresponding program language of natural language sentence.
The present embodiment is given birth to by extracting the entity type in natural language sentence, and according to the entity type of extraction At natural language template, then natural language template is input in trained neural network, natural language template is passed through The Fitting Calculation and iterative calculation are converted into process template, and make to have reserved in to-fill procedure template wait fill out by training design Slot being filled, for filling the entity in natural language sentence into process template, forming the corresponding program word of natural language sentence Speech.Above-mentioned entity type is the corresponding type of word of trunk word for indicating natural language sentence, such as including filename, Pathname, absolute path name, time etc., above-mentioned entity include filename, pathname, and absolute path name, time etc. are right respectively The assignment answered.The process of said extracted entity type, for the semantic process for determining trunk word of identification, that is, the word extracted retains The original semantic expression of former natural language sentence.Above-mentioned natural language template is the corresponding entity class of above-mentioned trunk word Type, the sequence formed according to the arrangement order in former natural language sentence.Then by by above-mentioned sequence inputting to training In good neural network, by the fitting and iterative calculation in coding and decoding, natural language template is made to be gradually converted into program The sequence of template, and reserved slot to be filled.The present embodiment is realized by the way that natural language sentence is converted directly into program language Programming personnel can be allowed to express expected operation using natural language, programmer is facilitated to examine and use.
Further, it is described by all entities respectively correspond filling it is described to be filled into described program template Slot generates the step S5 of the corresponding program language of the natural language sentence, comprising:
S51: according to the determination of preset matching calculation formula and the matched first instance of the first slot, wherein the first instance It is contained in all entities, first slot is contained in all slots to be filled.
S52: if so, filling the first instance into first slot.
S53: filling out for all slots to be filled in described program template is completed according to the filling process of first slot It fills, generates described program language.
The present embodiment is by carrying out matching pairing for entity and slot, and realization accurately fills entity in slot, and solving will Correctly input character string is aligned with the parameter value of output order.The preset matching calculation formula of the present embodiment is to pass through local It improves k- nearest neighbor algorithm with function to complete, since the Euclidean distance etc. in existing k- nearest neighbor algorithm is not suitable for the application In slot and entity matching, slot and entity in the application are without specific corresponding vector, and the present embodiment is by will be apart from nearest Entity and slot composition data pair, be spliced into a long vector, by calculate two long vectors between similarity, and then Matching degree between slot and entity to be matched.The accurate alignment for realizing slot and entity through the above way, is improved from nature Accurate correspondence of the language statement to program language.
Further, the step S51 according to preset matching calculation formula determination and the matched first instance of the first slot, Include:
S511: pass through calculation formulaCalculate separately all realities Matching fractional value between body and first slot, wherein d(i,j),(c,d)=cos ((hi,h`j),(hc,h`d)),hiIndicate the corresponding vector of all entities, hj` indicates that first slot is corresponding Vector, (ec,sd) it is the second instance and the second slot for having marked matching status, hcIndicate the second instance ecIt is corresponding to Amount, hd` indicates the second slot sdCorresponding vector.
S512: when determining the matching fractional value maximum, designated entities corresponding with first slot.
S513: the designated entities are determined as the first instance.
In the present embodiment, k- nearest neighbor algorithm is improved by local matching function, according to k- nearest neighbor algorithm by calculating Probability of occurrence in adjacent area is modified to judge the principle of similitude by selecting apart from entity to be matched and slot number according to right The entity and slot number of nearest marked matched data are according to matching score that is right, and calculating above-mentioned two pairs of entities and slot number evidence pair Value to overcome the problems, such as not being directly realized by accurate map vector between existing entity and slot, and is calculated by improved k- neighbour Method reduces calculation amount and improves the matching accuracy of entity and slot.Citing ground, above-mentioned second instance ecWith the second slot sd, point Not in the inner corresponding hidden layer variable h of encoding model (Encoder model) and decoded model (Decoder model)c,hd ` forms long vector (h by splicing variablec,hd`), reference entity and slot number are constituted according to right, and identifies matching status, Matching identification is 1, is 0 than matching identification.By fixed slot to be filled, i.e. the first slot, all entities, group are matched respectively At multiple entities for including the first slot and slot number according to right, same hiIndicate that all entities are corresponding in Encoder model respectively Hidden layer variable, hj` indicates corresponding hidden layer variable in the first slot Decoder model, by being spliced to form long vector (hi, hj`), the entity by screening apart from the first slot to be analyzed and slot number are according to right, the nearest mark matching status of distance value Second instance and the second slot, and calculate with marked the second instance of matching status and the matching fractional value of the second slot, match Fractional value is bigger, then the entity and slot number for showing the first slot to be analyzed according to right, with the second instance for having marked matching status and Second slot is more similar.Such as marked the second instance of matching status and the second slot is labeled as matching, then with it is similar to point The entity and slot number of first slot of analysis realize the accurate correspondence of entity and slot according to being also estimated as matching.
Further, the neural network model includes coding-decoded model, described to pass through the natural language template The neural network model of pre-training is converted into the step S4 of program language template, comprising:
S41: it by the hidden layer of the decoding encoding model of natural language template input pre-training, is fitted to obtain Fitting state natural language template simultaneously exports, wherein and the hidden layer of the decoding encoding model includes the form of the first specified quantity, The quantity of entity type for including in first specified quantity and the natural language template is identical.
S42: the hidden layer of the decoded model of the fitting state natural language template input pre-training is inputted by iteration List and the output for being converted to ordering described program language template are calculated, wherein described program language template is according to default lattice Formula retains the slot to be filled.
The present embodiment is realized by the hidden layer of Encoder and is fitted to the dimensionality reduction of natural language template, and treatment process is reduced In complexity, and improve the correct recognition rata to the extraction feature of natural language template.Encoder includes in the present embodiment The corresponding 7 fitting forms of 4 layers of hidden layer are followed successively by H1 to H7, set 20 for the step-length of every layer of LSTM;In MSCOCO data set On, hidden layer output is set as 1000, and on Flickr30K data set, the output of LSTM hidden layer is 512, hidden on Flickr8K Layer output is set as 256, to improve dimensionality reduction effect.The hidden layer of the Decoder of the present embodiment is by receiving Encoder output The last one hidden layer is fitted form as input, by successive ignition input and output, obtains ordering described program language The list of template, and slot to be filled is remained according to preset mode.The hidden layer of above-mentioned Encoder and hiding for Decoder Layer is connected, and trains optimum parameter by marked training sample, the program for exporting Encoder-Decoder model Template infinite approach preset mode.
Further, the hidden layer of the decoded model by the fitting state natural language template input pre-training, leads to Cross the step S42 that iteration input calculates the list for being converted to ordering described program language template and exports, comprising:
S421: using the fitting state natural language template as the first input data, it is input to the hidden layer of decoded model First gradient layer, determine the corresponding first instance type of the highest vector of weight coefficient and export.
S422: defeated using the first instance type and the calculating data of the first gradient layer as the second input data Enter the second gradient layer to the hidden layer of decoded model, determines time high corresponding second instance type of vector of weight coefficient and defeated Out, wherein the first gradient layer and the second gradient layer are the iteration layer of adjacent connection in the hidden layer of the decoded model.
S423: according to the iterative process for inputting data into second input data by described first, successively iteration is inputted To the hidden layer of the decoded model, until all trunk words of the natural language sentence are determined, wherein each trunk Word is determined according to the sequence of corresponding weight coefficient respectively, and according to the sequence of weight coefficient, forms the described of sequence The list of program language template.
The present embodiment passes through multiple gradient layers interconnected, is iterated input and output, such as including H1` to H5`, will The last one hidden layer of Encoder output is fitted form, i.e., fitting state natural language template is as the first input data, input To the H1` of the hidden layer of Decoder, the primitive most important first instance type Y1` of justice to natural language sentence is exported, then By Y1` and the process data for extracting Y1` while the input for being used as H2` are calculated, exports the primitive justice time to natural language sentence Then the process data that Y2` and calculating are extracted to Y2` is used as the input of H3` by important second instance type Y2` simultaneously, Successively iteration carries out calculating extraction, until output includes the column of the described program language template of all entity types of preset quantity Table.Citing ground, user's input " journal file before searching 15 days ", corresponding natural language template are as follows: find all [file Name] files older than [Timespan], by Encoder fitting output after, by Decoder hidden layer repeatedly It is calculated for input and output, the list of the described program language template of obtained sequence are as follows: Y1:find [path]-name [regex]-mtime[+Timespan];Y2:find[path]-type f-name[regex]-mtime[+Timespan]; Y3:find[path]-type f-perm[permission];Y4:find[path]-name[regex]-mtime[+ Timespan]xargs ls;Y5:....
Further, described to distinguish all entity types for including in the natural language sentence, and extract all described The step S2 of the corresponding entity of entity type, comprising:
S21: the regular expression being pre-configured according to the constituent element of described program template is called, wherein the regular expressions The type of formula includes at least two kinds.
S22: judged in the natural language sentence according to the first regular expression, if include and the first canonical table The given entity type being adapted to up to formula, wherein first regular expression is contained in all regular expressions.
S23: if so, extracting the corresponding entity of the given entity type by first regular expression.
The present embodiment identifies different entity types by matching different regular expressions, and extracts corresponding real Body, method is easy, and calculation amount is small and identifies that the accuracy for extracting entity is high.By by natural language sentence be sequentially inputted to it is each just Then in expression formula, to judge in natural language sentence whether to include entity type with current regular expression matching, and if it exists, Then extract the entity.Multiple regular expressions of the present embodiment arrangement can previously according to the important procedure of each entity type, Successively descending is arranged, and is arranged so that the entity type of identification is formed according to important order.
Further, the entity type includes mode class entity and quantity class entity, described according to all entities The step S3 of type matching natural language template, comprising:
S31: obtaining the corresponding entity of the mode class entity and physical quantities respectively and the quantity class entity is corresponding Entity and physical quantities.
S32: corresponding according to the corresponding entity of the mode class entity and physical quantities and the quantity class entity Entity and physical quantities, arrange the corresponding entity of the mode class entity and and the quantity class entity according to preset order Corresponding entity forms the natural language template.
The entity type of the present embodiment includes multiple mode class entities and multiple quantity class entities, such as including 5 modes Class entity, comprising: " File:file name;Directory:directory name;Path:absolute path;Date/ Time:date and time expression;Regex:other pattern arguments " and 3 quantity classes are real Body, including " Number:number;Size:file size;Timespan:time duration ", to cover certainly as far as possible comprehensively All trunk words of right language statement.By determining that different entities type and variant entity type correspond to natural language The importance ranking of sentence forms natural language template, while determining and extracting the corresponding entity of variant entity type, Assignment as slot to be filled.For example, user's input " journal file before searching 15 days, i.e. find all log files Older than 15days ", trunk word include " file name:log;Timespan:15days ", corresponding natural language Template are as follows: find all [file name] files older than [Timespan].
Referring to Fig. 2, the natural language of one embodiment of the application is converted into the device of program language, comprising:
Module 1 is obtained, for obtaining the natural language sentence of user's input.
Discriminating module 2 for distinguishing all entity types for including in the natural language sentence, and is extracted all described The corresponding entity of entity type.
Matching module 3, for matching natural language template according to all entity types.
Conversion module 4, for the natural language template to be converted into program word by the neural network model of pre-training Say template, wherein described program language template carries slot to be filled.
Module 5 is filled, it is described to be filled into described program template for all entities to be respectively corresponded filling Slot generates the corresponding program language of the natural language sentence.
The present embodiment is given birth to by extracting the entity type in natural language sentence, and according to the entity type of extraction At natural language template, then natural language template is input in trained neural network, natural language template is passed through The Fitting Calculation and iterative calculation are converted into process template, and make to have reserved in to-fill procedure template wait fill out by training design Slot being filled, for filling the entity in natural language sentence into process template, forming the corresponding program word of natural language sentence Speech.Above-mentioned entity type is the corresponding type of word of trunk word for indicating natural language sentence, such as including filename, Pathname, absolute path name, time etc., above-mentioned entity include filename, pathname, and absolute path name, time etc. are right respectively The assignment answered.The process of said extracted entity type, for the semantic process for determining trunk word of identification, that is, the word extracted retains The original semantic expression of former natural language sentence.Above-mentioned natural language template is the corresponding entity class of above-mentioned trunk word Type, the sequence formed according to the arrangement order in former natural language sentence.Then by by above-mentioned sequence inputting to training In good neural network, by the fitting and iterative calculation in coding and decoding, natural language template is made to be gradually converted into program The sequence of template, and reserved slot to be filled.The present embodiment is realized by the way that natural language sentence is converted directly into program language Programming personnel can be allowed to express expected operation using natural language, programmer is facilitated to examine and use.
Further, the filling module 5, comprising:
Determination unit, for according to the determination of preset matching calculation formula and the matched first instance of the first slot, wherein described First instance is contained in all entities, and first slot is contained in all slots to be filled.
Fills unit, for if so, filling the first instance into first slot.
Generation unit is completed all described wait fill out in described program template for the filling process according to first slot The filling of slot is filled, described program language is generated.
The present embodiment is by carrying out matching pairing for entity and slot, and realization accurately fills entity in slot, and solving will Correctly input character string is aligned with the parameter value of output order.The preset matching calculation formula of the present embodiment is to pass through local It improves k- nearest neighbor algorithm with function to complete, since the Euclidean distance etc. in existing k- nearest neighbor algorithm is not suitable for the application In slot and entity matching, slot and entity in the application are without specific corresponding vector, and the present embodiment is by will be apart from nearest Entity and slot composition data pair, be spliced into a long vector, by calculate two long vectors between similarity, and then Matching degree between slot and entity to be matched.The accurate alignment for realizing slot and entity through the above way, is improved from nature Accurate correspondence of the language statement to program language.
Further, the determination unit, comprising:
Computation subunit, for passing through calculation formulaIt calculates separately Matching fractional value between all entities and first slot, wherein d(i,j),(c,d)=cos ((hi,h`j),(hc,h`d)),hiIndicate the corresponding vector of all entities, hj` indicates that first slot is corresponding Vector, (ec,sd) it is the second instance and the second slot for having marked matching status, hcIndicate the second instance ecIt is corresponding to Amount, hd` indicates the second slot sdCorresponding vector.
First determines subelement, when for determining the matching fractional value maximum, specified reality corresponding with first slot Body.
Second determines subelement, for the designated entities to be determined as the first instance.
In the present embodiment, k- nearest neighbor algorithm is improved by local matching function, according to k- nearest neighbor algorithm by calculating Probability of occurrence in adjacent area is modified to judge the principle of similitude by selecting apart from entity to be matched and slot number according to right The entity and slot number of nearest marked matched data are according to matching score that is right, and calculating above-mentioned two pairs of entities and slot number evidence pair Value to overcome the problems, such as not being directly realized by accurate map vector between existing entity and slot, and is calculated by improved k- neighbour Method reduces calculation amount and improves the matching accuracy of entity and slot.Citing ground, above-mentioned second instance ecWith the second slot sd, point A corresponding hidden layer variable h not in Encoder model and Decoder modelc,hd`, by the way that variable is spliced, formed it is long to Measure (hc,hd`), reference entity and slot number are constituted according to right, and identifies matching status, matching identification 1 is than matching identification 0.By fixed slot to be filled, i.e. the first slot, match all entities respectively, form it is multiple include the first slot entity and Slot number is according to right, same hiIndicate all entities corresponding hidden layer variable, h in Encoder model respectivelyj` indicates described first Corresponding hidden layer variable in slot Decoder model, by being spliced to form long vector (hi, hj`), by screening apart to be analyzed The first slot entity and slot number according to right, the distance value nearest second instance for having marked matching status and the second slot, and calculate With the matching fractional value of the second instance for having marked matching status and the second slot, matching fractional value is bigger, then shows to be analyzed The entity of first slot and slot number are more similar to the second instance for having marked matching status and the second slot according to right.For example it marks Second instance and the second slot with state are labeled as matching, then with it the entity of similar first slot to be analyzed and slot number according to right Also it is estimated as matching, realizes the accurate correspondence of entity and slot.
Further, the neural network model includes coding-decoded model, conversion module 4, comprising:
Fitting unit, for the natural language template to be inputted in the hidden layer for decoding encoding model of pre-training, into Row fitting obtains fitting state natural language template and exports, wherein the hidden layer of the decoding encoding model includes first specified The quantity of entity type for including in the form of quantity, first specified quantity and the natural language template is identical.
Input unit, for leading to the hidden layer of the decoded model of the fitting state natural language template input pre-training It crosses iteration input and calculates list and the output for being converted to ordering described program language template, wherein described program language template Retain the slot to be filled according to preset format.
The present embodiment is realized by the hidden layer of Encoder and is fitted to the dimensionality reduction of natural language template, and treatment process is reduced In complexity, and improve the correct recognition rata to the extraction feature of natural language template.Encoder includes in the present embodiment The corresponding 7 fitting forms of 4 layers of hidden layer are followed successively by H1 to H7, set 20 for the step-length of every layer of LSTM;In MSCOCO data set On, hidden layer output is set as 1000, and on Flickr30K data set, the output of LSTM hidden layer is 512, hidden on Flickr8K Layer output is set as 256, to improve dimensionality reduction effect.The hidden layer of the Decoder of the present embodiment is by receiving Encoder output The last one hidden layer is fitted form as input, by successive ignition input and output, obtains ordering described program language The list of template, and slot to be filled is remained according to preset mode.The hidden layer of above-mentioned Encoder and hiding for Decoder Layer is connected, and trains optimum parameter by marked training sample, the program for exporting Encoder-Decoder model Template infinite approach preset mode.
Further, the input unit, comprising:
First input subelement, for being input to solution using the fitting state natural language template as the first input data The first gradient layer of the hidden layer of code model, determines the corresponding first instance type of the highest vector of weight coefficient and exports.
Second input subelement, for using the calculating data of the first instance type and the first gradient layer as the Two input datas are input to the second gradient layer of the hidden layer of decoded model, determine time high vector of weight coefficient corresponding the Two entity types simultaneously export, wherein the first gradient layer and the second gradient layer are adjacent company in the hidden layer of the decoded model The iteration layer connect.
Third inputs subelement, for according to the iteration mistake for inputting data into second input data by described first Journey, successively iteration is input to the hidden layer of the decoded model, until determine all trunk words of the natural language sentence, Wherein each trunk word is determined according to the sequence of corresponding weight coefficient respectively, and according to the sequence of weight coefficient, Form the list of the described program language template of sequence.
The present embodiment passes through multiple gradient layers interconnected, is iterated input and output, such as including H1` to H5`, will The last one hidden layer of Encoder output is fitted form, i.e., fitting state natural language template is as the first input data, input To the H1` of the hidden layer of Decoder, the primitive most important first instance type Y1` of justice to natural language sentence is exported, then By Y1` and the process data for extracting Y1` while the input for being used as H2` are calculated, exports the primitive justice time to natural language sentence Then the process data that Y2` and calculating are extracted to Y2` is used as the input of H3` by important second instance type Y2` simultaneously, Successively iteration carries out calculating extraction, until output includes the column of the described program language template of all entity types of preset quantity Table.Citing ground, user's input " journal file before searching 15 days ", corresponding natural language template are as follows: find all [file Name] files older than [Timespan], by Encoder fitting output after, by Decoder hidden layer repeatedly It is calculated for input and output, the list of the described program language template of obtained sequence are as follows: Y1:find [path]-name [regex]-mtime[+Timespan];Y2:find[path]-type f-name[regex]-mtime[+Timespan]; Y3:find[path]-type f-perm[permission];Y4:find[path]-name[regex]-mtime[+ Timespan]xargs ls;Y5:....
Further, the discriminating module 2, comprising:
Call unit, for calling the regular expression being pre-configured according to the constituent element of described program template, wherein institute The type for stating regular expression includes at least two kinds.
Judging unit, for judge in the natural language sentence according to the first regular expression, if include with it is described The given entity type of first regular expression adaptation, wherein first regular expression is contained in all canonical tables Up in formula.
Extraction unit is used for if so, corresponding by first regular expression extraction given entity type Entity.
The present embodiment identifies different entity types by matching different regular expressions, and extracts corresponding real Body, method is easy, and calculation amount is small and identifies that the accuracy for extracting entity is high.By by natural language sentence be sequentially inputted to it is each just Then in expression formula, to judge in natural language sentence whether to include entity type with current regular expression matching, and if it exists, Then extract the entity.Multiple regular expressions of the present embodiment arrangement can previously according to the important procedure of each entity type, Successively descending is arranged, and is arranged so that the entity type of identification is formed according to important order.
Further, the matching module 3, comprising:
Acquiring unit, for obtaining the corresponding entity of the mode class entity and physical quantities and the quantity respectively The corresponding entity of class entity and physical quantities.
Unit is formed, for according to the corresponding entity of the mode class entity and physical quantities and the quantity The corresponding entity of class entity and physical quantities arrange the corresponding entity of the mode class entity and and described according to preset order The corresponding entity of quantity class entity forms the natural language template.
The entity type of the present embodiment includes multiple mode class entities and multiple quantity class entities, such as including 5 modes Class entity, comprising: " File:file name;Directory:directory name;Path:absolute path;Date/ Time:date and time expression;Regex:other pattern arguments " and 3 quantity classes are real Body, including " Number:number;Size:file size;Timespan:time duration ", to cover certainly as far as possible comprehensively All trunk words of right language statement.By determining that different entities type and variant entity type correspond to natural language The importance ranking of sentence forms natural language template, while determining and extracting the corresponding entity of variant entity type, Assignment as slot to be filled.For example, user's input " journal file before searching 15 days, i.e. find all log files Older than 15days ", trunk word include " file name:log;Timespan:15days ", corresponding natural language Template are as follows: find all [file name] files older than [Timespan].
Referring to Fig. 3, a kind of computer equipment is also provided in the embodiment of the present application, which can be server, Its internal structure can be as shown in Figure 3.The computer equipment includes processor, the memory, network connected by system bus Interface and database.Wherein, the processor of the Computer Design is for providing calculating and control ability.The computer equipment is deposited Reservoir includes non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program And database.The internal memory provides environment for the operation of operating system and computer program in non-volatile memory medium.It should All data that the database of computer equipment is needed for the matched process of storage address.The network interface of the computer equipment For being communicated with external end by network connection.To realize that natural language is converted into when the computer program is executed by processor The method of program language.
Above-mentioned processor executes the method that above-mentioned natural language is converted into program language, comprising: obtains oneself of user's input Right language statement;All entity types for including in the natural language sentence are distinguished, and extract all entity types point Not corresponding entity;Natural language template is matched according to all entity types;By the natural language template by instructing in advance Experienced neural network model is converted into program language template, wherein described program language template carries slot to be filled;By all institutes It states entity and respectively corresponds the slot to be filled filled into described program template, generate the corresponding journey of the natural language sentence Sequence language.
Above-mentioned computer equipment, by extracting the entity type in natural language sentence, and according to the reality of extraction Body type generates natural language template, then natural language template is input in trained neural network, by natural language Template is converted into process template by the Fitting Calculation and iterative calculation, and is made in to-fill procedure template in advance by training design Slot to be filled having been stayed, for filling the entity in natural language sentence into process template, it is corresponding to form natural language sentence Program language.By the way that natural language sentence is converted directly into program language, realization can allow programming personnel to use nature language Speech facilitates programmer to examine and use to express expected operation.K- nearest neighbor algorithm is improved by local matching function come complete At, solve the problems, such as that the Euclidean distance etc. in existing k- nearest neighbor algorithm is not suitable for the matching of slot and entity in the application, By being spliced into a long vector for the data pair apart from nearest entity and slot composition, by calculating between two long vectors Similarity, and then obtain the matching degree between slot and entity to be matched.The accurate of slot and entity is realized through the above way Alignment improves the accurate correspondence from natural language sentence to program language.It is identified by matching different regular expressions Different entity types, and corresponding entity is extracted, method is easy, and calculation amount is small and identifies that the accuracy for extracting entity is high.It is logical Cross and natural language sentence be sequentially inputted in each regular expression, with judge in natural language sentence whether include with currently just The then matched entity type of expression formula, and if it exists, then extract the entity.
In one embodiment, all entities are respectively corresponded filling into described program template by above-mentioned processor The slot to be filled, the step of generating the natural language sentence corresponding program language, comprising: calculated according to preset matching public Formula determination and the matched first instance of the first slot, wherein the first instance is contained in all entities, first slot It is contained in all slots to be filled;If so, filling the first instance into first slot;According to described first The filling process of slot completes the filling of all slots to be filled in described program template, generates described program language.
In one embodiment, above-mentioned processor is determining real with the first slot matched first according to preset matching calculation formula The step of body, comprising: pass through calculation formulaIt calculates separately all described Matching fractional value between entity and first slot, wherein d(i,j),(c,d)=cos ((hi,h`j),(hc,h`d)),hiIndicate the corresponding vector of all entities, hj` indicates that first slot is corresponding Vector, (ec,sd) it is the second instance and the second slot for having marked matching status, hcIndicate the second instance ecIt is corresponding to Amount, hd` indicates the second slot sdCorresponding vector;When determining the matching fractional value maximum, finger corresponding with first slot Determine entity;The designated entities are determined as the first instance.
In one embodiment, the neural network model includes coding-decoded model, and above-mentioned processor is by the nature The step of language template is converted into program language template by the neural network model of pre-training, comprising: by the natural language Template inputs in the hidden layer of decoding encoding model of pre-training, is fitted to obtain fitting state natural language template and export, Wherein, it is described decoding encoding model hidden layer include the first specified quantity form, first specified quantity and it is described from The quantity for the entity type for including in right language template is identical;By the decoding of the fitting state natural language template input pre-training The hidden layer of model calculates list and the output for being converted to ordering described program language template by iteration input, wherein Described program language template retains the slot to be filled according to preset format.
In one embodiment, the fitting state natural language template is inputted the decoded model of pre-training by above-mentioned processor Hidden layer, by iteration input calculate be converted to list and the output of ordering described program language template the step of, packet It includes: using the fitting state natural language template as the first input data, being input to the first gradient of the hidden layer of decoded model Layer, determines the corresponding first instance type of the highest vector of weight coefficient and exports;By the first instance type and described the The calculating data of one gradient layer are input to the second gradient layer of the hidden layer of decoded model as the second input data, determine power The weight high corresponding second instance type of vector of coefficient time simultaneously exports, wherein the first gradient layer and the second gradient layer are described The iteration layer of adjacent connection in the hidden layer of decoded model;Second input data is input data into according to by described first Iterative process, successively iteration is input to the hidden layer of the decoded model, until determining all masters of the natural language sentence Dry word, wherein each trunk word is determined according to the sequence of corresponding weight coefficient respectively, and according to weight coefficient Sequence, form the list of the described program language template of sequence.
In one embodiment, above-mentioned processor distinguishes all entity types for including in the natural language sentence, and The step of extracting all entity types corresponding entity, comprising: call the constituent element according to described program template The regular expression of pre-configuration, wherein the type of the regular expression includes at least two kinds;Sentenced according to the first regular expression Break in the natural language sentence, if include the given entity type being adapted to first regular expression, wherein described First regular expression is contained in all regular expressions;If so, extracting institute by first regular expression State the corresponding entity of given entity type.
In one embodiment, the entity type includes mode class entity and quantity class entity, according to all realities The step of body type matching natural language template, comprising: the corresponding entity of the mode class entity and physical quantities are obtained respectively, And the corresponding entity of the quantity class entity and physical quantities;According to the corresponding entity of the mode class entity and entity Quantity and the corresponding entity of the quantity class entity and physical quantities arrange the mode class entity pair according to preset order The entity answered with and the corresponding entity of the quantity class entity, form the natural language template.
It will be understood by those skilled in the art that structure shown in Fig. 3, only part relevant to application scheme is tied The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme.
One embodiment of the application also provides a kind of computer readable storage medium, is stored thereon with computer program, calculates The method that natural language is converted into program language is realized when machine program is executed by processor, comprising: obtain the nature of user's input Language statement;All entity types for including in the natural language sentence are distinguished, and extract all entity type difference Corresponding entity;Natural language template is matched according to all entity types;The natural language template is passed through into pre-training Neural network model be converted into program language template, wherein described program language template carries slot to be filled;It will be all described Entity respectively corresponds the slot to be filled filled into described program template, generates the corresponding program of the natural language sentence Language.
Above-mentioned computer readable storage medium, by the way that the entity type in natural language sentence is extracted, and according to The entity type of extraction generates natural language template, and then natural language template is input in trained neural network, will Natural language template is converted into process template by the Fitting Calculation and iterative calculation, and makes to-fill procedure by training design Slot to be filled has been reserved in template, for filling the entity in natural language sentence into process template, forms natural language The corresponding program language of sentence.By the way that natural language sentence is converted directly into program language, realization can allow programming personnel to make Expected operation is expressed with natural language, and programmer is facilitated to examine and use.K- neighbour is improved by local matching function Algorithm is completed, and solves the matching that the Euclidean distance etc. in existing k- nearest neighbor algorithm is not suitable for slot and entity in the application The problem of, by the data pair that will be formed apart from nearest entity and slot, be spliced into a long vector, by calculate it is two long to Similarity between amount, and then obtain the matching degree between slot and entity to be matched.Slot and entity are realized through the above way Accurate alignment, improve accurate correspondence from natural language sentence to program language.By matching different regular expressions It identifies different entity types, and extracts corresponding entity, method is easy, and calculation amount is small and the accuracy of entity is extracted in identification It is high.By the way that natural language sentence is sequentially inputted in each regular expression, with judge in natural language sentence whether include with The entity type of current regular expression matching, and if it exists, then extract the entity.
In one embodiment, all entities are respectively corresponded filling into described program template by above-mentioned processor The slot to be filled, the step of generating the natural language sentence corresponding program language, comprising: calculated according to preset matching public Formula determination and the matched first instance of the first slot, wherein the first instance is contained in all entities, first slot It is contained in all slots to be filled;If so, filling the first instance into first slot;According to described first The filling process of slot completes the filling of all slots to be filled in described program template, generates described program language.
In one embodiment, above-mentioned processor is determining real with the first slot matched first according to preset matching calculation formula The step of body, comprising: pass through calculation formulaIt calculates separately all described Matching fractional value between entity and first slot, wherein d(i,j),(c,d)=cos ((hi,h`j),(hc,h`d)),hiIndicate the corresponding vector of all entities, hj` indicates that first slot is corresponding Vector, (ec,sd) it is the second instance and the second slot for having marked matching status, hcIndicate the second instance ecIt is corresponding to Amount, hd` indicates the second slot sdCorresponding vector;When determining the matching fractional value maximum, finger corresponding with first slot Determine entity;The designated entities are determined as the first instance.
In one embodiment, the neural network model includes coding-decoded model, and above-mentioned processor is by the nature The step of language template is converted into program language template by the neural network model of pre-training, comprising: by the natural language Template inputs in the hidden layer of decoding encoding model of pre-training, is fitted to obtain fitting state natural language template and export, Wherein, it is described decoding encoding model hidden layer include the first specified quantity form, first specified quantity and it is described from The quantity for the entity type for including in right language template is identical;By the decoding of the fitting state natural language template input pre-training The hidden layer of model calculates list and the output for being converted to ordering described program language template by iteration input, wherein Described program language template retains the slot to be filled according to preset format.
In one embodiment, the fitting state natural language template is inputted the decoded model of pre-training by above-mentioned processor Hidden layer, by iteration input calculate be converted to list and the output of ordering described program language template the step of, packet It includes: using the fitting state natural language template as the first input data, being input to the first gradient of the hidden layer of decoded model Layer, determines the corresponding first instance type of the highest vector of weight coefficient and exports;By the first instance type and described the The calculating data of one gradient layer are input to the second gradient layer of the hidden layer of decoded model as the second input data, determine power The weight high corresponding second instance type of vector of coefficient time simultaneously exports, wherein the first gradient layer and the second gradient layer are described The iteration layer of adjacent connection in the hidden layer of decoded model;Second input data is input data into according to by described first Iterative process, successively iteration is input to the hidden layer of the decoded model, until determining all masters of the natural language sentence Dry word, wherein each trunk word is determined according to the sequence of corresponding weight coefficient respectively, and according to weight coefficient Sequence, form the list of the described program language template of sequence.
In one embodiment, above-mentioned processor distinguishes all entity types for including in the natural language sentence, and The step of extracting all entity types corresponding entity, comprising: call the constituent element according to described program template The regular expression of pre-configuration, wherein the type of the regular expression includes at least two kinds;Sentenced according to the first regular expression Break in the natural language sentence, if include the given entity type being adapted to first regular expression, wherein described First regular expression is contained in all regular expressions;If so, extracting institute by first regular expression State the corresponding entity of given entity type.
In one embodiment, the entity type includes mode class entity and quantity class entity, according to all realities The step of body type matching natural language template, comprising: the corresponding entity of the mode class entity and physical quantities are obtained respectively, And the corresponding entity of the quantity class entity and physical quantities;According to the corresponding entity of the mode class entity and entity Quantity and the corresponding entity of the quantity class entity and physical quantities arrange the mode class entity pair according to preset order The entity answered with and the corresponding entity of the quantity class entity, form the natural language template.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with Relevant hardware is instructed to complete by computer program, above-mentioned computer program can be stored in a non-volatile computer In read/write memory medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, Any reference used in provided herein and embodiment to memory, storage, database or other media, Including non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM (PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms, Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double speed are according to rate SDRAM (SSRSDRAM), enhancing Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, device, article or the method that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, device, article or method institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, device of element, article or method.
The foregoing is merely preferred embodiment of the present application, are not intended to limit the scope of the patents of the application, all utilizations Equivalent structure or equivalent flow shift made by present specification and accompanying drawing content is applied directly or indirectly in other correlations Technical field, similarly include in the scope of patent protection of the application.

Claims (10)

1. a kind of method that natural language is converted into program language characterized by comprising
Obtain the natural language sentence of user's input;
All entity types for including in the natural language sentence are distinguished, and it is corresponding to extract all entity types Entity;
Natural language template is matched according to all entity types;
The natural language template is converted into program language template by the neural network model of pre-training, wherein the journey Sequence language template carries slot to be filled;
All entities are respectively corresponded into the slot to be filled filled into described program template, generate the natural language The corresponding program language of sentence.
2. the method that natural language according to claim 1 is converted into program language, which is characterized in that described by all institutes It states entity and respectively corresponds the slot to be filled filled into described program template, generate the corresponding journey of the natural language sentence The step of sequence language, comprising:
According to the determination of preset matching calculation formula and the matched first instance of the first slot, wherein the first instance is contained in institute Have in the entity, first slot is contained in all slots to be filled;
If so, filling the first instance into first slot;
The filling of all slots to be filled in described program template is completed according to the filling process of first slot, generates institute State program language.
3. the method that natural language according to claim 2 is converted into program language, which is characterized in that the basis is default Matching primitives formula determines the step of first instance matched with the first slot, comprising:
Pass through calculation formulaCalculate separately all entities with it is described Matching fractional value between first slot, wherein d(i,j),(c,d)=cos ((hi,hj`),(hc,hd`)),hiIndicate the corresponding vector of all entities, hj` indicates that first slot is corresponding Vector, (ec,sd) it is the second instance and the second slot for having marked matching status, hcIndicate the second instance ecIt is corresponding to Amount, hd` indicates the second slot sdCorresponding vector;
When determining the matching fractional value maximum, designated entities corresponding with first slot;
The designated entities are determined as the first instance.
4. the method that natural language according to claim 1 is converted into program language, which is characterized in that the neural network Model includes coding-decoded model, described that the natural language template is converted into journey by the neural network model of pre-training The step of sequence language template, comprising:
The natural language template is inputted in the hidden layer of decoding encoding model of pre-training, is fitted to obtain fitting state certainly Right language template simultaneously exports, wherein form of the hidden layer comprising the first specified quantity of the decoding encoding model, described first The quantity of entity type for including in specified quantity and the natural language template is identical;
By the hidden layer of the decoded model of the fitting state natural language template input pre-training, is inputted by iteration and calculate conversion List and output for ordering described program language template, wherein described program language template retains institute according to preset format State slot to be filled.
5. the method that natural language according to claim 4 is converted into program language, which is characterized in that described described to intend The hidden layer for closing the decoded model of state natural language template input pre-training, is calculated by iteration input and is converted to ordering institute The step of stating the list of program language template and output, comprising:
Using the fitting state natural language template as the first input data, it is input to the first gradient of the hidden layer of decoded model Layer, determines the corresponding first instance type of the highest vector of weight coefficient and exports;
Using the first instance type and the calculating data of the first gradient layer as the second input data, it is input to decoding mould Second gradient layer of the hidden layer of type determines the high corresponding second instance type of vector of weight coefficient time and exports, wherein institute It states first gradient layer and the second gradient layer is the iteration layer of adjacent connection in the hidden layer of the decoded model;
According to the iterative process for inputting data into second input data by described first, successively iteration is input to the decoding The hidden layer of model, until all trunk words of the natural language sentence are determined, wherein each trunk word distinguishes root It is determined according to the sequence of corresponding weight coefficient, and according to the sequence of weight coefficient, forms the described program language mould of sequence The list of plate.
6. the method that natural language according to claim 1 is converted into program language, which is characterized in that described in the differentiation All entity types for including in natural language sentence, and the step of extracting all entity types corresponding entity, Include:
The regular expression being pre-configured according to the constituent element of described program template is called, wherein the type of the regular expression Including at least two kinds;
Judged in the natural language sentence according to the first regular expression, if comprising being adapted to first regular expression Given entity type, wherein first regular expression is contained in all regular expressions;
If so, extracting the corresponding entity of the given entity type by first regular expression.
7. the method that natural language according to claim 1 is converted into program language, which is characterized in that the entity type Including mode class entity and quantity class entity, described the step of matching natural language template according to all entity types, packet It includes:
Obtain respectively the corresponding entity of the mode class entity and physical quantities and the corresponding entity of the quantity class entity and Physical quantities;
According to the corresponding entity of the mode class entity and physical quantities and the corresponding entity of the quantity class entity and Physical quantities, according to preset order arrange the corresponding entity of the mode class entity with and the corresponding reality of the quantity class entity Body forms the natural language template.
8. the device that a kind of natural language is converted into program language characterized by comprising
Module is obtained, for obtaining the natural language sentence of user's input;
Discriminating module for distinguishing all entity types for including in the natural language sentence, and extracts all entities The corresponding entity of type;
Matching module, for matching natural language template according to all entity types;
Conversion module, for the natural language template to be converted into program language mould by the neural network model of pre-training Plate, wherein described program language template carries slot to be filled;
Module is filled, it is raw for all entities to be respectively corresponded the slot to be filled filled into described program template At the corresponding program language of the natural language sentence.
9. a kind of computer equipment, including memory and processor, the memory are stored with computer program, feature exists In the step of processor realizes any one of claims 1 to 7 the method when executing the computer program.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the computer program The step of method described in any one of claims 1 to 7 is realized when being executed by processor.
CN201910600648.5A 2019-07-04 2019-07-04 Natural language is converted into the method, apparatus and computer equipment of program language Pending CN110442332A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910600648.5A CN110442332A (en) 2019-07-04 2019-07-04 Natural language is converted into the method, apparatus and computer equipment of program language
PCT/CN2019/122480 WO2021000512A1 (en) 2019-07-04 2019-12-02 Method and apparatus for converting natural language into programing language, and computer device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910600648.5A CN110442332A (en) 2019-07-04 2019-07-04 Natural language is converted into the method, apparatus and computer equipment of program language

Publications (1)

Publication Number Publication Date
CN110442332A true CN110442332A (en) 2019-11-12

Family

ID=68428517

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910600648.5A Pending CN110442332A (en) 2019-07-04 2019-07-04 Natural language is converted into the method, apparatus and computer equipment of program language

Country Status (2)

Country Link
CN (1) CN110442332A (en)
WO (1) WO2021000512A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111008213A (en) * 2019-12-23 2020-04-14 百度在线网络技术(北京)有限公司 Method and apparatus for generating language conversion model
CN111191439A (en) * 2019-12-16 2020-05-22 浙江大搜车软件技术有限公司 Natural sentence generation method and device, computer equipment and storage medium
WO2021000512A1 (en) * 2019-07-04 2021-01-07 深圳壹账通智能科技有限公司 Method and apparatus for converting natural language into programing language, and computer device
CN112306497A (en) * 2020-11-03 2021-02-02 高炼 Method and system for converting natural language into program code
CN113934684A (en) * 2021-12-16 2022-01-14 四川省交通勘察设计研究院有限公司 Data format automatic conversion method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101930428A (en) * 2009-06-18 2010-12-29 万继华 System and method for ensuring computer to understand natural languages
CN109144493A (en) * 2018-07-18 2019-01-04 平安科技(深圳)有限公司 Generation method, electronic device and the readable storage medium storing program for executing of business rule
CN109739483A (en) * 2018-12-28 2019-05-10 北京百度网讯科技有限公司 Method and apparatus for generated statement
CN109918680A (en) * 2019-03-28 2019-06-21 腾讯科技(上海)有限公司 Entity recognition method, device and computer equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120101803A1 (en) * 2007-11-14 2012-04-26 Ivaylo Popov Formalization of a natural language
CN103617159B (en) * 2012-12-07 2016-10-12 万继华 Natural language translation is become the method for computer language, semantic analyzer and interactive system
CN107291701B (en) * 2016-04-01 2020-12-01 阿里巴巴集团控股有限公司 Machine language generation method and device
CN110442332A (en) * 2019-07-04 2019-11-12 深圳壹账通智能科技有限公司 Natural language is converted into the method, apparatus and computer equipment of program language

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101930428A (en) * 2009-06-18 2010-12-29 万继华 System and method for ensuring computer to understand natural languages
CN109144493A (en) * 2018-07-18 2019-01-04 平安科技(深圳)有限公司 Generation method, electronic device and the readable storage medium storing program for executing of business rule
CN109739483A (en) * 2018-12-28 2019-05-10 北京百度网讯科技有限公司 Method and apparatus for generated statement
CN109918680A (en) * 2019-03-28 2019-06-21 腾讯科技(上海)有限公司 Entity recognition method, device and computer equipment

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021000512A1 (en) * 2019-07-04 2021-01-07 深圳壹账通智能科技有限公司 Method and apparatus for converting natural language into programing language, and computer device
CN111191439A (en) * 2019-12-16 2020-05-22 浙江大搜车软件技术有限公司 Natural sentence generation method and device, computer equipment and storage medium
CN111008213A (en) * 2019-12-23 2020-04-14 百度在线网络技术(北京)有限公司 Method and apparatus for generating language conversion model
CN112306497A (en) * 2020-11-03 2021-02-02 高炼 Method and system for converting natural language into program code
CN112306497B (en) * 2020-11-03 2024-04-26 高炼 Method and system for converting natural language into program code
CN113934684A (en) * 2021-12-16 2022-01-14 四川省交通勘察设计研究院有限公司 Data format automatic conversion method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
WO2021000512A1 (en) 2021-01-07

Similar Documents

Publication Publication Date Title
CN110442332A (en) Natural language is converted into the method, apparatus and computer equipment of program language
CN111506722B (en) Knowledge graph question-answering method, device and equipment based on deep learning technology
CN110147445A (en) Intension recognizing method, device, equipment and storage medium based on text classification
CN112256825A (en) Medical field multi-turn dialogue intelligent question-answering method and device and computer equipment
KR102452123B1 (en) Apparatus for Building Big-data on unstructured Cyber Threat Information, Method for Building and Analyzing Cyber Threat Information
CN109829692A (en) Contract trial method, apparatus, equipment and storage medium based on artificial intelligence
CA3135717A1 (en) System and method for transferable natural language interface
CN112016279A (en) Electronic medical record structuring method and device, computer equipment and storage medium
CN112052684A (en) Named entity identification method, device, equipment and storage medium for power metering
CN109992664A (en) Mark classification method, device, computer equipment and the storage medium of central issue
CN111710383A (en) Medical record quality control method and device, computer equipment and storage medium
CN108664595A (en) Domain knowledge base construction method, device, computer equipment and storage medium
CN113032568A (en) Query intention identification method based on bert + bilstm + crf and combined sentence pattern analysis
CN112766319A (en) Dialogue intention recognition model training method and device, computer equipment and medium
JP7579022B1 (en) Method and system for intelligent analysis of bills based on semantic graph model
CN113204968B (en) Concept identification method, device, equipment and storage medium of medical entity
CN112036151A (en) Method and device for constructing gene disease relation knowledge base and computer equipment
CN116340467B (en) Text processing method, text processing device, electronic equipment and computer readable storage medium
CN113868422A (en) Multi-label inspection work order problem traceability identification method and device
CN114004231A (en) Chinese special word extraction method, system, electronic equipment and storage medium
CN109885830A (en) Sentence interpretation method, device, computer equipment
CN116341519A (en) Event causal relation extraction method, device and storage medium based on background knowledge
CN111680132A (en) Noise filtering and automatic classifying method for internet text information
CN111782821B (en) Medical hotspot prediction method and device based on FM model and computer equipment
CN113051920A (en) Named entity recognition method and device, computer equipment and storage medium

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