CN112463819A - Computing method, device and equipment based on Chinese expression and storage medium - Google Patents
Computing method, device and equipment based on Chinese expression and storage medium Download PDFInfo
- Publication number
- CN112463819A CN112463819A CN202011352143.0A CN202011352143A CN112463819A CN 112463819 A CN112463819 A CN 112463819A CN 202011352143 A CN202011352143 A CN 202011352143A CN 112463819 A CN112463819 A CN 112463819A
- Authority
- CN
- China
- Prior art keywords
- chinese
- expression
- chinese expression
- data
- matching
- 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
Links
- 230000014509 gene expression Effects 0.000 title claims abstract description 135
- 238000004364 calculation method Methods 0.000 title claims abstract description 54
- 238000000034 method Methods 0.000 claims abstract description 34
- 238000012795 verification Methods 0.000 claims abstract description 33
- 238000004458 analytical method Methods 0.000 claims abstract description 22
- 238000004590 computer program Methods 0.000 claims description 12
- 238000010195 expression analysis Methods 0.000 claims description 3
- 238000012423 maintenance Methods 0.000 abstract description 3
- 230000006870 function Effects 0.000 description 26
- 230000008569 process Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 4
- 238000011161 development Methods 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012827 research and development Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2452—Query translation
- G06F16/24522—Translation of natural language queries to structured queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Artificial Intelligence (AREA)
- Mathematical Physics (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Document Processing Apparatus (AREA)
Abstract
The invention relates to a computing method, a device, equipment and a storage medium based on a Chinese expression. The method comprises the following steps: receiving a Chinese expression input by a user; carrying out format compliance verification on the Chinese expression; after the verification is passed, analyzing the Chinese expression by using a recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression; and calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result. In the method, the recursive descent analysis method is adopted to analyze the formula input by the user in real time, when the user changes the service calculation logic or newly adds the service, the purpose can be achieved by only maintaining the formula expression without modifying the code, the maintenance cost is reduced, and the system stability is improved.
Description
Technical Field
The invention relates to the technical field of computer data processing, in particular to a computing method, a computing device, computing equipment and a storage medium based on a Chinese expression.
Background
With the development of intelligent management systems, more and more personnel application systems are put into use. The personnel system inevitably needs to process various formulas, the calculation formulas of data in various personnel application systems are defined in advance by research and development personnel through codes based on the business rules of users, and the users can modify the variable values of the software calculation formulas but cannot modify the calculation rules. In order to express these formulas in various forms in application systems, it is the mainstream practice for developers to provide a known calculation logic formula library based on business status definition, and the formula library is selected by an end user.
At present, when an application system is formally operated on line, a user needs to modify and upgrade an original code program because of the development requirements of an enterprise, certain previously defined calculation formula operation rules are not applicable any more, developers need to modify and upgrade the original code program, the formula modification needs the participation of the developers, the method greatly reduces the real-time performance and flexibility of the application system calculation, and the stability of the system can be greatly reduced due to the rewriting of rule codes.
Disclosure of Invention
In view of the above, the present invention provides a method, an apparatus, a device and a storage medium for computing based on chinese expression to overcome the disadvantages of the prior art.
In order to achieve the purpose, the invention adopts the following technical scheme:
a computing method based on Chinese expressions comprises the following steps:
receiving a Chinese expression input by a user;
carrying out format compliance verification on the Chinese expression;
after the verification is passed, analyzing the Chinese expression by using a recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression;
and calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result.
Optionally, the performing format compliance verification on the chinese expression includes:
analyzing the Chinese expression to obtain an operation symbol and an operation factor of the Chinese expression;
judging whether the operation symbol meets a preset operation symbol standard or not;
if the operation factor meets the preset operation sign standard, judging whether the operation factor is matched with a preset index information set;
and if the operation factors are matched with the preset index information set, performing preset data annotation matching on all the operation factors.
Optionally, the SQL statement includes: character SQL statements and symbol SQL statements;
the analyzing the Chinese expression by using a recursive descent analysis method to generate the SQL statement corresponding to the Chinese expression comprises the following steps:
analyzing the Chinese expression to obtain basic elements of a formula; the basic elements of the formula comprise Chinese character elements and operation symbol elements;
identifying the Chinese character elements and converting the Chinese character elements into corresponding character SQL sentences;
and identifying the operation symbol elements and converting the operation symbol elements into the corresponding symbol SQL sentences.
Optionally, the calculating by using the SQL statement and combining the pre-acquired data to be calculated to obtain a calculation result includes:
creating a temporary table and storing the Chinese character elements into the temporary table;
reading the pre-acquired data to be calculated and storing the data to be calculated into a data field corresponding to the Chinese character element in the temporary table;
and executing the SQL statement to calculate the data of the data field to obtain the calculation result.
Optionally, the attributes of the preset index information set include: index name;
the judging whether the operation factor is matched with a preset index information set or not includes:
matching the operation factor with the index name in the preset index information set;
and if the matched index name is obtained, judging that the operation factor is matched with the preset index information set.
Optionally, the matching of the preset data labels to all the operation factors includes:
matching the data types and the data lengths of all the operation factors;
if the matching is successful, determining the data type of the operation factor;
if the data type is integer, judging that the matching between the operation factors is successful;
if the data type is a real type, judging whether the decimal lengths of all the operation factors are matched;
and if the matching is successful, judging that the matching between the operation factors is successful.
A computing device based on chinese expressions, comprising:
the Chinese expression receiving module is used for receiving a Chinese expression input by a user;
the compliance verification module is used for carrying out format compliance verification on the Chinese expression;
the SQL sentence generation module is used for analyzing the Chinese expression by using a recursive descent analysis method after the verification is passed, and generating an SQL sentence corresponding to the Chinese expression;
and the calculation module is used for calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result.
Optionally, the compliance verification module includes:
the Chinese expression analysis unit is used for analyzing the Chinese expression to obtain an operation symbol and an operation factor of the Chinese expression;
an operator judging unit, configured to judge whether the operation symbol meets a preset operation symbol standard;
the index information set matching unit is used for judging whether the operation factor is matched with a preset index information set or not if the preset operation symbol standard is met;
and the operation factor matching unit is used for matching preset data labels to all the operation factors if the operation factors are matched with the preset index information set.
A computing device based on chinese expressions, comprising:
a processor, and a memory coupled to the processor;
the memory is used for storing a computer program, and the computer program is at least used for executing the calculation method based on the Chinese expression;
the processor is used for calling and executing the computer program in the memory.
A storage medium storing a computer program which, when executed by a processor, implements the steps of the chinese expression-based computation method as described above.
The technical scheme provided by the application can comprise the following beneficial effects:
the application discloses a calculation method based on a Chinese expression, which comprises the following steps: receiving a Chinese expression input by a user; carrying out compliance verification on the Chinese expression; after the verification is passed, analyzing the Chinese expression by using a recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression; and calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result. In the method, the Chinese expression input by the user is received in real time, the Chinese expression is analyzed to generate the SQL sentence corresponding to the Chinese expression, and the data to be calculated is calculated by utilizing the SQL sentence to obtain the final calculation result. The method is simple, flexible and efficient, the calculation of the target data is realized through the natural language definition Chinese formula, the whole process does not need the manual participation of developers, and the labor cost is saved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of a computing method based on Chinese expressions according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for generating an SQL statement corresponding to a Chinese expression according to an embodiment of the present invention;
FIG. 3 is a block diagram of a computing device based on Chinese expressions according to an embodiment of the present invention;
FIG. 4 is a block diagram of a computing device based on Chinese expressions according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the examples given herein without any inventive step, are within the scope of the present invention.
After the personnel system is formally operated on line, the user needs to be changed along with the development of the enterprise, so that the calculation rule of the calculation formula defined in the prior art in the personnel system is not suitable for the user requirement any more, developers are required to modify and upgrade the original code program, and the modification of the formula needs the participation of the developers.
For example: if the user needs to add high-temperature subsidy due to service change, the original developer needs to modify the section of calculation logic through a code level, and if the user uses the method, the user only needs to edit a page of the calculation formula to modify a corresponding formula and add a high-temperature subsidy item.
The high-temperature subsidy needs to be issued under certain conditions, payroll issuing months are 6 months, 7 months and 8 months and are field personnel, research and development personnel are required to define 2 formulas to calculate the payroll respectively at present, the old formula calculates the payroll aiming at the personnel who do not meet the conditions, and the new formula corresponds to the personnel who meet the conditions. After the invention is used, a user can solve the problems by using a formula: the payroll should be issued as basic payroll + bonus + allowance and subsidy + shift-added payroll-absence payroll + (if the staff type is 'outworker' and (month (paydate) ═ 6 or month (paydate) ═ 7 or month (paydate) ═ 8) then the high temperature subsidy is finished, otherwise 0 is finished). The calculation method in the present application will now be described in more detail, in particular as follows.
Fig. 1 is a flowchart of a calculation method based on a chinese expression according to an embodiment of the present invention. Referring to fig. 1, a calculation method based on a chinese expression includes:
step 101: receiving a Chinese expression input by a user. In the application scenario, the user needs to calculate data by using a new formula, and at the moment, the user inputs a Chinese expression at a user application end of a software system corresponding to the application method.
Step 102: and judging whether the format of the Chinese expression meets the compliance verification condition or not. Format compliance verification is permitted here for the chinese expression. After a user inputs a Chinese expression, before analyzing the Chinese expression, compliance verification is carried out on the Chinese expression input by the user, wherein the compliance verification is that the Chinese expression is compared with a preset expression rule to verify whether an operation symbol and an operation element (factor) of the Chinese expression meet the preset rule or not, if the Chinese expression passes the verification, the analysis of the Chinese expression is carried out, and if the Chinese expression does not pass the verification, the user is prompted that the Chinese expression rule does not meet the standard, and the formula is input again.
Step 103: if the compliance verification condition is not met, the Chinese expression is prompted to be not compliant at the moment. The user is prompted to re-enter the expression.
Step 104: if the compliance verification condition is met, analyzing the Chinese expression by using a recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression.
Step 105: and calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result. The data to be calculated needs to be counted by data counting software. When data calculation is carried out in the application, the data in the data statistical software can be directly called.
The method comprises the steps of receiving a Chinese expression required to be used by user input, carrying out format compliance verification on the Chinese expression, analyzing the Chinese expression by using a recursive descent analysis method after the verification is passed, obtaining an SQL sentence corresponding to the Chinese expression, and finally calculating data by using the SQL sentence to obtain a result required by the user. The user can automatically maintain the Chinese formula according to the rules provided by the computing system for computing aiming at different service computing logics, when the user changes the service computing logics or adds new services, the purpose can be achieved by only maintaining the formula expression without modifying codes, the maintenance cost is reduced, and the system stability is improved.
In more detail, step 102: judging whether the format of the Chinese expression meets the compliance verification condition or not, specifically comprising the following steps:
analyzing the Chinese expression to obtain an operation symbol and an operation factor of the Chinese expression;
and judging whether the operation symbol meets a preset operation symbol standard or not. Specifically, whether brackets exist in the operation symbols is judged, if yes, whether the number of the left brackets and the number of the right brackets are equal is judged, and if not, error reporting information is given to inform a user that the number of the brackets is not matched; if the number of the left brackets and the right brackets is equal, judging whether the adding, subtracting, multiplying, dividing and brackets in the operation symbols accord with the four-rule operation rule, if so, judging that the preset operation symbol standard is met, otherwise, prompting a user that the operation symbols do not accord with the operation rule, and informing that the formula definition is wrong.
If the operation factor meets the preset operation sign standard, judging whether the operation factor is matched with a preset index information set; the attributes of the preset index information set comprise: index name; the specific matching process is as follows:
matching the operation factor with the index name in the preset index information set;
and if the matched index name is obtained, judging that the operation factor is matched with the preset index information set.
Further, the preset index information set further includes: index ID, index type, index length, and fractional bit length. After the Chinese expression is matched with the index name, the index ID, the index type, the index length and the decimal place length corresponding to the index name can be obtained in a preset index information set according to the index name. And respectively matching the data type, the data length and other information of the operation factor of the Chinese expression with the index type, the index length, the decimal bit length and the like in a preset index information set. And when the matching is passed, the format of the Chinese expression input by the user meets the preset format standard. And if the matching is not passed, prompting the user that a certain element of the formula cannot be analyzed.
And if the operation factors are matched with the preset index information set, performing preset data annotation matching on all the operation factors. After the format of the chinese expression is verified with the preset index information set, format matching is performed on each element in the chinese expression, for example: b + C needs to be calculated, and whether the data type and the data length between B and C are consistent needs to be verified. Specifically, the method comprises the following steps: matching the data types and the data lengths of all the operation factors; if the matching is successful, determining the data type of the operation factor; if the data type is integer, judging that the matching between the operation factors is successful; if the data type is a real type, judging whether the decimal lengths of all the operation factors are matched; and if the matching is successful, judging that the matching between the operation factors is successful.
More specifically, the present application further introduces details of a process of generating an SQL statement, which are as follows:
fig. 2 is a flowchart of a method for generating an SQL statement corresponding to a chinese expression according to an embodiment of the present invention. Referring to fig. 2, analyzing the chinese expression by using a recursive descent analysis method to generate an SQL statement corresponding to the chinese expression, including:
step 201: analyzing the Chinese expression to obtain basic elements of a formula; the basic elements of the formula comprise Chinese character elements and operation symbol elements;
step 202: judging whether the operation symbol element contains a ' and ' or ' mark;
if the "and", "or" flag is included, go to step 210: converting the operation symbol elements into corresponding symbol SQL sentences;
step 203: if the operation symbol element does not include the "and" or "flag, it is determined whether the operation matching element includes the" like "," in "," > "," "," < ">";
if the "like", "in", ">", "", "<", "mark" is included, step 210 is executed;
step 204: if the arithmetic symbol element does not include "like", "in", ">", "", "<", it is determined whether the arithmetic symbol element includes "+" and "-";
if the mark contains "+" and "-" marks, the step 210 is executed;
step 205: if the operation symbol elements do not contain "+" and "-", whether the operation symbol elements contain "+", "/", and "%" is judged;
if the symbol contains "+", "/", "%" mark, execute step 210;
step 206: if the operation symbol elements do not contain "+", "/", "%", whether the operation accords with the elements to contain ^ is judged;
if the identifier contains the identifier, go to step 210;
step 207: if the operation symbol element does not contain ^ or, judging whether the operation symbol element contains 'not';
if the "not" flag is included, go to step 210;
step 208: if the operation symbol element does not contain 'NOT', judging whether the operation coincidence element contains 'plus' or 'minus';
if the "(", ")" mark is included, step 210 is executed;
step 209: if the operation symbol elements do not contain "(", ")", identifying the Chinese character elements;
step 211: and converting the Chinese character elements into corresponding character SQL sentences.
In the present embodiment, the SQL statement is generated by using a recursive descent analysis method, which is a deterministic top-down analysis method and requires a grammar to be an LL (1) grammar. And compiling a recursive descent analysis function for each non-terminal character, wherein each function name is a corresponding non-terminal character, and the function body is compiled according to the structure and the sequence of the symbol string at the right part of the rule. The subprograms are called recursively, level0, level1, level2, level3, level4, level5, level6 and Primitive functions are respectively constructed to execute own recognition functions, and the recognition functions of the functions are determined according to the content sequence of the grammar.
Specifically, step 202 is implemented by calling a level0 function, where the function is used to identify an "AND" OR "identifier in an expression, AND assemble the formula into" AND "OR" symbols corresponding to SQL;
step 203 is realized by calling a level1 function, wherein the function is used for identifying the identifiers of "like", "in", ">," "," "<" ", and" < "", in the expression, and assembling the formula into a symbol corresponding to the SQL;
step 204 is realized by calling a level2 function, wherein the function is used for identifying "+" and "-" in the expression, and the formula is assembled into a symbol corresponding to SQL;
step 205 is implemented by calling a level3 function, where the function is used to identify "+", "/", "%" in an expression, and assemble a formula into a symbol corresponding to SQL;
step 206 is realized by calling a level4 function, wherein the function is used for identifying 'Lambda' in an expression, and the formula is assembled into a symbol corresponding to SQL;
step 207 is realized by calling a level5 function, wherein the function is used for identifying negation in the expression, and the formula is assembled into a symbol corresponding to SQL;
step 208 is realized by calling a level6 function, wherein the function is used for identifying "(", ") in the expression and assembling the formula into a symbol corresponding to SQL;
step 209 is implemented by calling a primative function, which is used to identify the most basic elements of the expression, such as values, characters, dates, and index names, and functions (including if, then, round-robin, etc.), and assemble the chinese character elements into an SQL syntax that can be identified by the database.
After the SQL sentences which can be identified by the database are assembled, a temporary table is created, and the table column information is Chinese character elements which are put into a stack when the Chinese expression is analyzed; copying the data to be calculated into a temporary table according to a preset registered data screening condition and a name of the data table to be calculated; then executing the assembled SQL statement; and writing the execution result into a result field of the temporary table, wherein the data in the result field is the calculation result required by the user.
Now, for a more clear and simple description of the calculation method in the present application, the above-mentioned method will be described by way of example:
the user A uses the manual application system in the application to carry out payroll settlement, the company specifies that real payroll is supposed to be sent and payroll is paid for personal income, after the user A inputs a Chinese expression of real payroll which is supposed to be sent and payroll which is paid for personal income into the application system, the expression is analyzed after the expression of real payroll which is supposed to be sent and payroll which is paid for personal income is received, the operation symbols in the expression are 'true' and 'minus', and the operation factors include: real payroll, payroll and personal income tax. Firstly, analyzing the operation signs of "-" and "-" to determine that the four operation rules are met. Then, the operation factors ' real payroll ', ' payroll to be sent ' and ' personal income tax ' are respectively matched with the index names in the preset index information set, for example, whether indexes of ' real payroll ' exist in the traversal index names or not is traversed, if yes, the operation factors are matched, all the operation factors are sequentially matched, after the matching is passed, the format matching is carried out on the ' real payroll ', ' payroll to be sent ' and ' personal income tax ', whether the data types of the three operation factors are the same or not is matched, for example, the ' real payroll ' is an integer type, the ' payroll to be sent ' and the ' personal income tax ' are real types (floating point numbers), the condition can lead the result of adding the ' payroll to be sent ' and the personal income tax ' possibly to be floating point numbers, and the data types are not matched with the integer type of the ' real payroll ' at the moment, so that the data types of the three are required to be determined to be the same, and simultaneously, the data length is ensured to be the same. After the matching is passed, the recursive descent analysis method is used for analysis, firstly, the ' real pay ' is judged not to meet the judgment condition in the step 202 and 208, the step 209 is directly executed, the ' real pay ' is identified, the index ID corresponding to the index name is called from the preset index information set according to the index name corresponding to the ' real pay ', the index ID is used as an SQL statement of the ' real pay ', for example, the index ID of the ' real pay ' is A5605, and similarly, the index ID of the ' payable pay ' is A5606, and the index ID of personal income tax ' is A5607. Then, the operator "-" is identified according to step 203, and then the final SQL statement is obtained as follows: a5605 — a5606-a 5607. And then calling data to be calculated, and calculating a final payroll result to be sent according to the SQL statement.
In the embodiment, the terminal user can flexibly compile a complex calculation formula based on Chinese semantics according to business needs, so that the problems that in the prior art, research and development personnel are required to participate in modifying calculation logic, time and labor are consumed, great convenience is brought in the actual production and use process, and on-demand strain is brought are solved.
The embodiment of the invention also provides a computing device based on the Chinese expression. Please see the examples below.
FIG. 3 is a block diagram of a computing device based on Chinese expressions according to an embodiment of the present invention. Referring to fig. 3, a computing device based on chinese expression includes:
a Chinese expression receiving module 301, configured to receive a Chinese expression input by a user;
a compliance verification module 302, configured to perform format compliance verification on the chinese expression;
the SQL statement generating module 303 is configured to analyze the chinese expression by using a recursive descent analysis method after the verification is passed, and generate an SQL statement corresponding to the chinese expression;
and the calculation module 304 is configured to perform calculation by using the SQL statement in combination with the pre-acquired data to be calculated to obtain a calculation result.
In more detail, the compliance verification module 302 includes: the Chinese expression analysis unit is used for analyzing the Chinese expression to obtain an operation symbol and an operation factor of the Chinese expression; an operator judging unit, configured to judge whether the operation symbol meets a preset operation symbol standard; the index information set matching unit is used for judging whether the operation factor is matched with a preset index information set or not if the preset operation symbol standard is met; and the operation factor matching unit is used for matching preset data labels to all the operation factors if the operation factors are matched with the preset index information set.
The SQL statement generation module 303 is specifically configured to: analyzing the Chinese expression to obtain basic elements of a formula; the basic elements of the formula comprise Chinese character elements and operation symbol elements; identifying the Chinese character elements and converting the Chinese character elements into corresponding character SQL sentences; and identifying the operation symbol elements and converting the operation symbol elements into the corresponding symbol SQL sentences.
The calculation module 304 is specifically configured to: creating a temporary table and storing the Chinese character elements into the temporary table; reading the pre-acquired data to be calculated and storing the data to be calculated into a data field corresponding to the Chinese character element in the temporary table; and executing the SQL statement to calculate the data of the data field to obtain the calculation result.
The device converts a mathematical formula which is difficult to be memorized into a formula expression which is convenient to be memorized and is compiled based on Chinese semantics, adopts a formula analysis logic realized by a recursive sinking algorithm, and generates a database SQL script matched with the formula in the analysis process of the formula, so that the analysis is realized according to the Chinese expression input by a user in real time, the calculation of data is further realized, and the practicability of an application system and the data calculation efficiency are greatly improved.
In order to more clearly introduce a hardware system for implementing the embodiment of the present invention, the embodiment of the present invention further provides a computing device based on a chinese expression, corresponding to the combustible gas alarm method provided by the embodiment of the present invention. Please see the examples below.
FIG. 4 is a block diagram of a computing device based on Chinese expressions according to an embodiment of the present invention. Referring to fig. 4, a computing device based on chinese expression includes:
a processor 401 and a memory 402 connected to the processor 401;
the memory 402 is used for storing a computer program at least for executing the above-mentioned calculation method based on the chinese expression;
the processor 401 is used to call and execute the computer program in the memory 402.
On the basis of the above embodiment, the present application further discloses a storage medium storing a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the calculation method based on the chinese expression as described above.
The user can self-maintain the Chinese formula to calculate according to the rules provided by the equipment aiming at different service calculation logics, when the user changes the service calculation logics or adds new services, the purpose can be achieved by only maintaining the formula expression without modifying codes, the maintenance cost is reduced, and the system stability is improved.
It is understood that the same or similar parts in the above embodiments may be mutually referred to, and the same or similar parts in other embodiments may be referred to for the content which is not described in detail in some embodiments.
It should be noted that the terms "first," "second," and the like in the description of the present invention are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Further, in the description of the present invention, the meaning of "a plurality" means at least two unless otherwise specified.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process, and alternate implementations are included within the scope of the preferred embodiment of the present invention in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present invention.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention, and that variations, modifications, substitutions and alterations can be made to the above embodiments by those of ordinary skill in the art within the scope of the present invention.
Claims (10)
1. A computing method based on Chinese expressions is characterized by comprising the following steps:
receiving a Chinese expression input by a user;
carrying out format compliance verification on the Chinese expression;
after the verification is passed, analyzing the Chinese expression by using a recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression;
and calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result.
2. The method of claim 1, wherein the performing format compliance verification on the chinese expression comprises:
analyzing the Chinese expression to obtain an operation symbol and an operation factor of the Chinese expression;
judging whether the operation symbol meets a preset operation symbol standard or not;
if the operation factor meets the preset operation sign standard, judging whether the operation factor is matched with a preset index information set;
and if the operation factors are matched with the preset index information set, performing preset data annotation matching on all the operation factors.
3. The method of claim 1, wherein the SQL statement comprises: character SQL statements and symbol SQL statements;
the analyzing the Chinese expression by using a recursive descent analysis method to generate the SQL statement corresponding to the Chinese expression comprises the following steps:
analyzing the Chinese expression to obtain basic elements of a formula; the basic elements of the formula comprise Chinese character elements and operation symbol elements;
identifying the Chinese character elements and converting the Chinese character elements into corresponding character SQL sentences;
and identifying the operation symbol elements and converting the operation symbol elements into the corresponding symbol SQL sentences.
4. The method according to claim 3, wherein the calculating by using the SQL statement in combination with the pre-acquired data to be calculated to obtain the calculation result comprises:
creating a temporary table and storing the Chinese character elements into the temporary table;
reading the pre-acquired data to be calculated and storing the data to be calculated into a data field corresponding to the Chinese character element in the temporary table;
and executing the SQL statement to calculate the data of the data field to obtain the calculation result.
5. The method according to claim 1, wherein the attributes of the preset index information set include: index name;
the judging whether the operation factor is matched with a preset index information set or not includes:
matching the operation factor with the index name in the preset index information set;
and if the matched index name is obtained, judging that the operation factor is matched with the preset index information set.
6. The method of claim 5, wherein the matching of the predetermined data labels to all of the operation factors comprises:
matching the data types and the data lengths of all the operation factors;
if the matching is successful, determining the data type of the operation factor;
if the data type is integer, judging that the matching between the operation factors is successful;
if the data type is a real type, judging whether the decimal lengths of all the operation factors are matched;
and if the matching is successful, judging that the matching between the operation factors is successful.
7. A computing device based on chinese expressions, comprising:
the Chinese expression receiving module is used for receiving a Chinese expression input by a user;
the compliance verification module is used for carrying out format compliance verification on the Chinese expression;
the SQL sentence generation module is used for analyzing the Chinese expression by using a recursive descent analysis method after the verification is passed, and generating an SQL sentence corresponding to the Chinese expression;
and the calculation module is used for calculating by combining the SQL statement with the pre-acquired data to be calculated to obtain a calculation result.
8. The apparatus of claim 7, wherein the compliance verification module comprises:
the Chinese expression analysis unit is used for analyzing the Chinese expression to obtain an operation symbol and an operation factor of the Chinese expression;
an operator judging unit, configured to judge whether the operation symbol meets a preset operation symbol standard;
the index information set matching unit is used for judging whether the operation factor is matched with a preset index information set or not if the preset operation symbol standard is met;
and the operation factor matching unit is used for matching preset data labels to all the operation factors if the operation factors are matched with the preset index information set.
9. A computing device based on a chinese expression, comprising:
a processor, and a memory coupled to the processor;
the memory is used for storing a computer program at least for executing the Chinese expression-based calculation method according to any one of claims 1 to 6;
the processor is used for calling and executing the computer program in the memory.
10. A storage medium storing a computer program which, when executed by a processor, implements each step in the chinese expression based computation method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011352143.0A CN112463819B (en) | 2020-11-26 | Calculation method, device, equipment and storage medium based on Chinese expression |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011352143.0A CN112463819B (en) | 2020-11-26 | Calculation method, device, equipment and storage medium based on Chinese expression |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112463819A true CN112463819A (en) | 2021-03-09 |
CN112463819B CN112463819B (en) | 2024-10-25 |
Family
ID=
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113177094A (en) * | 2021-04-23 | 2021-07-27 | 远光软件股份有限公司 | Data processing method and device for time sequence database, server and storage medium |
CN113539405A (en) * | 2021-06-24 | 2021-10-22 | 北京天健源达科技股份有限公司 | Processing method of electronic medical record table operation control |
CN114358729A (en) * | 2021-12-30 | 2022-04-15 | 新开普电子股份有限公司 | Method and system for realizing formula recommendation algorithm |
WO2024114655A1 (en) * | 2022-11-29 | 2024-06-06 | 中国银联股份有限公司 | Rule expression matching method and apparatus, and computer-readable storage medium |
Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001142885A (en) * | 1999-11-12 | 2001-05-25 | Hitachi Ltd | Inquiry sql generator by job name designation |
US20080120326A1 (en) * | 2006-11-20 | 2008-05-22 | Oracle International Corporation | Query generation |
CN101788992A (en) * | 2009-05-06 | 2010-07-28 | 厦门东南融通系统工程有限公司 | Method and system for converting query sentence of database |
CN103226488A (en) * | 2013-05-06 | 2013-07-31 | 中国农业银行股份有限公司 | Method and device for efficiency control in formalized code generation |
CN104657440A (en) * | 2015-01-30 | 2015-05-27 | 欧阳江 | Structured query statement generating system and method |
CN104657439A (en) * | 2015-01-30 | 2015-05-27 | 欧阳江 | Generation system and method for structured query sentence used for precise retrieval of natural language |
CN107451153A (en) * | 2016-05-31 | 2017-12-08 | 北京京东尚科信息技术有限公司 | The method and apparatus of export structure query statement |
CN109408526A (en) * | 2018-10-12 | 2019-03-01 | 平安科技(深圳)有限公司 | SQL statement generation method, device, computer equipment and storage medium |
CN111104423A (en) * | 2019-12-18 | 2020-05-05 | 北京百度网讯科技有限公司 | SQL statement generation method and device, electronic equipment and storage medium |
CN111324631A (en) * | 2020-03-19 | 2020-06-23 | 成都海天数联科技有限公司 | Method for automatically generating sql statement by human natural language of query data |
CN111414380A (en) * | 2020-03-20 | 2020-07-14 | 华泰证券股份有限公司 | Chinese database SQ L statement generation method, equipment and storage medium |
CN111581229A (en) * | 2020-03-25 | 2020-08-25 | 平安科技(深圳)有限公司 | SQL statement generation method and device, computer equipment and storage medium |
Patent Citations (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001142885A (en) * | 1999-11-12 | 2001-05-25 | Hitachi Ltd | Inquiry sql generator by job name designation |
US20080120326A1 (en) * | 2006-11-20 | 2008-05-22 | Oracle International Corporation | Query generation |
CN101788992A (en) * | 2009-05-06 | 2010-07-28 | 厦门东南融通系统工程有限公司 | Method and system for converting query sentence of database |
CN103226488A (en) * | 2013-05-06 | 2013-07-31 | 中国农业银行股份有限公司 | Method and device for efficiency control in formalized code generation |
CN104657440A (en) * | 2015-01-30 | 2015-05-27 | 欧阳江 | Structured query statement generating system and method |
CN104657439A (en) * | 2015-01-30 | 2015-05-27 | 欧阳江 | Generation system and method for structured query sentence used for precise retrieval of natural language |
CN107451153A (en) * | 2016-05-31 | 2017-12-08 | 北京京东尚科信息技术有限公司 | The method and apparatus of export structure query statement |
CN109408526A (en) * | 2018-10-12 | 2019-03-01 | 平安科技(深圳)有限公司 | SQL statement generation method, device, computer equipment and storage medium |
CN111104423A (en) * | 2019-12-18 | 2020-05-05 | 北京百度网讯科技有限公司 | SQL statement generation method and device, electronic equipment and storage medium |
CN111324631A (en) * | 2020-03-19 | 2020-06-23 | 成都海天数联科技有限公司 | Method for automatically generating sql statement by human natural language of query data |
CN111414380A (en) * | 2020-03-20 | 2020-07-14 | 华泰证券股份有限公司 | Chinese database SQ L statement generation method, equipment and storage medium |
CN111581229A (en) * | 2020-03-25 | 2020-08-25 | 平安科技(深圳)有限公司 | SQL statement generation method and device, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
李青 等: "一种依需聚合的语义解析图查询模型", 《电子学报》, no. 04, 15 April 2020 (2020-04-15), pages 141 - 149 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113177094A (en) * | 2021-04-23 | 2021-07-27 | 远光软件股份有限公司 | Data processing method and device for time sequence database, server and storage medium |
CN113539405A (en) * | 2021-06-24 | 2021-10-22 | 北京天健源达科技股份有限公司 | Processing method of electronic medical record table operation control |
CN113539405B (en) * | 2021-06-24 | 2024-03-19 | 北京天健源达科技股份有限公司 | Processing method of electronic medical record form operation control |
CN114358729A (en) * | 2021-12-30 | 2022-04-15 | 新开普电子股份有限公司 | Method and system for realizing formula recommendation algorithm |
WO2024114655A1 (en) * | 2022-11-29 | 2024-06-06 | 中国银联股份有限公司 | Rule expression matching method and apparatus, and computer-readable storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109697050B (en) | Demand description model design method facing E-commerce field based on knowledge graph | |
US20050144166A1 (en) | Method for assisting in automated conversion of data and associated metadata | |
CN109446221B (en) | Interactive data exploration method based on semantic analysis | |
US20020170042A1 (en) | Method and apparatus for producing software | |
CN109359277B (en) | Data monitoring method, device and computer storage medium | |
AU2014201573A1 (en) | Improved data integration tool | |
CN113672781A (en) | Data query method and device, electronic equipment and storage medium | |
Nicholson et al. | Automated verification of design patterns: A case study | |
CN116301795B (en) | Development platform for page visual configuration and code writing | |
Fernández et al. | A strategy language for graph rewriting | |
CN113849162A (en) | Code generation method combining model drive and deep neural network | |
US20030200534A1 (en) | Mechanism for reformatting a simple source code statement into a compound source code statement | |
CN114816420A (en) | Data processing method and device | |
McCluskey et al. | A requirements capture method and its use in an air traffic control application | |
CN110928535B (en) | Derived variable deployment method, device, equipment and readable storage medium | |
CN112463819A (en) | Computing method, device and equipment based on Chinese expression and storage medium | |
CN112463819B (en) | Calculation method, device, equipment and storage medium based on Chinese expression | |
CN115145584A (en) | Parser generation method, data processing method, medium, and device | |
US20030009744A1 (en) | Source code line counting system and method | |
CN115687651A (en) | Knowledge graph construction method and device, electronic equipment and storage medium | |
Pecheti et al. | Recursive Descent Parser for Abstract Syntax Tree Visualization of Mathematical Expressions | |
CN117193781B (en) | SIMSCRIPT language-oriented abstract syntax tree construction method and device | |
Buschle | Tool Support for Enterprise Architecture Analysis: with application in cyber security | |
Turner et al. | Visual constraint diagrams: Runtime conformance checking of UML object models versus implementations | |
Chen | A Flop Count Tool with an Example in PLU Factorization |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant |