CN102707948B - Source code generation method - Google Patents

Source code generation method Download PDF

Info

Publication number
CN102707948B
CN102707948B CN201210126647.XA CN201210126647A CN102707948B CN 102707948 B CN102707948 B CN 102707948B CN 201210126647 A CN201210126647 A CN 201210126647A CN 102707948 B CN102707948 B CN 102707948B
Authority
CN
China
Prior art keywords
general rule
character string
mapping relations
code segment
character
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
CN201210126647.XA
Other languages
Chinese (zh)
Other versions
CN102707948A (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.)
Zhangjiagang Kangdexin Optronics Material Co Ltd
Original Assignee
Huaya Microelectronics Shanghai Inc
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 Huaya Microelectronics Shanghai Inc filed Critical Huaya Microelectronics Shanghai Inc
Priority to CN201210126647.XA priority Critical patent/CN102707948B/en
Publication of CN102707948A publication Critical patent/CN102707948A/en
Application granted granted Critical
Publication of CN102707948B publication Critical patent/CN102707948B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention relates to a source code generation method. The source code generation method comprises the steps of: S1, storing a special string sample, a general string sample corresponding to the special string sample, and a generate code segment sample corresponding to the general string sample in a database, wherein the special string sample is the subset of the general string sample; S2, retrieving the special string sample matching a string inputted by peripheral equipment in the database, executing step S3 is the special string sample is retrieved, otherwise, returning to step S1; and S3, retrieving the general string sample corresponding to the special string sample obtained in step S2 in the database, comparing the special string sample with the general string sample, and generating a first mapping relationship between the special string sample and the general string sample. According to the source code generation method provided by the invention, the natural language strings can automatically generate the code segments, thereby reducing the work loads of software development and meeting different use demands of users.

Description

