Calculation method, device, equipment and storage medium based on Chinese expression
Through the calculation method based on Chinese expressions, users can define and modify calculation formulas by themselves, generate SQL statements for data calculation, solve the problem of frequent modification of calculation formula operation rules in the existing technology, and improve the flexibility and stability of the system. Maintenance costs are reduced.
Patent Information
- Application Number
- CN202011352143.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-26
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2040-11-26
AI Technical Summary
In the process of enterprise development, the calculation formula operation rules of the existing personnel system need to be frequently modified, which leads to the involvement of developers, reduces the real-time and flexibility of the system, and may affect the stability of the system.
Using a calculation method based on Chinese expressions, by receiving Chinese expressions input by users, it performs format compliance verification and recursive descent analysis, generates SQL statements, and performs calculations based on the data to be calculated to achieve dynamic updating of formulas and avoid Direct intervention by developers.
It enables users to define and modify calculation formulas by themselves, improves the flexibility and real-time performance of the system, reduces maintenance costs, enhances system stability, and reduces dependence on developers.
Smart Images

Figure CN112463819B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer data processing, and in particular to a calculation method, device, equipment and storage medium based on Chinese expressions. Background Art
[0002] With the development of intelligent management systems, more and more personnel application systems are put into use. Personnel systems inevitably need to deal with a variety of formulas. The calculation formulas for data in various personnel application systems are pre-defined by R&D personnel through code based on the user's business rules. Users can modify the variable values of the software calculation formula but cannot modify its calculation rules. In order to express these various formulas in the application system, the mainstream approach is for R&D personnel to provide a library of known calculation logic formulas defined based on the business status for end users to choose from.
[0003] At present, when the application system is officially launched, some previously defined calculation formula operation rules will no longer apply due to the needs of the enterprise's own development. This requires developers to modify and upgrade the original code program. The modification of the formula requires the participation of developers. This method greatly reduces the real-time and flexibility of the application system calculation, and the rewriting of the rule code may also greatly reduce the stability of the system. Summary of the invention
[0004] In view of this, the purpose of the present invention is to overcome the deficiencies of the prior art and provide a calculation method, device, equipment and storage medium based on Chinese expressions.
[0005] To achieve the above objectives, the present invention adopts the following technical solutions:
[0006] A calculation method based on Chinese expressions, comprising:
[0007] Receive Chinese expressions input by users;
[0008] Verifying the format compliance of the Chinese expression;
[0009] After verification, the Chinese expression is parsed using the recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression;
[0010] The SQL statement is used in combination with the pre-acquired data to be calculated to perform calculations to obtain calculation results.
[0011] Optionally, the format compliance verification of the Chinese expression includes:
[0012] Analyze the Chinese expression to obtain operation symbols and operation factors of the Chinese expression;
[0013] Determining whether the operation symbol meets the preset operation symbol standard;
[0014] If the preset operation symbol standard is met, determining whether the operation factor matches the preset indicator information set;
[0015] If it matches the preset indicator information set, all the operation factors are matched with the preset data annotations.
[0016] Optionally, the SQL statement includes: a character SQL statement and a symbol SQL statement;
[0017] The method of parsing the Chinese expression using the recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression includes:
[0018] Analyze the Chinese expression to obtain basic elements of the formula; the basic elements of the formula include Chinese character elements and operation symbol elements;
[0019] Identify the Chinese character elements and convert them into corresponding character SQL statements;
[0020] The operator symbol elements are identified and converted into corresponding symbolic SQL statements.
[0021] Optionally, the using the SQL statement in combination with pre-acquired data to be calculated to perform calculations to obtain calculation results includes:
[0022] Creating a temporary table, and storing the Chinese character elements in the temporary table;
[0023] Read the pre-acquired data to be calculated and store it in the data field corresponding to the Chinese character element in the temporary table;
[0024] The SQL statement is executed to calculate the data in the data field to obtain the calculation result.
[0025] Optionally, the attributes of the preset indicator information set include: indicator name;
[0026] The determining whether the operation factor matches the preset indicator information set includes:
[0027] Matching the operation factor with the indicator name in the preset indicator information set;
[0028] If a matching indicator name is obtained, it is determined that the operation factor matches the preset indicator information set.
[0029] Optionally, matching preset data annotations for all the operation factors includes:
[0030] Matching the data types and data lengths of all the operation factors;
[0031] If the match is successful, the data type of the operation factor is determined;
[0032] If the data type is an integer, determining that the operation factors are matched successfully;
[0033] If the data type is real, determine whether the decimal lengths of all the operation factors match;
[0034] If the match is successful, it is determined that the operation factors are matched successfully.
[0035] A computing device based on Chinese expressions, comprising:
[0036] A Chinese expression receiving module is used to receive Chinese expressions input by users;
[0037] A compliance verification module, used for verifying the format compliance of the Chinese expression;
[0038] An SQL statement generation module is used to parse the Chinese expression using a recursive descent analysis method after verification, and generate an SQL statement corresponding to the Chinese expression;
[0039] The calculation module is used to use the SQL statement in combination with the pre-acquired data to be calculated to perform calculations and obtain calculation results.
[0040] Optionally, the compliance verification module includes:
[0041] A Chinese expression analysis unit, used to analyze the Chinese expression to obtain operation symbols and operation factors of the Chinese expression;
[0042] An operator judgment unit, used to judge whether the operation symbol meets the preset operation symbol standard;
[0043] An indicator information set matching unit, used to determine whether the operation factor matches the preset indicator information set if the preset operation symbol standard is met;
[0044] The operation factor matching unit is used to match the preset data annotations of all the operation factors if they match the preset indicator information set.
[0045] A computing device based on Chinese expressions, comprising:
[0046] A processor, and a memory connected to the processor;
[0047] The memory is used to store a computer program, and the computer program is at least used to execute the above-mentioned calculation method based on Chinese expressions;
[0048] The processor is used to call and execute the computer program in the memory.
[0049] A storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements the various steps in the calculation method based on Chinese expressions as described above.
[0050] The technical solution provided by this application may have the following beneficial effects:
[0051] The present application discloses a calculation method based on Chinese expressions, including: receiving Chinese expressions input by users; verifying the compliance of Chinese expressions; after the verification, parsing the Chinese expressions using the recursive descent analysis method, generating SQL statements corresponding to the Chinese expressions; and calculating using the SQL statements in combination with pre-acquired data to be calculated to obtain calculation results. In the above method, the Chinese expressions input by users are received in real time, the Chinese expressions are parsed, and SQL statements corresponding to the Chinese expressions are generated, and the data to be calculated are calculated using the SQL statements to obtain the final calculation results. This method is simple, flexible, and efficient, and realizes the calculation of target data by defining Chinese formulas in natural language. The entire process does not require manual participation of developers, thus saving labor costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 is a flow chart of a calculation method based on Chinese expressions provided by an embodiment of the present invention;
[0054] Figure 2 It is a flow chart of a method for generating SQL statements corresponding to Chinese expressions provided by an embodiment of the present invention;
[0055] Figure 3 is a module diagram of a computing device based on Chinese expressions provided by an embodiment of the present invention;
[0056] Figure 4 It is a structural diagram of a computing device based on Chinese expressions provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0057] To make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described in detail below. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other implementation methods obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0058] After the personnel system is officially launched, the user needs will continue to change as the company's own development needs change, resulting in the calculation formula operation rules previously defined in the personnel system no longer being applicable to user needs. This requires developers to modify and upgrade the original code program, and the modification of the formula requires the participation of developers.
[0059] For example: payable wages = basic wage + bonus + allowances and subsidies + overtime wages - absence wages. If the user needs to add high temperature subsidies to the payable wages due to business changes, the current technical means require the original developer to modify this calculation logic at the code level. If the present invention is used, the user only needs to modify the corresponding formula on the calculation formula editing page and add the high temperature subsidy item.
[0060] For example, the high temperature subsidy mentioned above needs to meet certain conditions before it can be issued. The salary payment months are June, July, and August and they are field staff. Currently, R&D personnel need to define two formulas to calculate separately. The old formula calculates the payable salary for personnel who do not meet the conditions, and the new formula corresponds to personnel who meet the conditions. After using the present invention, the user can solve it with one formula: payable salary = basic salary + bonus + allowance and subsidy + overtime salary - absence salary + (if the personnel type = 'field staff' and (month (pay date) = 6 or month (pay date) = 7 or month (pay date) = 8) then the high temperature subsidy is 0 otherwise). The calculation method in this application is now introduced in more detail, as follows.
[0061] Figure 1 is a flow chart of a calculation method based on Chinese expressions provided by an embodiment of the present invention. Figure 1 , a calculation method based on Chinese expressions, comprising:
[0062] Step 101: receiving a Chinese expression input by a user. The application scenario in this application is that a user needs to use a new formula to calculate data. At this time, the user inputs a Chinese expression on the user application side of the software system corresponding to the method of this application.
[0063] Step 102: Determine whether the format of the Chinese expression meets the compliance verification conditions. Here, the Chinese expression may be format-compliant verified. After the user enters a Chinese expression, before analyzing the Chinese expression, the Chinese expression entered by the user is first verified for compliance. The compliance verification here is to compare the Chinese expression with the pre-set expression rules to verify whether the operation symbols and operation elements (factors) of the Chinese expression meet the preset rules. If the verification is passed, the Chinese expression is analyzed. If the verification is not passed, the user is prompted that the Chinese expression rules do not meet the standards and please re-enter the formula.
[0064] Step 103: If the compliance verification condition is not met, a prompt is displayed that the Chinese expression is not compliant, and the user is prompted to re-enter the expression.
[0065] Step 104: If the compliance verification condition is met, the Chinese expression is parsed using a recursive descent analysis method to generate a SQL statement corresponding to the Chinese expression.
[0066] Step 105: Calculate using the SQL statement in combination with the pre-acquired data to be calculated to obtain a calculation result. The data to be calculated here needs to be counted using data statistics software. When performing data calculation in this application, the data in the data statistics software can be directly retrieved.
[0067] In the above method, the Chinese expression required by the user input is received, and the format compliance of the Chinese expression is verified. When the verification is passed, the Chinese expression is parsed using the recursive descent analysis method to obtain the SQL statement corresponding to the Chinese expression, and finally the SQL statement is used to calculate the data to obtain the result required by the user. Users can maintain Chinese formulas for calculations according to the rules provided by the calculation system for different business calculation logics. When users change the business calculation logic or add new businesses, they can achieve their goals by maintaining the formula expression without modifying the code, which reduces maintenance costs and improves system stability.
[0068] In more detail, step 102: determining whether the format of the Chinese expression meets the compliance verification condition, specifically includes:
[0069] Analyze the Chinese expression to obtain operation symbols and operation factors of the Chinese expression;
[0070] Determine whether the operation symbol meets the preset operation symbol standard. Specifically, determine whether there are brackets in the operation symbol. If there are brackets, determine whether the number of left and right brackets is equal. If the number of left and right brackets is not equal, give an error message to inform the user that the number of brackets does not match; if the number of left and right brackets is equal, determine whether the addition, subtraction, multiplication, division and brackets in the operation symbol meet the four arithmetic operation rules. If they meet the four arithmetic operation rules, it is determined that the preset operation symbol standard is met. Otherwise, the user is prompted that it does not meet the operation rules and is informed of the formula definition error.
[0071] If the preset operation symbol standard is met, it is determined whether the operation factor matches the preset indicator information set; the attributes of the preset indicator information set include: indicator name; the specific matching process is as follows:
[0072] Matching the operation factor with the indicator name in the preset indicator information set;
[0073] If a matching indicator name is obtained, it is determined that the operation factor matches the preset indicator information set.
[0074] Furthermore, the attributes of the preset indicator information set also include: indicator ID, indicator type, indicator length and decimal length. After matching the indicator name in the Chinese expression, the indicator ID, indicator type, indicator length and decimal length corresponding to the indicator name can be obtained in the preset indicator information set according to the indicator name. Among them, the data type, data length and other information of the operation factors of the Chinese expression must be matched with the indicator type, indicator length and decimal length in the preset indicator information set respectively. When the matches are all passed, it means that the format of the Chinese expression entered by the user meets the preset format standard. If the match fails, the user is prompted that a certain element of the formula cannot be parsed.
[0075] If it matches the preset indicator information set, all the operation factors are matched with the preset data annotations. After the Chinese expression is format-verified with the preset indicator information set, the formats of the elements in the Chinese expression must also be matched. For example, if B+C needs to be calculated, it is necessary to verify whether the data type and data length between B and C are consistent. Specifically: match the data type and data length of all the operation factors; if the match is successful, determine the data type of the operation factor; if the data type is integer, determine whether the operation factors are matched successfully; if the data type is real, determine whether the decimal lengths of all the operation factors match; if the match is successful, determine whether the operation factors are matched successfully.
[0076] In more detail, the present application also provides a detailed introduction to the process of generating SQL statements, as follows:
[0077] Figure 2 is a flow chart of a method for generating SQL statements corresponding to Chinese expressions provided by an embodiment of the present invention. Figure 2 , using the recursive descent analysis method to parse the Chinese expression and generate an SQL statement corresponding to the Chinese expression, including:
[0078] Step 201: Analyze the Chinese expression to obtain basic elements of the formula; the basic elements of the formula include Chinese character elements and operation symbol elements;
[0079] Step 202: Determine whether the operator element contains an "and" or "or" mark;
[0080] If the "and" or "or" mark is included, step 210 is executed: the operation symbol element is converted into a corresponding symbolic SQL statement;
[0081] Step 203: If the operator symbol element does not contain the "and" or "or" mark, determine whether the operator element contains the "like", "in", ">", ">=", "=", "<", "<=" marks;
[0082] If the identifiers "like", "in", ">", ">=", "=", "<", "<=" are included, execute step 210;
[0083] Step 204: If the operator symbol element does not contain "like", "in", ">", ">=", "=", "<", "<=", determine whether the operator element contains "+", "-";
[0084] If it contains "+" or "-", execute step 210;
[0085] Step 205: If the operator symbol element does not contain "+" or "-", determine whether the operator element contains "*", " / ", or "%";
[0086] If it contains "*", " / ", "%", execute step 210;
[0087] Step 206: If the operator symbol element does not contain "*", " / ", or "%", determine whether the operator element contains "^";
[0088] If the “^” mark is included, execute step 210;
[0089] Step 207: If the operator symbol element does not contain “^”, determine whether the operator combination element contains “not”;
[0090] If the "non" mark is included, execute step 210;
[0091] Step 208: If the operator symbol element does not contain "not", determine whether the operator element contains "(", ")";
[0092] If the "(", ")" mark is included, execute step 210;
[0093] Step 209: If the operation symbol element does not contain “(”, “)”, identify the Chinese character element;
[0094] Step 211: Convert Chinese character elements into corresponding character SQL statements.
[0095] In this embodiment, SQL statements are generated by using a recursive descent analysis method. The recursive descent analysis method is a top-down analysis method that requires the grammar to be an LL(1) grammar. A recursive descent analysis function is compiled for each non-terminal symbol. Each function name is a corresponding non-terminal symbol, and the function body is written according to the structure and order of the symbol string on the right side of the rule. The subroutines recursively call each other, and construct level0, level1, level2, level3, level4, level5, level6, and primitive functions to perform their own recognition functions. The recognition function of the function is determined according to the content order of the grammar.
[0096] Specifically, step 202 is implemented by calling a level 0 function, which is used to identify the "and" and "or" symbols in the expression and assemble the formula into the "AND" and "OR" symbols corresponding to SQL;
[0097] Step 203 is implemented by calling the level1 function, which is used to identify the "like", "in", ">", ">="", "=", "<", "<="" symbols in the expression and assemble the formula into the corresponding SQL symbols;
[0098] Step 204 is implemented by calling the level 2 function, which is used to identify the "+" and "-" in the expression and assemble the formula into the corresponding SQL symbols;
[0099] Step 205 is implemented by calling the level3 function, which is used to recognize "*", " / ", "%" in the expression and assemble the formula into the corresponding SQL symbols;
[0100] Step 206 is implemented by calling the level 4 function, which is used to identify the "^" in the expression and assemble the formula into the symbol corresponding to SQL;
[0101] Step 207 is implemented by calling the level5 function, which is used to identify the "non" in the expression and assemble the formula into the corresponding SQL symbol;
[0102] Step 208 is implemented by calling the level6 function, which is used to recognize "(", ")" in the expression and assemble the formula into the corresponding SQL symbols;
[0103] Step 209 is implemented by calling the Primitive function, which is used to identify the most basic elements of the expression, such as numerical values, characters, dates, index names, functions (including if, then, rounding, etc.), and assemble the Chinese character elements into SQL syntax recognizable by the database.
[0104] After being assembled into a SQL statement recognizable by the database, a temporary table is created, and the table column information is the Chinese character elements placed in the stack when the Chinese expression is analyzed; the data to be calculated is copied to the temporary table according to the pre-set registered data screening conditions and the name of the data table to be calculated; then the assembled SQL statement is executed; the execution result is written into the result field of the temporary table, and the data in the result field is the calculation result required by the user.
[0105] In order to introduce the calculation method in this application more clearly and simply, the above method is introduced by example:
[0106] User A uses the personnel application system in this application to settle wages. The company stipulates that actual wages = payable wages - personal income tax. When user A enters the Chinese expression "actual wages = payable wages - personal income tax" into this application system, after receiving the expression "actual wages = payable wages - personal income tax", the expression is analyzed, and the operation symbols in the expression are "=" and "-", and the operation factors include: "actual wages", "payable wages" and "personal income tax". First, the operation symbols "=" and "-" are analyzed, and after analysis, it is determined that they meet the four arithmetic operations. Then match the operation factors "actual wages", "payable wages" and "personal income tax" with the indicator names in the preset indicator information set respectively. For example, check whether there is an indicator of "actual wages" in the indicator names. If so, it means that this operation factor is matched. Match all the operation factors in turn. After the match is passed, match the formats of "actual wages", "payable wages" and "personal income tax" to see if the data types of these three operation factors are the same. For example, "actual wages" is an integer type, "payable wages" and "personal income tax" are real types (floating point numbers). In this case, the result of adding "payable wages" and "personal income tax" may be a floating point number. At this time, the data type does not match the integer type of "actual wages". Therefore, it is necessary to ensure that the data types of the three are the same, and the data lengths must be the same. When all the above matches are passed, the recursive descent analysis method is used for analysis. First, it is determined that the "actual wages" do not meet the judgment conditions in steps 202-208, and step 209 is directly executed to identify the "actual wages". According to the indicator name corresponding to the "actual wages", the indicator ID corresponding to the indicator name is retrieved in the preset indicator information set, and the indicator ID is used as the SQL statement of "actual wages". For example, the indicator ID of "actual wages" is A5605. Similarly, the indicator ID of "payable wages" is A5606, and the indicator ID of "personal income tax" is A5607. Then, according to step 203, the operator "=" is identified, and according to step 204, the operator "-" is identified, and then the final SQL statement is obtained: A5605=A5606-A5607. Then, the data to be calculated is retrieved, and the final result of the payable wages is calculated according to the SQL statement.
[0107] In the above embodiment, terminal users can flexibly write complex calculation formulas based on Chinese semantics according to business needs, which solves the problem in the prior art that R&D personnel need to participate in modifying the calculation logic, which is time-consuming and labor-intensive. It brings great convenience in actual production and use, and can adapt to needs.
[0108] Corresponding to a calculation method based on Chinese expressions provided in an embodiment of the present invention, an embodiment of the present invention also provides a calculation device based on Chinese expressions. Please refer to the following embodiments.
[0109] Figure 3 1 is a block diagram of a computing device based on Chinese expressions provided by an embodiment of the present invention. Figure 3 , a computing device based on Chinese expressions, comprising:
[0110] The Chinese expression receiving module 301 is used to receive a Chinese expression input by a user;
[0111] A compliance verification module 302, used for verifying the format compliance of the Chinese expression;
[0112] SQL statement generation module 303, used to parse the Chinese expression using recursive descent analysis method after verification, and generate SQL statement corresponding to the Chinese expression;
[0113] The calculation module 304 is used to perform calculations using the SQL statement in combination with the pre-acquired data to be calculated to obtain calculation results.
[0114] In more detail, the compliance verification module 302 includes: a Chinese expression analysis unit, used to analyze the Chinese expression to obtain the operation symbol and operation factor of the Chinese expression; an operator judgment unit, used to judge whether the operation symbol meets the preset operation symbol standard; an indicator information set matching unit, used to judge whether the operation factor matches the preset indicator information set if the preset operation symbol standard is met; an operation factor matching unit, used to match the preset data annotations of all the operation factors if they match the preset indicator information set.
[0115] The SQL statement generation module 303 is specifically used for: analyzing the Chinese expression to obtain basic elements of the formula; the basic elements of the formula include Chinese character elements and operation symbol elements; identifying the Chinese character elements and converting them into corresponding character SQL statements; identifying the operation symbol elements and converting them into corresponding symbol SQL statements.
[0116] The calculation module 304 is specifically used to: create a temporary table and store the Chinese character elements in the temporary table; read the pre-acquired data to be calculated and store them in the data field corresponding to the Chinese character elements in the temporary table; execute the SQL statement to calculate the data in the data field to obtain the calculation result.
[0117] The above-mentioned device converts mathematical formulas that are difficult to remember into Chinese logic expressions that are easy to remember based on Chinese semantics, uses a recursive sinking algorithm to implement the formula parsing logic, and generates a matching database SQL script during the formula parsing process, thereby realizing parsing according to the Chinese expression input by the user in real time, and then realizing data calculation, which greatly improves the practicality of the application system and the data calculation efficiency.
[0118] In order to more clearly introduce the hardware system for implementing the embodiment of the present invention, corresponding to a flammable gas alarm method provided by the embodiment of the present invention, the embodiment of the present invention also provides a computing device based on Chinese expressions. Please refer to the following embodiments.
[0119] Figure 4 FIG. 1 is a structural diagram of a computing device based on Chinese expressions provided by an embodiment of the present invention. Figure 4 , a computing device based on Chinese expressions, comprising:
[0120] A processor 401, and a memory 402 connected to the processor 401;
[0121] The memory 402 is used to store a computer program, and the computer program is at least used to execute the above-mentioned calculation method based on Chinese expressions;
[0122] The processor 401 is used to call and execute the computer program in the memory 402 .
[0123] On the basis of the above-mentioned embodiments, the present application further discloses a storage medium, which stores a computer program. When the computer program is executed by a processor, each step of the calculation method based on Chinese expressions as described above is implemented.
[0124] Users can maintain Chinese formulas for calculations according to the rules provided by the above devices for different business calculation logics. When users change the business calculation logic or add new businesses, they can achieve their goals by maintaining the formula expressions without modifying the code, which reduces maintenance costs and improves system stability.
[0125] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0126] It should be noted that, in the description of the present invention, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0127] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention belong.
[0128] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0129] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0130] In addition, each functional unit in each embodiment of the present invention may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0131] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0132] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0133] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A calculation method based on Chinese expressions, characterized in that: include: Receive Chinese expressions input by users; Verifying the format compliance of the Chinese expression; After verification, the Chinese expression is parsed using the recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression; Utilize the SQL statement in combination with the pre-acquired data to be calculated to perform calculations and obtain calculation results; The SQL statements include: character SQL statements and symbol SQL statements; The method of parsing the Chinese expression using the recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression includes: Analyze the Chinese expression to obtain basic elements of the formula; the basic elements of the formula include Chinese character elements and operation symbol elements; Identify the Chinese character elements and convert them into corresponding character SQL statements; Identify the operator symbol element and convert it into the corresponding symbolic SQL statement; The format compliance verification of the Chinese expression includes: Analyze the Chinese expression to obtain operation symbols and operation factors of the Chinese expression; Determine whether the operation symbol meets the preset operation symbol standard; If the preset operation symbol standard is met, determining whether the operation factor matches the preset indicator information set; If it matches the preset indicator information set, all the operation factors are matched with the preset data annotations; The matching of preset data annotations for all the operation factors includes: Matching the data types and data lengths of all the operation factors; If the match is successful, the data type of the operation factor is determined; If the data type is an integer, determining that the operation factors are matched successfully; If the data type is real, determine whether the decimal lengths of all the operation factors match; If the match is successful, it is determined that the operation factors are matched successfully.
2. The method according to claim 1, characterized in that: The step of using the SQL statement in combination with the pre-acquired data to be calculated to perform calculations to obtain calculation results includes: Creating a temporary table, and storing the Chinese character elements in the temporary table; Read the pre-acquired data to be calculated and store it in the data field corresponding to the Chinese character element in the temporary table; The SQL statement is executed to calculate the data in the data field to obtain the calculation result.
3. The method according to claim 1, characterized in that The attributes of the preset indicator information set include: indicator name; The determining whether the operation factor matches the preset indicator information set includes: Matching the operation factor with the indicator name in the preset indicator information set; If a matching indicator name is obtained, it is determined that the operation factor matches the preset indicator information set.
4. A computing device based on Chinese expressions, characterized in that: include: A Chinese expression receiving module is used to receive Chinese expressions input by users; A compliance verification module, used for verifying the format compliance of the Chinese expression; An SQL statement generation module is used to parse the Chinese expression using a recursive descent analysis method after verification, and generate an SQL statement corresponding to the Chinese expression; The SQL statements include: character SQL statements and symbol SQL statements; The method of parsing the Chinese expression using the recursive descent analysis method to generate an SQL statement corresponding to the Chinese expression includes: Analyze the Chinese expression to obtain basic elements of the formula; the basic elements of the formula include Chinese character elements and operation symbol elements; Identify the Chinese character elements and convert them into corresponding character SQL statements; Identify the operator symbol element and convert it into the corresponding symbolic SQL statement; A calculation module, used to perform calculations using the SQL statement in combination with pre-acquired data to be calculated to obtain calculation results; The compliance verification module comprises: A Chinese expression analysis unit, used to analyze the Chinese expression to obtain operation symbols and operation factors of the Chinese expression; An operator judgment unit, used to judge whether the operation symbol meets the preset operation symbol standard; An indicator information set matching unit, used to determine whether the operation factor matches the preset indicator information set if the preset operation symbol standard is met; An operation factor matching unit, used for matching all the operation factors with preset data annotations if they match the preset indicator information set; The matching of preset data annotations for all the operation factors includes: Matching the data types and data lengths of all the operation factors; If the match is successful, the data type of the operation factor is determined; If the data type is an integer, determining that the operation factors are matched successfully; If the data type is real, determine whether the decimal lengths of all the operation factors match; If the match is successful, it is determined that the operation factors are matched successfully.
5. A computing device based on Chinese expressions, characterized in that: include: A processor, and a memory connected to the processor; The memory is used to store a computer program, and the computer program is used to at least execute the calculation method based on Chinese expressions according to any one of claims 1 to 3; The processor is used to call and execute the computer program in the memory.
6. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, each step of the calculation method based on Chinese expressions as described in any one of claims 1 to 3 is implemented.
