CN102707948A - Source code generation method - Google Patents

Source code generation method Download PDF

Info

Publication number
CN102707948A
CN102707948A CN201210126647XA CN201210126647A CN102707948A CN 102707948 A CN102707948 A CN 102707948A CN 201210126647X A CN201210126647X A CN 201210126647XA CN 201210126647 A CN201210126647 A CN 201210126647A CN 102707948 A CN102707948 A CN 102707948A
Authority
CN
China
Prior art keywords
general rule
character string
mapping relations
code segment
database
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.)
Granted
Application number
CN201210126647XA
Other languages
Chinese (zh)
Other versions
CN102707948B (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 with the source code generation method of natural language as input.
Background technology
At present, natural language processing technique just progressively begins practicability (for example: based on the programming tool of natural language, speech control system etc.), but still is in the more elementary stage.
Existing natural Language Processing technology just is mapped as a function with a natural language character string usually.For example: " transmission note " is mapped as certain function in the mobile phone.Certainly, the sequence that a natural language character string is mapped as a plurality of functions also is easy to, because this way is equivalent to these functions is encapsulated as 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 " when being transfused to, carry out " code segment " accordingly.Certainly, this mapping can be a multi-to-multi, and for example: same " character string " is mapped as difference " code segment " under the different application environment; A plurality of " character strings " are mapped as same " code segment ".
Yet; Defective below these methods exist is: " code segment " is that the slip-stick artist finishes writing in advance; This means that the slip-stick artist will judge in advance which " character string " user can import; 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
In order to solve the problem that above-mentioned prior art exists, the present invention aims to provide a kind of source code generation method, so that the automatic generating code section of natural language character string, thereby reduce the software development workload, satisfy user's multiple user demand.
A kind of source code generation method of the present invention may further comprise the steps:
Step S1, in database store character string example, gang up example and the code segment general rule corresponding with the individual routine corresponding characters of said character string with said character string general rule, wherein, a said character string example is the subclass of character string general rule;
Step S2, the character string of the string matching of a retrieval and peripheral input example in said database obtains this character string example if retrieve, and then execution in step S3 carries out said step S1 otherwise return;
Step S3, in said database retrieval obtain with said step S2 in the character string that obtains a routine corresponding characters gang up example, and this character string example and character string general rule relatively generates first mapping relations of the routine and character string general rule of this character string;
Step S4, in said database retrieval obtain with said step S3 in the corresponding code segment general rule of character string general rule that obtains, and relatively this character string general rule and code segment general rule generate second mapping relations of this character string general rule and code segment general rule;
Step S5 according to said first mapping relations and said second mapping relations, generates source code with the code segment general rule replacement that obtains among the said step S4.
In above-mentioned source code generation method, said step S1 also is included in the said database storage and decomposes a plurality of escape character (ESC)s that form by said character string general rule and gang up example.
In above-mentioned source code generation method, be included in said step S4 and carry out afterwards:
Step S6, in said database retrieval obtain with said step S4 in the corresponding a plurality of escape character (ESC)s of character string general rule that obtain gang up example, and generate this character string general rule and the 3rd routine mapping relations ganged up in a plurality of escape character (ESC);
Step S7 gangs up each escape character (ESC) among the said step S6 with example as a character string general rule, and in said database, retrieves the code segment general rule corresponding with each character string general rule; If retrieval obtains the code segment general rule, execution in step S8 then, otherwise; According to said first mapping relations, example ganged up in said escape character (ESC) replace with escape character (ESC) string example, and this escape character (ESC) string is routine as the character string general rule; The retrieval code segment general rule corresponding in said database with this character string general rule; If retrieval obtains the code segment general rule, execution in step S8 then, otherwise return execution in step S1;
Step S8, the code segment general rule corresponding of character string general rule among the more said step S7 and acquisition with it, and generate the 4th mapping relations of this character string general rule and code segment general rule;
Step S9 according to said first mapping relations, said the 3rd mapping relations and said the 4th mapping relations, generates the extended source code with the code segment general rule replacement that obtains among the said step S7;
Step S10 according to said second mapping relations and said the 3rd mapping relations, advances in the code segment general rule that obtains among the said step S4 the extended source code that obtains among a plurality of said step S9 is nested, generates source code.
In above-mentioned source code generation method, said step S6 also is included in said the 3rd mapping relations of storage in the said database.
In above-mentioned source code generation method, said step S8 also is included in said the 4th mapping relations of storage in the said database.
In above-mentioned source code generation method, said step S3 also is included in said first mapping relations of storage in the said database.
In above-mentioned source code generation method, said step S4 also is included in the mapping relations of storage said second in the said database.
Owing to adopted above-mentioned technical solution, the present invention has the following advantages:
1, improves software development efficiency, reduce the software development difficulty
Can with slip-stick artist design with have collaboration mode most of work simplification down that programming tool realizes now to the difficulty of writing document, most of work of while can be ignored details (for example, with digraph boil down to character string, carrying out repeatedly), thus raising development efficiency.
For example, as far as products such as smart mobile phone and intelligent televisions, adopt the pattern of using the shop mostly.Reduce the software development difficulty, mean the exploitation that more people can participate in using, thereby obtain more applications.
Further, can make the people of the experience of not programming participate in software development, thereby obtain better application.For example: let the doctor develop the software relevant with medicine.
2, improve the user experience of electronic product
Adopt the present invention to generate the Different software source code, be similar to and be the most suitable his software of each user's design, thereby improve user experience according to user's different demands.
General method for designing is to satisfy most of users' joint demand with a few design, does tending to ignore details and few users like this.For example: some people's finger is thicker.
The present invention then allows the user after buying product, revises a part of software to adapt to the demand of self with the mode of natural language.For example: amplify icon to adapt to finger.
Certainly, the demand of this differentiation can solve through system's setting, can not judge the demand that has which differentiation in advance but problem is the slip-stick artist.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, promptly a kind of source code generation method may further comprise the steps:
Step S1, in database store character string example, gang up example and the code segment general rule corresponding with the individual routine corresponding characters of character string with the character string general rule, wherein, a character string example is the subclass 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, execution in step S3 then, otherwise return execution in step S1;
Step S3; In database retrieval obtain with step S2 in the character string that obtains a routine corresponding characters gang up example; And relatively this character string example and character string general rule, generate and first mapping relations of the routine and character string general rule of this character string of storage in database;
Step S4; In database retrieval obtain with step S3 in the corresponding code segment general rule of character string general rule that obtains; And relatively this character string general rule and code segment general rule, generate and second mapping relations of this character string general rule of storage and code segment general rule in database;
Step S5 according to the character string general rule and second mapping relations of code segment general rule that generate among first mapping relations of the character string that generates among the step S3 example and character string general rule and the step S4, replaces the generation source code with the code segment general rule that obtains among the step S4.
In source code generation method of the present invention, step S1 also comprises: storage is ganged up example by a plurality of escape character (ESC)s that the character string general rule is split to form in database.In the case, this method is carried out after being included in step S4:
Step S6, in database retrieval obtain with step S4 in the corresponding a plurality of escape character (ESC)s of character string general rule that obtain gang up example, and generate and in database this character string general rule of storage and a plurality of escape character (ESC) gang up the 3rd routine mapping relations;
Step S7 gangs up each escape character (ESC) among the step S6 with example as a character string general rule, and in database, retrieves the code segment general rule corresponding with each character string general rule; If retrieval obtains the code segment general rule, execution in step S8 then, otherwise; According to first mapping relations that generate among the step S3, example ganged up in escape character (ESC) replace with escape character (ESC) string example, and this escape character (ESC) string is routine as the character string general rule; The retrieval code segment general rule corresponding in database with this character string general rule; If retrieval obtains the code segment general rule, execution in step S8 then, otherwise return execution in step S1;
Step S8, the code segment general rule corresponding of character string general rule among the comparison step S7 and acquisition, and the 4th mapping relations that generate and in database, store this character string general rule and code segment general rule with it;
Step S9 according to the 4th mapping relations that generate among the 3rd mapping relations that generate among first mapping relations that generate among the step S3, the step S6 and the said step S8, generates the extended source code with the code segment general rule replacement that obtains among the step S7;
Step S10 according to the 3rd mapping relations that generate among second mapping relations that generate among the step S4 and the step S6, in the code segment general rule that obtains among the rapid S4 of the nested progress of extended source code that obtains among a plurality of step S9, generates source code.
Can know based on above-mentioned steps, need to preserve following information in the database of in step S1 of the present invention, mentioning:
1, a character string example: for example, " 100 ";
2, character string general rule: for example, " numeral ";
But general rule is a kind of relativeness of cascade with a relation of example, also is appreciated that to be classification, and individual example is a sub-set 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 notions comparatively speaking, and for example: " 10 systems numeral " " 100 " relatively is general rule, and " numeral " is an example relatively; If two character strings comprise " individual example " and " general rule " respectively, and other part is 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 source codes comprise " individual example " and " general rule " respectively, and other part is 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, first mapping relations: for example, character string example " a 100 " corresponding character string general rule " numeral ", then first mapping relations are " numeral is 100 ";
4, code segment general rule: both can be the character string form; Can be the algorithm form also, and be not must be line code, also can be the multirow code; Comprise: control statement such as computing 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; The code segment general rule changes with the variation of source code program language, and for example: the C language is different with the corresponding code segment general rule of Java language; Different code segment general rules is also arranged in the Different software, and for example: the function that obtains system time in the different operating system is just different; A part " the code segment general rule that the character string general rule is corresponding " is exactly the method for application of certain function in fact, and for example: " obtaining the system time character string " is corresponding to function " character string=GetSysTime () "; What the present invention explained is a kind of method in common, and is not limited to concrete programming language or software;
5, second mapping relations: for example; Corresponding code segment general rule " numeral=numeral " that the character string general rule " is given numeral with digital assignment "; Then 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 greater than 0 so b equal 0 " corresponding character string general rule " if data greater than data so data equal data ", then 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; The character string general rule " if data 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); Then the 3rd mapping relations are " the 1st numeral of character string general rule ganged up the 1st numeral in the example for first escape character (ESC); the 2nd numeral of character string general rule ganged up the 2nd numeral in the example for first escape character (ESC); the 3rd numeral of character string general rule is that the 1st numeral in the example ganged up in second escape character (ESC), and the 4th numeral of character string general rule is that the 2nd numeral in the example ganged up in second escape character (ESC) ";
8, the 4th mapping relations: the essence of this relation is identical with second mapping relations; For example; Corresponding code segment general rule " data>data " when example " data are greater than data " ganged up as the character string general rule in first escape character (ESC); Then 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 mentioned among the step S2 of the present invention input, (identification of natural language is meant: sentence is separated be speech to be defaulted as natural language character string through correct identification in the present invention; The implication of identification speech and sentence; Algorithm is analyzed in the fuzzy matching of character string etc.), the present invention only solves how it is replaced the problem that generates source code.
The information in the 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, perhaps can understand like this: add information=teaching and administrative staff's tool to database and write code; Utilize the information generating code of database=use instrument generating code; Specifically:
1, can't just should write code by teaching and administrative staff's tool during generating code when instrument; Since can synchronizing information between the 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: accomplished 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 the slip-stick artist to import necessary information;
C) in other words, with the process of certain module source code of instrument generation, be exactly to be the process of other module ready message.
On the stricti jurise, both can preserve the mapping relations between " a character string example " and " a code segment example " in the database, 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 ", and also can " integer+integer "; Also can " real number+real number "; And difference is, the general rule degree is high more, needs the information of preservation few more; Therefore, select to preserve the mapping relations between " character string general rule " and " code segment general rule " among the present invention.
Above-mentioned steps S3-step S5 is described below by way of example.
For example, the character string example with the string matching of periphery input is " with the data1 assignment to data2 ";
Step S3; Retrieve and gang up example with character string the example corresponding characters of " giving data2 " and " give numeral " digital assignment with the data1 assignment; After comparing 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 corresponding code segment general rule " numeral=numeral " of " giving numeral " digital assignment; After comparing 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 " with code segment general rule " numeral=numeral "; In the present embodiment, the process of this " replacement " can adopt existing program means to realize, for example, utilizes the programming tool of magnificent sub-micro electronics corporation design to realize; Its principle is following:
(1) scan code section general rule finds the character string general rule that wherein comprises: the 1st " numeral " and the 2nd " numeral ";
(2) obtained by the first mapping relations M1 and the second mapping relations M2: the 1st numeral is data2, and the 2nd numeral is data1;
(3), that is, just can obtain source code through simple character string replacement and " data2=data1 " with data2 and data1 substitution " numeral=numeral ".
Above-mentioned steps S3, step S4, step S6-step S10 are described below by way of example.
For example, the character string example with the string matching of periphery input be " if a greater than 0 so b equal 0 ";
Step S3; Retrieve with character string example " if a greater than 0 so b equal 0 " corresponding characters gang up example " if data greater than data so data equal data "; Simultaneously relatively after both, generate and store the first mapping relations M1 and be: the 1st numeral of character string general rule is a, and 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 the character string general rule " if data greater than data so data equal data " corresponding code segment general rule " If (X) { X} "; After comparing 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 the 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 the character string general rule " if data greater than data so data equal data " example " data are greater than data " ganged up in first corresponding escape character (ESC) and example " data equal data " ganged up in second escape character (ESC); Generating and storing the 3rd mapping relations M3 simultaneously is: the 1st numeral of character string general rule ganged up the 1st numeral in the example for first escape character (ESC); The 2nd numeral of character string general rule ganged up the 2nd numeral in the example for first escape character (ESC); The 3rd numeral of character string general rule is that the 1st numeral in the example ganged up in second escape character (ESC), and the 4th numeral of character string general rule is that the 2nd numeral in the 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 the 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 the character string general rule;
Step S8; After relatively example " data are greater than data " and the code segment general rule " data>data " corresponding with it ganged up in first escape character (ESC); 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); After relatively example " data are greater than data " and the code segment general rule " data=data " corresponding with it ganged up in second escape character (ESC); 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, replaces generation extended source code " a>0 " and " b=0 " respectively with the code segment general rule " data>data " that obtains among the step S7 and " data=data ";
Step S10 according to the second mapping relations M2 and the 3rd mapping relations M3, in the code segment general rule that obtains among the rapid S4 of the nested progress of extended source code that obtains among a plurality of step S8 " If (X) { X} ", generates source code " If (a>0) { b=0} ".
Enumerate down example here again with the another kind of situation among the explanation above-mentioned steps S7.
For example; A character string example is " ordering 10 apples "; The character string general rule that retrieves is " ordering weight jin goods ", retrieves 3 escape character (ESC)s that are decomposed to form by character string general rule " order weight jin goods " and gangs 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 ";
Gang up in the corresponding code segment general rule process of example at 3 escape character (ESC)s of retrieval; Can't retrieve with escape character (ESC) and gang up the corresponding code segment general rule of example " unit price of inquiry goods "; Just attempt that example inner each " general rule " ganged up in this escape character (ESC) this moment and oppositely replace with " individual example "; Promptly replace with an escape character (ESC) string example and search code segment general rule (can find) as long as there is one in the various array configuration; Here, example " unit price of inquiry goods " ganged up in escape character (ESC) 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 " then distinguished corresponding code segment general rule " total price=unit price * weight " and " Pay (total price) ";
It should be noted that here; Two special speech that in above-mentioned code segment general rule, occur: " unit price " and " total price ", in the process that the code segment general rule is replaced with source code, also need be with these two speech replacements; Be this two speech not occur in " ordering 10 apples " in an original character string example then; Therefore, just need in this case to generate a unduplicated interim character string automatically, 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: the character string general rule is decomposed into a plurality of escape character (ESC)s gangs up the character string that the example back occurs, and here " unit price " and " total price " for example, the information that defines interim character string also is stored in the 3rd mapping relations; Do not repeat to be meant that the variable name in the source code can not repeat, for example: the numerical value of prefix+increase progressively, ABCD_00000000001, when generating source code, character string " definition unit price " is corresponding to " int ABCD_00000000001 ".All places of using " unit price " all replace with ABCD_00000000001 in the code segment general rule.
Again, as described before, can the multilayer cascade between " the individual example " among the present invention and " general rule ", so can need the mapping relations quantity of maintenance through multilayer cascade minimizings.For example go up in the example and can think; " weight ", " unit price ", " total price " all are examples of " numeral "; Therefore; Escape character (ESC) is ganged up example " total price=unit price * weight " and can be used as a character string example, replaces 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 the 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;, same character string need do differentiation when repeatedly occurring; For example go up that " numeral " occurred 3 times in the example, wherein a kind of differentiating method can be with the several bytes of character code extended length (for example 2 byte code forms from Unicode expand to 4 bytes), then in expansion storage side-play amount in analytic process; Change back original coded format again after analyzing end, these all are technological means conventional in the prior art.
Among the present invention, can the character string general rule be decomposed into the chain type sequence that example ganged up in several escape character (ESC)s, 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 the 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, perhaps corresponding certain code segment general rule.The linking relationship of digraph then corresponding code segment general rule optionally such as if, for, switch, for example: " if (* * *) { * * * } else{***} ".Certainly, this digraph sequence and process flow diagram still have essential difference: can generate source code according to this digraph sequence through existing programming tool, and the process flow diagram in the software needs the slip-stick artist manually to write source code.
In view of this; This method can its essence is the compression of information, and this compression process can be carried out repeatedly with character string of digraph boil down to of complicacy; Be equivalent to the nested repeatedly of control statements such as if; Thereby Information Compression to the limit, as far as using the people of " character string general rule ", can be ignored the detail information that wherein comprises fully.
In addition, also mentioned the situation of returning step S1 in the step of the present invention, this is that promptly, database of descriptions lacks information because in database, can not find a character string example at the very start, and report customer requirements interpolation information gets final product; Perhaps in the process that the character string general rule is decomposed, can not find corresponding code segment general rule, thereby cause generating the source code failure; But the latter is the analytic process of a rollback; That is, there are a lot of different explanation in character string after introducing a general rule and a routine mapping relations, and analytic process is to attempt various possibilities gradually; Until a kind of successful or whole failure is arranged; If failure, then also database of descriptions lacks information, and report customer requirements interpolation information gets final product.
Can know based on above-mentioned explanation; The prerequisite that this method is used is to set up 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 the character string general rule is corresponding, the extended pattern mapping relations between the character string general rule.And need not prejudge which character string; Relevant information can constantly be added in operational process; In other words: the user need not guess which character string the user can import; Just when the character string that instrument can't handle occurring, add this character string, and any one user can add the character string that he needs.And because can synchronizing information between the information bank, so everyone can use as long as there is a user to import certain character string.This seems huge workload is to be shared by all users in fact, and the user is many more, and the workload that everyone assigns to is more little.
The present invention can have following application model:
Pattern 1, user are the slip-stick artists, for example, are used to develop the automatic programming instrument.
Under this pattern, existing programming tool capable of using generates source code according to the character string of slip-stick artist's input.And some work is (for example coding and decoding video algorithm etc.) that existing programming tool can't be accomplished automatically in the software development; Then the work of this part is still manually accomplished by the slip-stick artist; Therefore, this pattern is the process that software is accomplished in slip-stick artist and the cooperation of existing programming tool in fact, promptly; Slip-stick artist's design, tool implementation.
For example: the 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 the character string general rule and " insert new node character string " to the chained list character string; Just generate source code, again the character string in the code segment general rule is replaced with p_chain etc. according to the corresponding code segment general rule of general rule.
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 through synchronizing information between the information bank, all slip-stick artists can use these information; Common slip-stick artist is responsible for an input of character string example.As far as common slip-stick artist, he can accomplish software development fully under the situation of not understanding ins and outs, thereby reduces work difficulty.
Pattern 2, user are ordinary consumer, for example, are used for realizing strengthening voice-operated analytical algorithm.
Under this pattern, algorithm capable of using generates source code according to the character string of user's input, and the approach of user inputs character string can be speech recognition.Certainly; Owing to there is not the slip-stick artist to assist, this pattern also is not suitable for complex software, can only splice the function that to be fit to user's request based on " preset function "; Usually be presented as application software; " preset function " here is meant the function that is comprised in the software module that the slip-stick artist writes in advance, and these modules are preset in the product, for example: database, file system or the like.
For example: customer requirements " is play the 10th television channel " (this is a character string example); Retrieve the character string general rule according to algorithm and " play a numeral television channel "; Expand to " numbering that obtains a numeral television channel from database " and " playing television channel " then, replace with source code then according to numbering.
The programming language of the code that generates under this pattern should be selected interpreted languages for use, for example Action Script etc.Database will be kept in the server in high in the clouds simultaneously, so that constantly increase the character string that can support.
For example: the user says " shielding all phones from Shanghai " to mobile phone, and this character string is sent out turns round and stretches out the hand the high in the clouds server of machine company, and server is attempted revising the module of answering the call according to character string.If also do not support at present, then return failure and report to the service engineer.The service engineer has this type instruction to be sent to server after database adds relevant information again, just can generate source code automatically and send it back mobile phone.
The present invention and down load application program are differentiated: the user only gets final product with the demand of natural language statement oneself among the present invention, neither need search application program, also need not download and install.The present invention more is applicable to the modification of small or details.
Pattern 2 can with pattern 1 cooperation, promptly the slip-stick artist accomplishes " preset function " 1 time in pattern, ordinary consumer splices the function of oneself liking pattern 2 times based on " preset function ".
Above-described, be merely preferred embodiment of the present invention, be not in order to limiting scope of the present invention, the above embodiment of the present invention can also be made various variations.Be that every simple, equivalence of doing according to the claims and the description of application of the present invention changes and modification, all fall into the claim protection domain of patent of the present invention.The present invention not detailed description be the 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 store character string example, gang up example and the code segment general rule corresponding with the individual routine corresponding characters of said character string with said character string general rule, wherein, a said character string example is the subclass of character string general rule;
Step S2, the character string of the string matching of a retrieval and peripheral input example in said database obtains this character string example if retrieve, and then execution in step S3 carries out said step S1 otherwise return;
Step S3, in said database retrieval obtain with said step S2 in the character string that obtains a routine corresponding characters gang up example, and this character string example and character string general rule relatively generates first mapping relations of the routine and character string general rule of this character string;
Step S4, in said database retrieval obtain with said step S3 in the corresponding code segment general rule of character string general rule that obtains, and relatively this character string general rule and code segment general rule generate second mapping relations of this character string general rule and code segment general rule;
Step S5 according to said first mapping relations and said second mapping relations, generates source code with the code segment general rule replacement that obtains among the said step S4.
2. source code generation method according to claim 1 is characterized in that, said step S1 also is included in the said database storage and decomposes a plurality of escape character (ESC)s that form by said character string general rule and gang up example.
3. source code generation method according to claim 2 is characterized in that, said method is carried out after being included in said step S4:
Step S6, in said database retrieval obtain with said step S4 in the corresponding a plurality of escape character (ESC)s of character string general rule that obtain gang up example, and generate this character string general rule and the 3rd routine mapping relations ganged up in a plurality of escape character (ESC);
Step S7 gangs up each escape character (ESC) among the said step S6 with example as a character string general rule, and in said database, retrieves the code segment general rule corresponding with each character string general rule; If retrieval obtains the code segment general rule, execution in step S8 then, otherwise; According to said first mapping relations, example ganged up in said escape character (ESC) replace with escape character (ESC) string example, and this escape character (ESC) string is routine as the character string general rule; The retrieval code segment general rule corresponding in said database with this character string general rule; If retrieval obtains the code segment general rule, execution in step S8 then, otherwise return execution in step S1;
Step S8, the code segment general rule corresponding of character string general rule among the more said step S7 and acquisition with it, and generate the 4th mapping relations of this character string general rule and code segment general rule;
Step S9 according to said first mapping relations, said the 3rd mapping relations and said the 4th mapping relations, generates the extended source code with the code segment general rule replacement that obtains among the said step S7;
Step S10 according to said second mapping relations and said the 3rd mapping relations, advances in the code segment general rule that obtains among the said step S4 the extended source code that obtains among a plurality of said step S9 is nested, generates source code.
4. source code generation method according to claim 3 is characterized in that, said step S6 also is included in said the 3rd mapping relations of storage in the said database.
5. according to claim 3 or 4 described source code generation methods, it is characterized in that said step S8 also is included in said the 4th mapping relations of storage in the said database.
6. according to claim 1,2,3 or 4 described source code generation methods, it is characterized in that said step S3 also is included in said first mapping relations of storage in the said database.
7. source code generation method according to claim 6 is characterized in that, said step S4 also is included in the mapping relations of storage said second in the said database.
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 true CN102707948A (en) 2012-10-03
CN102707948B 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)

Cited By (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
CN106250159A (en) * 2016-08-04 2016-12-21 深圳市微我科技有限公司 A kind of hybrid programming method utilizing 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
CN106293725B (en) * 2016-08-04 2021-03-02 深圳市微我科技有限公司 Natural language hybrid programming method based on post-realization
CN115993955A (en) * 2023-03-23 2023-04-21 山东大学 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

Cited By (9)

* 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
CN106250159A (en) * 2016-08-04 2016-12-21 深圳市微我科技有限公司 A kind of hybrid programming method utilizing natural language
CN106250159B (en) * 2016-08-04 2020-12-22 深圳市微我科技有限公司 Mixed programming method using natural language
CN106293725B (en) * 2016-08-04 2021-03-02 深圳市微我科技有限公司 Natural language hybrid programming method based on post-realization
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
US10929277B2 (en) 2019-06-24 2021-02-23 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
CN115993955A (en) * 2023-03-23 2023-04-21 山东大学 Source code generation and test method and system for symmetric cryptographic algorithm

Also Published As

Publication number Publication date
CN102707948B (en) 2014-11-26

Similar Documents

Publication Publication Date Title
CN102707948B (en) Source code generation method
CN110032369A (en) A kind of code automatic generation method, device and medium
EP2924633A1 (en) A system and method for extracting a business rule embedded in an application source code
CN104035754A (en) XML (Extensible Markup Language)-based custom code generation method and generator
CN103810224A (en) Information persistence and query method and device
CN105975446A (en) Method and system for displaying word document content by modules in mobile phone terminal
CN106354817A (en) Method and device for processing log
CN110264361A (en) A kind of data analysis method and device of block chain
CN108701153B (en) Method, system and computer readable storage medium for responding to natural language query
CN110020443B (en) Method, device and equipment for processing translation data and computer readable storage medium
CN115329753B (en) Intelligent data analysis method and system based on natural language processing
CN115495440A (en) Data migration method, device and equipment of heterogeneous database and storage medium
CN115756692A (en) Method for automatically combining and displaying pages based on style attributes and related equipment thereof
CN106599244B (en) General original log cleaning device and method
CN115422275A (en) Data processing method, device, equipment and storage medium
CN109117431A (en) System and method for the source data applied from source to be incorporated into the target data of target application
CN113609822A (en) Cross-service tree data conversion method and related equipment
JP2018081403A (en) Incident management system, incident management method and computer program
JP7293544B2 (en) Q&A system update processing method and device
AU2018313995B2 (en) Systems and methods for providing globalization features in a service management application interface
CN112527753B (en) DNS analysis record lossless compression method and device, electronic equipment and storage medium
CN113821211B (en) Command parsing method and device, storage medium and computer equipment
CN102566536A (en) System flow control device and system flow control method
CN106503118A (en) A kind of data acquisition system and its implementation based on HC TABLE
US20200226685A1 (en) Systems and methods for change in language-based textual analysis

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