A kind of source code generation method
Technical field
The present invention relates to a kind of source code generation method of natural language as input of usining.
Background technology
At present, natural language processing technique just progressively starts practical (for example: the programming tool based on natural language, speech control system etc.), but still in the more elementary stage.
Existing natural language processing technique is just mapped as a function by a natural language character string conventionally.For example: " transmission note " is mapped as to certain function in mobile phone.Certainly, the sequence that a natural language character string is mapped as to a plurality of functions is also easy to, because this way is equivalent to, these functions is encapsulated as to a new function.
The essence of above-mentioned these implementation methods is: set up the mapping table between " character string " and " code segment ", when " character string " is transfused to, carry out corresponding " code segment ".Certainly, this mapping can be multi-to-multi, for example: same " character string " is mapped as difference " code segment " under different application environment; A plurality of " character strings " are mapped as same " code segment ".
Yet, these methods exist following defect to be: " code segment " is that slip-stick artist finishes writing in advance, this means that slip-stick artist will judge which " character string " user can input in advance, because the user of magnanimity has the differentiated demand of magnanimity, therefore, these methods obviously do not meet the differentiation trend of demand.
Summary of the invention
The problem existing in order to solve above-mentioned prior art, the present invention aims to provide a kind of source code generation method, so that natural language character string automatic code generating section, thereby reduce software development workload estimate, meet user's multiple user demand.
A kind of source code generation method of the present invention, comprises the following steps:
Step S1, in database storing character string example, with a described character string routine corresponding character string general rule and the code segment general rule corresponding with described character string general rule, wherein, a described character string example is the subset of character string general rule;
Step S2, a character string example of retrieval and the string matching of peripheral input in described database, routine if retrieval obtains this character string, perform step S3, otherwise return to the described step S1 of execution;
Step S3, the character string general rule that retrieval obtains and the character string obtaining in described step S2 example is corresponding in described database, and this character string routine and character string general rule relatively, generate the first mapping relations of the routine and character string general rule of this character string;
Step S4, in described database, retrieval obtains the code segment general rule corresponding with the character string general rule obtaining in described step S3, and relatively this character string general rule and code segment general rule, generates the second mapping relations of this character string general rule and code segment general rule;
Step S5, according to described the first mapping relations and described the second mapping relations, replaces the code segment general rule obtaining in described step S4 to generate source code.
In above-mentioned source code generation method, described step S1 is also included in a plurality of escape character (ESC)s that in described database, storage is formed by described character string general rule decomposition and gangs up example.
In above-mentioned source code generation method, be included in described step S4 and carry out afterwards:
Step S6, in described database, retrieval obtains a plurality of escape character (ESC)s corresponding with the character string general rule obtaining in described step S4 and gangs up example, and generates this character string general rule and gang up the 3rd routine mapping relations with a plurality of escape character (ESC);
Step S7, each escape character (ESC) in described step S6 is ganged up to example as a character string general rule, and in described database the retrieval code segment general rule corresponding with each character string general rule, if retrieval obtains code segment general rule, perform step S8, otherwise, according to described the first mapping relations, described escape character (ESC) is ganged up to example and replace with an escape character (ESC) string example, and using this escape character (ESC) string example as character string general rule, the retrieval code segment general rule corresponding with this character string general rule in described database, if retrieval obtains code segment general rule, perform step S8, otherwise return to execution step S1,
Step S8, the code segment general rule corresponding with it of the character string general rule in more described step S7 and acquisition, and generate the 4th mapping relations of this character string general rule and code segment general rule;
Step S9, according to described the first mapping relations, described the 3rd mapping relations and described the 4th mapping relations, replaces the code segment general rule obtaining in described step S7 to generate extended source code;
Step S10, according to described the second mapping relations and described the 3rd mapping relations, enters in the code segment general rule obtaining in described step S4 the extended source code obtaining in a plurality of described step S9 is nested, generates source code.
In above-mentioned source code generation method, described step S6 is also included in and in described database, stores described the 3rd mapping relations.
In above-mentioned source code generation method, described step S8 is also included in and in described database, stores described the 4th mapping relations.
In above-mentioned source code generation method, described step S3 is also included in and in described database, stores described the first mapping relations.
In above-mentioned source code generation method, described step S4 is also included in the mapping relations of storing described second in described database.
Owing to having adopted above-mentioned technical solution, the present invention has the following advantages:
1, improve software development efficiency, reduce software development difficulty
Most of work simplification under the collaboration mode that slip-stick artist's design and existing programming tool can be realized is to the difficulty of writing document, most of work simultaneously (for example can be ignored details, by digraph boil down to character string, repeatedly carry out), thus development efficiency improved.
For example, for products such as smart mobile phone and intelligent televisions, mostly adopt the pattern in application shop.Reduce software development difficulty, mean that more people can participate in the exploitation of application, thereby obtain more application.
Further, can make not have the people of programming experience to participate in software development, thereby obtain better application.For example: allow doctor develop the software relevant with medicine.
2, the user who improves electronic product experiences
Adopt the present invention to generate different software source codes according to user's different demands, be similar to as the most applicable his software of each user's design, thereby improve user's experience.
General method for designing is with a few design, to meet most of users' joint demand, tends to like this ignore details and a few users.For example: some people's finger is thicker.
The present invention allows user after buying product, in the mode of natural language, revises a part of software to adapt to the demand of self.For example: icon is amplified to adapt to finger.
Certainly, the demand of this differentiation can solve by system setting, but problem is slip-stick artist, can not judge in advance the demand that has which differentiation.In the present invention, as long as database is placed on the server in high in the clouds, just can constantly increases the character string of support, thereby support increasing differentiated demand.
Embodiment
Below in conjunction with embodiment, the present invention is described in detail.
The present invention, i.e. a kind of source code generation method, comprises the following steps:
Step S1, in database storing character string example, with a character string routine corresponding character string general rule and the code segment general rule corresponding with character string general rule, wherein, a character string example is the subset of character string general rule;
Step S2, a character string example of retrieval and the string matching of peripheral input in database, routine if retrieval obtains this character string, perform step S3, otherwise return, perform step S1;
Step S3, in database, retrieval obtains and the character string obtaining in a step S2 character string general rule that example is corresponding, and relatively this character string example and character string general rule, generate and store the first mapping relations of the routine and character string general rule of this character string in database;
Step S4, in database, retrieval obtains the code segment general rule corresponding with the character string general rule obtaining in step S3, and relatively this character string general rule and code segment general rule, the second mapping relations that generate and store this character string general rule and code segment general rule in database;
Step S5, according to the character string general rule generating in the first mapping relations of the character string generating in a step S3 example and character string general rule and step S4 and the second mapping relations of code segment general rule, replaces the code segment general rule obtaining in step S4 to generate source code.
In source code generation method of the present invention, step S1 also comprises: example ganged up in a plurality of escape character (ESC)s that storage is split to form by character string general rule in database.In the case, this method is carried out after being included in step S4:
Step S6, in database, retrieval obtains a plurality of escape character (ESC)s corresponding with the character string general rule obtaining in step S4 and gangs up example, and generates and store this character string general rule gang up the 3rd routine mapping relations with a plurality of escape character (ESC) in database;
Step S7, each escape character (ESC) in step S6 is ganged up to example as a character string general rule, and in database the retrieval code segment general rule corresponding with each character string general rule, if retrieval obtains code segment general rule, perform step S8, otherwise, according to the first mapping relations that generate in step S3, escape character (ESC) is ganged up to example and replace with an escape character (ESC) string example, and using this escape character (ESC) string example as character string general rule, the retrieval code segment general rule corresponding with this character string general rule in database, if retrieval obtains code segment general rule, perform step S8, otherwise return to execution step S1,
Step S8, the code segment general rule corresponding with it of the character string general rule in comparison step S7 and acquisition, and the 4th mapping relations that generate and store this character string general rule and code segment general rule in database;
Step S9, according to the 4th mapping relations that generate in the 3rd mapping relations that generate in the first mapping relations that generate in step S3, step S6 and described step S8, replaces the code segment general rule obtaining in step S7 to generate extended source code;
Step S10, according to the 3rd mapping relations that generate in the second mapping relations that generate in step S4 and step S6, by the code segment general rule obtaining in the rapid S4 of the nested progress of extended source code obtaining in a plurality of step S9, generates source code.
Known based on above-mentioned steps, in the database of mentioning, need to preserve following information in step S1 of the present invention:
1, a character string example: for example, " 100 ";
2, character string general rule: for example, " numeral ";
The relation of general rule and an example is a kind of relativeness that can cascade, also can be understood as classification, and individual example is subset or the special case of general rule, and for example, " 100 " are examples of " 10 systems numeral ", and " 10 systems numeral " is an example of " numeral "; Individual example and general rule are concepts comparatively speaking, for example: " 10 system numeral " relatively " 100 " is general rule, and " numeral " is an example relatively; If two character strings comprise respectively " individual example " and " general rule ", and other parts are in full accord, these two character strings " individual example " and " general rule " also each other so, for example " 100+100=200 " is an example of " numeral+numeral=numeral "; If two sections of source codes comprise respectively " individual example " and " general rule ", and other parts are in full accord, these two source codes " individual example " and " general rule " also each other so, for example " SendMsg (" Tom ") " is an example of " SendMsg (" name ") ";
3, the first mapping relations: for example, character string example " 100 " corresponding character string general rule " numeral ", the first mapping relations are " numeral is 100 ";
4, code segment general rule: can be both character string form, also can be algorithm form, and must be not line code, also can be multirow code, comprise: the control statements such as the computings such as preset function, chained list scheduling algorithm, addition and If etc., for example, " numeral=numeral " of character string form, " output numeral " " output=" " output numeral " of algorithm form, code segment general rule changes with the variation of source code program language, for example: the code segment general rule that C language and Java language are corresponding is different; In different software, also there is different code segment general rules, for example: the function that obtains system time in different operating system is just different; A part " the code segment general rule that character string general rule is corresponding ", is exactly the using method of certain function in fact, for example: " obtaining system time character string " is corresponding to function " character string=GetSysTime () "; What the present invention illustrated is a kind of general method, and is not limited to concrete programming language or software;
5, the second mapping relations: for example, corresponding code segment general rule " numeral=numeral " that character string general rule " is given numeral by digital assignment ", the second mapping relations are " the 1st numeral of code segment general rule is the 2nd numeral of character string general rule, and the 2nd numeral of code segment general rule is the 1st numeral of character string general rule ";
6, example ganged up in escape character (ESC): for example, character string example " if a be greater than 0 so b equal 0 " corresponding character string general rule " if data be greater than data so data equal data ", this character string general rule can be decomposed into that example " data are greater than data " ganged up in first escape character (ESC) and example " data equal data " ganged up in second escape character (ESC);
7, the 3rd mapping relations: for example, character string general rule " if data be greater than data so data equal data " example " data are greater than data " ganged up in corresponding first escape character (ESC) and example " data equal data " ganged up in second escape character (ESC), the 3rd mapping relations are for " the 1st numeral of character string general rule ganged up the 1st numeral in example for first escape character (ESC), the 2nd numeral of character string general rule ganged up the 2nd numeral in example for first escape character (ESC), the 3rd numeral of character string general rule is that the 1st numeral in example ganged up in second escape character (ESC), the 4th numeral of character string general rule is that the 2nd numeral in example ganged up in second escape character (ESC) ",
8, the 4th mapping relations: the essence of this relation is identical with the second mapping relations, for example, corresponding code segment general rule " data > data " when example " data are greater than data " ganged up as character string general rule in first escape character (ESC), the 4th mapping relations are " the 1st numeral of code segment general rule is the 1st numeral that example ganged up in first escape character (ESC), and the 2nd numeral of code segment general rule is the 2nd numeral that example ganged up in first escape character (ESC) ".
The character string of the periphery input of mentioning in step S2 of the present invention, (identification of natural language refers to: sentence is separated as word to be defaulted as in the present invention the natural language character string that process has correctly been identified; The implication of identification word and sentence; The analytical algorithms such as the fuzzy matching of character string), the present invention only solves the problem that generates source code of how being replaced.
The information in database that it should be noted that can constantly be added, and uses the slip-stick artist of existing programming tool in use can constantly increase information, or can understand like this: to database, add information=teaching and administrative staff tool and write code; Utilize the Information generation code of database=use instrument generating code; Specifically:
1, when instrument cannot just should be write code by teaching and administrative staff's tool during generating code; Due to can synchronizing information between database, so as long as there is a people church instrument to generate certain code, all instruments have just all been learned.
2,, when instrument generates source code, also setting up mapping relations simultaneously
A) for example: completed function G et_SysTime, act as " the acquisition system time " of this function is described to instrument simultaneously;
B) instrument is set up corresponding relation between " acquisition system time " and " data=Get_SysTime () ", wherein needs slip-stick artist to input necessary information;
C) in other words, generating the process of certain module source code with instrument, is exactly to be the process of other module ready message.
On stricti jurise, in database, both can preserve the mapping relations between " a character string example " and " a code segment example ", also can preserve the mapping relations between " character string general rule " and " code segment general rule ", this is contradiction not, just as a people both can " 1+1 ", also can " integer+integer ", also can " real number+real number ", and difference is, general rule degree is higher, need the information of preservation fewer, therefore, in the present invention, select to preserve the mapping relations between " character string general rule " and " code segment general rule ".
Below by illustrating above-mentioned steps S3-step S5.
For example, be " by data1 assignment to data2 " with a character string example for the string matching of periphery input;
Step S3, retrieve the character string general rule corresponding with character string example " by data1 assignment to data2 " " by digital assignment to digital ", compare after both simultaneously, generating and storing the first mapping relations M1 is: the 1st numeral of character string general rule is data1, and the 2nd numeral of character string general rule is data2 (these first mapping relations M1 comes from analytic process: data1 and data2 are replaced by numeral);
Step S4, retrieve and the character string general rule code segment general rule " numeral=numeral " that " to give numeral by digital assignment " corresponding, compare after both simultaneously, generating and storing the second mapping relations M2 is: the 1st numeral of code segment general rule is the 2nd numeral of character string general rule, and the 2nd numeral of code segment general rule is the 1st numeral of character string general rule;
Step S5, according to the first mapping relations M1 and the second mapping relations M2, replaces with source code " data2=data1 " by code segment general rule " numeral=numeral "; In the present embodiment, the process of this " replacement " can adopt existing program means to realize, and for example, utilizes the programming tool of magnificent sub-micro electronics corporation design to realize; Its principle is as follows:
(1) scan code section general rule, finds the character string general rule wherein comprising: the 1st " numeral " and the 2nd " numeral ";
(2) by the first mapping relations M1 and the second mapping relations M2, obtained: the 1st numeral is data2, the 2nd numeral is data1;
(3) by data2 and data1 substitution " numeral=numeral ", that is, by simple character string replacement, just can obtain source code and " data2=data1 ".
Below by illustrating above-mentioned steps S3, step S4, step S6-step S10.
For example, with a character string example for the string matching of periphery input be " if a be greater than 0 so b equal 0 ";
Step S3, retrieve with character string example " if a be greater than 0 so b equal 0 " corresponding character string general rule " if data be greater than data so data equal data ", compare after both simultaneously, generating and storing the first mapping relations M1 is: the 1st numeral of character string general rule is a, the 2nd numeral of character string general rule is 0, the 3rd numeral of character string general rule is b, and the 4th numeral of character string general rule is 0;
Step S4, retrieve with character string general rule " if data be greater than data so data equal data " corresponding code segment general rule " If (X) { X} ", compare after both simultaneously, generating and storing the second mapping relations M2 is: the 1st X of code segment general rule is " data are greater than data " in character string general rule, and the 2nd X of code segment general rule is character string general rule " data equal data ";
Step S6, retrieve with character string general rule " if data be greater than data so data equal data " example " data are greater than data " ganged up in corresponding first escape character (ESC) and example " data equal data " ganged up in second escape character (ESC), generate and store the 3rd mapping relations M3 is simultaneously: the 1st numeral of character string general rule ganged up the 1st numeral in example for first escape character (ESC), the 2nd numeral of character string general rule ganged up the 2nd numeral in example for first escape character (ESC), the 3rd numeral of character string general rule is that the 1st numeral in example ganged up in second escape character (ESC), the 4th numeral of character string general rule is that the 2nd numeral in example ganged up in second escape character (ESC),
Step S7, corresponding code segment general rule " data > data " when retrieving first escape character (ESC) and ganging up example " data are greater than data " as character string general rule, corresponding code segment general rule " data=data " when retrieving second escape character (ESC) and ganging up example " data equal data " as character string general rule;
Step S8, relatively first escape character (ESC) is ganged up after example " data are greater than data " and the code segment general rule " data > data " corresponding with it, generating and storing the 4th mapping relations M4 is: the 1st numeral of code segment general rule is the 1st numeral that example ganged up in first escape character (ESC), and the 2nd numeral of code segment general rule is the 2nd numeral that example ganged up in first escape character (ESC); Relatively second escape character (ESC) ganged up after example " data are greater than data " and the code segment general rule " data=data " corresponding with it, generating and storing the 4th mapping relations M4 is: the 1st numeral of code segment general rule is the 1st numeral that example ganged up in second escape character (ESC), and the 2nd numeral of code segment general rule is the 2nd numeral that example ganged up in second escape character (ESC);
Step S9, according to the first mapping relations M1, the 3rd mapping relations M3 and the 4th mapping relations M4, the code segment general rule obtaining in step S7 " data > data " and " data=data " are replaced respectively to generation extended source code " a > 0 " and " b=0 ";
Step S10, according to the second mapping relations M2 and the 3rd mapping relations M3, by in the code segment general rule obtaining in the rapid S4 of the nested progress of extended source code obtaining in a plurality of step S8 " If (X) { X} ", generate source code " If (a > 0) { b=0} ".
Enumerate again lower example herein with the another kind of situation in explanation above-mentioned steps S7.
For example, a character string example is " ordering 10 apples ", the character string general rule retrieving is " ordering weight jin goods ", retrieve 3 escape character (ESC)s that are decomposed to form by character string general rule " order weight jin goods " and gang up example: " unit price of inquiry goods ", " total price=unit price * weight " and " payment total price ", here, " 10 " are examples of " weight ", and " apple " is an example of " goods ";
At 3 escape character (ESC)s of retrieval, gang up in code segment general rule process corresponding to example, cannot retrieve with escape character (ESC) and gang up code segment general rule corresponding to example " unit price of inquiry goods ", now just attempt that this escape character (ESC) is ganged up to example inner each " general rule " and oppositely replace with " individual example ", replace with an escape character (ESC) string example and search code segment general rule (can find as long as there is in various array configuration), herein, escape character (ESC) is ganged up to example " unit price of inquiry goods " and replace with an escape character (ESC) string example " unit price of inquiry apple ", and retrieve corresponding code segment general rule " unit price=GetApplePrice () ", example " total price=unit price * weight " ganged up in other two escape character (ESC)s and " payment total price " distinguishes corresponding code segment general rule " total price=unit price * weight " and " Pay (total price) ",
It should be noted that herein, two special words that occur in above-mentioned code segment general rule: " unit price " and " total price ", code segment general rule is being replaced with to the process of source code, also need these two words to replace, then in an original character string example, be not occur this two words in " ordering 10 apples ", therefore, just need in this case automatically to generate a unduplicated interim character string, as temporary variable, its type can be definite by the place of using, for example the rreturn value type of function G etApplePrice; Interim character string refers to: character string general rule is decomposed into a plurality of escape character (ESC)s and gangs up the character string occurring after example, and " unit price " and " total price " herein for example, the information that defines interim character string is also stored in the 3rd mapping relations; Do not repeat to refer to that the variable name in source code can not repeat, for example: the numerical value of prefix+increase progressively, ABCD_00000000001, while generating source code, character string " definition unit price " is corresponding to " int ABCD_00000000001 ".In code segment general rule, the place of all using " unit price " all replaces with ABCD_00000000001.
Again, as described above, can multilayer cascade between " the individual example " in the present invention and " general rule ", so can reduce and need the mapping relations quantity safeguarded by multilayer cascade.For example go up in example and can think, " weight ", " unit price ", " total price " are all examples of " numeral ", therefore, escape character (ESC) is ganged up example " total price=unit price * weight " and be can be used as a character string example, replace to character string general rule " numeral=digital * numeral ", that is to say, this character string general rule " numeral=digital * numeral " can solve the problem of all multiplication, so user does not need to safeguard the multiplication relation between the character strings such as " weight ", " unit price ", " total price ".
It should be noted that, when repeatedly occurring, same character string need to distinguish, for example going up " numeral " in example has occurred 3 times, wherein a kind of differentiating method for example can be, by the several bytes of character code extended length (expanding to 4 bytes from the 2 byte code forms of Unicode) in analytic process, then in expansion storage side-play amount, after analysis finishes, convert back original coded format, these are all technological means conventional in prior art again.
In the present invention, character string general rule can be decomposed into several escape character (ESC)s and gang up routine chain type sequence, in fact also can be decomposed into the digraph sequence that is similar to process flow diagram, for example: " if * * is *, * * * so, otherwise * * * "; Each node in digraph is that example ganged up in escape character (ESC), and each escape character (ESC) gangs up example and can be decomposed into the digraph of details more, or corresponding certain code segment general rule.The linking relationship of digraph is corresponding if, for, switch etc. code segment general rule optionally, for example: " if (* * *) { * * * } else{***} ".Certainly, this digraph sequence and process flow diagram still have essential difference: by existing programming tool, can generate source code according to this digraph sequence, and process flow diagram in software needs slip-stick artist manually to write source code.
In view of this, this method can be by character string of complicated digraph boil down to, its essence is the compression of information, and this compression process can be carried out repeatedly, be equivalent to the repeatedly nested of the control statements such as if, thereby Information Compression, to the limit, for using the people of " character string general rule ", can be ignored to the detail information wherein comprising completely.
In addition, also mentioned the situation of returning to step S1 in step of the present invention, this is that, database of descriptions lacks information because can not find at the very start a character string example in database, and report user requires interpolation information; Or in the process of decomposing in character string general rule, can not find corresponding code segment general rule, thereby cause generating source code failure; The latter be can rollback analytic process,, after introducing general rule and a routine mapping relations, there are a lot of different explanations in character string, analytic process is to attempt gradually various possibilities, until there are a kind of successful or all failures, if failure, also database of descriptions lacks information, and report user requires interpolation information.
Known based on above-mentioned explanation, the prerequisite of this method application is building database, and this database can be kept on the server in high in the clouds, preserves example and the general rule relation between character string, the code segment general rule that character string general rule is corresponding, the extended pattern mapping relations between character string general rule.And do not need to have prejudged which character string, relevant information can constantly be added in operational process, in other words: user does not need to guess which character string user can input, just when there is the character string that instrument cannot be processed, add this character string, and any one user can add the character string that he needs.And due to can synchronizing information between information bank, so everyone can use as long as there is a user to input certain character string.This seems huge workload is to be shared by all users in fact, and user is more, and the workload that everyone assigns to is less.
The present invention can have following application model:
Pattern 1, user are slip-stick artists, for example, and for developing automatic programming instrument.
Under this pattern, can utilize existing programming tool to generate source code according to the character string of slip-stick artist's input.And in software development, some work is that existing programming tool cannot complete (such as coding and decoding video algorithm etc.) automatically, the work of this part is still manually completed by slip-stick artist, therefore, this pattern is the cooperated process of software of slip-stick artist and existing programming tool in fact,, slip-stick artist's design, instrument is realized.
For example: slip-stick artist specifies the acting as of certain function " inserting new node p_node to chained list p_chain ", and (this is a character string example, so contain p_chain etc.), retrieve character string general rule and " to chained list character string, insert new node character string ", just according to code segment general rule corresponding to general rule, generate source code, then the character string in code segment general rule is replaced with to p_chain etc.
Under this pattern, the user of instrument can classify two kinds, and senior slip-stick artist is responsible for input of character string general rule, code segment general rule and various corresponding relation between them, and by synchronizing information between information bank, all slip-stick artists can use these information; Common slip-stick artist is responsible for an input of character string example.For common slip-stick artist, he can complete software development completely in the situation that not understanding ins and outs, thereby reduces work difficulty.
Pattern 2, user are ordinary consumer, for example, for realizing, strengthen voice-operated analytical algorithm.
Under this pattern, can utilize algorithm to generate source code according to the character string of user's input, the approach of user inputs character string can be speech recognition.Certainly, owing to not having slip-stick artist to assist, this pattern is not also suitable for complex software, can only splice the function that to be applicable to user's request based on " preset function ", conventionally be presented as application software, " preset function " herein refers to the function comprising in the software module that slip-stick artist writes in advance, and these modules are preset in product, for example: database, file system etc.
For example: user requires " playing the 10th television channel " (this is a character string example), according to algorithm, retrieve character string general rule and " play a numeral television channel ", then expand to " numbering that obtains a numeral television channel from database " and " according to numbering, playing television channel ", then replace with source code.
The programming language of the code generating under this pattern should be selected interpreted languages, such as Action Script etc.Database will be kept in the server in high in the clouds simultaneously, to constantly increase the character string that can support.
For example: user says " shielding all phones from Shanghai " to mobile phone, and this character string is sent back to the cloud server of cellular telephone companies, server is attempted revising according to character string the module of answering the call.If also do not support at present, return to failure and report to service engineer.Service engineer adds after relevant information to database, then has this class instruction to be sent to server, just can automatically generate source code and send it back mobile phone.
The present invention and down load application program are differentiated: in the present invention, user, only with the demand of natural language statement oneself, neither needs to search application program, also do not need to download and install.The present invention is more suitable for the modification of small or details.
Pattern 2 can cooperate with pattern 1, and slip-stick artist completes " preset function " 1 time in pattern, and ordinary consumer splices the function of oneself liking 2 times in pattern based on " preset function ".
Above-described, be only preferred embodiment of the present invention, not in order to limit scope of the present invention, the above embodiment of the present invention can also make a variety of changes.Be that simple, the equivalence that every claims according to the present patent application and description are done changes and modify, all fall into the claim protection domain of patent of the present invention.The present invention not detailed description be routine techniques content.

Claims (7)

1. a source code generation method, is characterized in that, said method comprising the steps of:
Step S1, in database storing character string example, with a described character string routine corresponding character string general rule and the code segment general rule corresponding with described character string general rule, wherein, a described character string example is the subset of character string general rule;
Step S2, a character string example of retrieval and the string matching of peripheral input in described database, routine if retrieval obtains this character string, perform step S3, otherwise return to the described step S1 of execution;
Step S3, the character string general rule that retrieval obtains and the character string obtaining in described step S2 example is corresponding in described database, and this character string routine and character string general rule relatively, generate the first mapping relations of the routine and character string general rule of this character string;
Step S4, in described database, retrieval obtains the code segment general rule corresponding with the character string general rule obtaining in described step S3, and relatively this character string general rule and code segment general rule, generates the second mapping relations of this character string general rule and code segment general rule;
Step S5, according to described the first mapping relations and described the second mapping relations, replaces the code segment general rule obtaining in described step S4 to generate source code.
2. source code generation method according to claim 1, is characterized in that, described step S1 is also included in a plurality of escape character (ESC)s that in described database, storage is formed by described character string general rule decomposition and gangs up example.
3. source code generation method according to claim 2, is characterized in that, described method is carried out after being included in described step S4:
Step S6, in described database, retrieval obtains a plurality of escape character (ESC)s corresponding with the character string general rule obtaining in described step S4 and gangs up example, and generates this character string general rule and gang up the 3rd routine mapping relations with a plurality of escape character (ESC);
Step S7, each escape character (ESC) in described step S6 is ganged up to example as a character string general rule, and in described database the retrieval code segment general rule corresponding with each character string general rule, if retrieval obtains code segment general rule, perform step S8, otherwise, according to described the first mapping relations, described escape character (ESC) is ganged up to example and replace with an escape character (ESC) string example, and using this escape character (ESC) string example as character string general rule, the retrieval code segment general rule corresponding with this character string general rule in described database, if retrieval obtains code segment general rule, perform step S8, otherwise return to execution step S1,
Step S8, the code segment general rule corresponding with it of the character string general rule in more described step S7 and acquisition, and generate the 4th mapping relations of this character string general rule and code segment general rule;
Step S9, according to described the first mapping relations, described the 3rd mapping relations and described the 4th mapping relations, replaces the code segment general rule obtaining in described step S7 to generate extended source code;
Step S10, according to described the second mapping relations and described the 3rd mapping relations, enters in the code segment general rule obtaining in described step S4 the extended source code obtaining in a plurality of described step S9 is nested, generates source code.
4. source code generation method according to claim 3, is characterized in that, described step S6 is also included in and in described database, stores described the 3rd mapping relations.
5. according to the source code generation method described in claim 3 or 4, it is characterized in that, described step S8 is also included in and in described database, stores described the 4th mapping relations.
6. according to the source code generation method described in claim 1,2,3 or 4, it is characterized in that, described step S3 is also included in and in described database, stores described the first mapping relations.
7. source code generation method according to claim 6, is characterized in that, described step S4 is also included in and in described database, stores described the second mapping relations.
CN201210126647.XA 2012-04-26 2012-04-26 Source code generation method Active CN102707948B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210126647.XA CN102707948B (en) 2012-04-26 2012-04-26 Source code generation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210126647.XA CN102707948B (en) 2012-04-26 2012-04-26 Source code generation method

Publications (2)

Publication Number Publication Date
CN102707948A CN102707948A (en) 2012-10-03
CN102707948B true CN102707948B (en) 2014-11-26

Family

ID=46900772

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210126647.XA Active CN102707948B (en) 2012-04-26 2012-04-26 Source code generation method

Country Status (1)

Country Link
CN (1) CN102707948B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104360861A (en) * 2014-11-19 2015-02-18 成都实景信息技术有限公司 Software code compiling system
CN106293725B (en) * 2016-08-04 2021-03-02 深圳市微我科技有限公司 Natural language hybrid programming method based on post-realization
CN106250159B (en) * 2016-08-04 2020-12-22 深圳市微我科技有限公司 Mixed programming method using natural language
CN109408049A (en) * 2018-10-13 2019-03-01 彭熹 A kind of method and system from natural language automatically generating program code
WO2020257973A1 (en) 2019-06-24 2020-12-30 Citrix Systems, Inc. Detecting hard-coded strings in source code
CN112394926A (en) * 2020-12-03 2021-02-23 钟月珠 Code bed system based on natural language model
CN115993955B (en) * 2023-03-23 2023-06-23 山东大学 Source code generation and test method and system for symmetric cryptographic algorithm

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101968785A (en) * 2009-07-28 2011-02-09 万继华 Logical machine model capable of understanding human natural language
US8042093B1 (en) * 2001-11-15 2011-10-18 Cypress Semiconductor Corporation System providing automatic source code generation for personalization and parameterization of user modules
CN102306102A (en) * 2011-08-25 2012-01-04 中兴通讯股份有限公司 Method and device for automatically generating program file

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8042093B1 (en) * 2001-11-15 2011-10-18 Cypress Semiconductor Corporation System providing automatic source code generation for personalization and parameterization of user modules
CN101968785A (en) * 2009-07-28 2011-02-09 万继华 Logical machine model capable of understanding human natural language
CN102306102A (en) * 2011-08-25 2012-01-04 中兴通讯股份有限公司 Method and device for automatically generating program file

Also Published As

Publication number Publication date
CN102707948A (en) 2012-10-03

Similar Documents

Publication Publication Date Title
CN102707948B (en) Source code generation method
CN107918666B (en) Data synchronization method and system on block chain
CN101661391B (en) Object serializing method, object deserializing method, device and system
CN104298496B (en) data analysis type software development framework system
CN110032369A (en) A kind of code automatic generation method, device and medium
CN104035754A (en) XML (Extensible Markup Language)-based custom code generation method and generator
KR20220115046A (en) Method and appartuas for semantic retrieval, device and storage medium
US20220019739A1 (en) Item Recall Method and System, Electronic Device and Readable Storage Medium
CN108829884A (en) data mapping method and device
CN105975446A (en) Method and system for displaying word document content by modules in mobile phone terminal
CN111475511A (en) Data storage method, data access method, data storage device, data access device and data access equipment based on tree structure
CN112328257A (en) Code conversion method and device
CN117033309A (en) Data conversion method and device, electronic equipment and readable storage medium
CN111488464A (en) Entity attribute processing method, device, equipment and medium
CN115794105A (en) Micro-service extraction method and device and electronic equipment
CN115132186A (en) End-to-end speech recognition model training method, speech decoding method and related device
CN114860872A (en) Data processing method, device, equipment and storage medium
CN114116779A (en) Deep learning-based power grid regulation and control field information retrieval method, system and medium
CN103838742A (en) Method and device for processing compression parameters of multimedia files
CN113609822A (en) Cross-service tree data conversion method and related equipment
CN106339454A (en) Inquiry-command conversion method and device
CN112631567A (en) Method and device for generating database operation file
CN113821211B (en) Command parsing method and device, storage medium and computer equipment
JP7293544B2 (en) Q&A system update processing method and device
CN115455036B (en) Processing method, device, equipment and medium of joint statement

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
ASS Succession or assignment of patent right

Owner name: SHANGHAI WEIZHOU MICROELECTRONIC TECHNOLOGY CO., L

Free format text: FORMER OWNER: HUAYA MICRO-ELECTRONIC (SHANGHAI) CO., LTD.

Effective date: 20150108

C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20150108

Address after: 201203, Shanghai 690 Zhangjiang Road, Pudong New Area No. 5 Building No. 2 floor

Patentee after: SHANGHAI WEI ZHOU MICROELECTRONICS TECHNOLOGY CO., LTD.

Address before: 201203, room 5, building 690, No. 201-202 blue wave road, Zhangjiang hi tech park, Shanghai, Pudong New Area

Patentee before: Huaya Microelectronics (Shanghai) Co., Ltd.

TR01 Transfer of patent right

Effective date of registration: 20200401

Address after: 215634 north side of Chengang road and west side of Ganghua Road, Jiangsu environmental protection new material industrial park, Zhangjiagang City, Suzhou City, Jiangsu Province

Patentee after: ZHANGJIAGANG KANGDE XIN OPTRONICS MATERIAL Co.,Ltd.

Address before: 201203, Shanghai 690 Zhangjiang Road, Pudong No. 5 Building No. 2 floor

Patentee before: WZ TECHNOLOGY Inc.

TR01 Transfer of patent right