Data processing method and device and storage medium

The data processing method addresses the limitations of traditional decision engines by decomposing and parsing user expressions into sub-expressions using operand and operator stacks, enhancing user experience and efficiency through intuitive interfaces and flexible natural language processing.

CN119166682AInactive Publication Date: 2024-12-20ZHONGKE YUNGU TECH
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411670915.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2024-12-20
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional decision engines face limitations such as unintuitive user interfaces, high technical dependence, insufficient flexibility, limited customizability, and high maintenance costs, making them inadequate for processing and parsing natural language-driven expressions.

Method used

A data processing method that decomposes user-input expressions into sub-expressions, traverses and parses characters into operand or operator stacks, and generates a target expression using Dijkstra's double stack algorithm to ensure accurate and flexible natural language processing.

Benefits of technology

Enables intuitive user interfaces, reduces technical dependence, enhances flexibility and customizability, and simplifies maintenance by allowing business personnel to easily define and configure calculation formulas, improving user experience and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166682A_ABST
    Figure CN119166682A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and device and a storage medium, and relates to the technical field of computers.The method comprises the steps that a to-be-analyzed expression input by a user is disassembled into a plurality of sub-expressions through a preset rule; traversing characters included in each sub-expression, analyzing the characters into corresponding operands or operators, storing the operands into operand stacks corresponding to the sub-expressions, and storing the operators into operator stacks corresponding to the sub-expressions; respectively taking out a first operator and a first operand from the stack top of the operator stack and the stack top of the operand stack in sequence to generate a first expression in a combined manner, and storing the first expression as an operand into the stack top of the operand stack until the operator stack is empty; determining the operand of the stack top of each operand stack as a second expression corresponding to each sub-expression; and generating a target expression corresponding to the to-be-analyzed expression according to all the second expressions. According to the scheme, the expression processing based on natural language driving can be flexibly and accurately realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data processing method, device and storage medium. Background Art

[0002] Traditional decision engines are a set of software tools designed to assist enterprises in automated decision making. They analyze data and provide decision recommendations through built-in rules and algorithms. Although these engines can provide effective decision support in some cases, they also have some common limitations. These limitations include unintuitive user interfaces, which make it difficult for non-technical users to operate; high technical dependence, requiring professional knowledge to configure and maintain; insufficient flexibility, making it difficult to quickly adapt to changes in business needs; limited customizability, making it difficult for users to adjust decision logic according to specific needs; insufficient real-time performance, which may not provide immediate decision feedback; high maintenance and update costs, and requiring a lot of time and resources to adjust as business logic changes. With the advancement of technology and the evolution of enterprise needs, traditional decision engines lack flexible, efficient, easy-to-use and cross-domain decision support solutions, and cannot flexibly process and parse natural language-driven expressions. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a data processing method, device and storage medium to solve the technical problem in the prior art that traditional decision engines cannot flexibly process and parse natural language driven expressions.

[0004] In order to achieve the above-mentioned purpose, the first aspect of the present application provides a data processing method, the method comprising: Get the expression to be parsed entered by the user; Decompose the expression to be parsed into multiple sub-expressions according to preset rules; Traverse the characters included in each sub-expression and parse each character in each sub-expression into the corresponding operand or operator; For each character in each subexpression, store the character parsed into an operand in the operand stack corresponding to the subexpression, and store the character parsed into an operator in the operator stack corresponding to the subexpression; For each sub-expression, take out a first operator from the top of the operator stack corresponding to the sub-expression, and take out multiple first operands from the top of the operand stack corresponding to the sub-expression; For each sub-expression, generate a first expression according to the first operator and the first operands taken out each time, and store the first expression as an operand at the top of the operand stack corresponding to the sub-expression until the operator stack is empty; Determine the top operand of the operand stack corresponding to each sub-expression as the second expression corresponding to each sub-expression; A target expression corresponding to the expression to be parsed is generated according to all the second expressions, where the target expression is a composite expression encapsulated by the second expressions corresponding to each sub-expression.

[0005] In an example of the present application, for each character in each sub-expression, storing the character parsed into an operand in an operand stack corresponding to the sub-expression, and storing the character parsed into an operator in an operator stack corresponding to the sub-expression includes: for each character in each sub-expression, determining the first priority of the character parsed into the operator and the second priority of the operator corresponding to the current top of the stack of operands corresponding to the sub-expression; for each character in each sub-expression, storing the character parsed into the operator in the operator stack corresponding to the sub-expression according to the first priority and the second priority of the character parsed into the operator.

[0006] In the example of the present application, for each character in each sub-expression, according to the first priority and the second priority of the character parsed into the operator, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression, including: when the first priority of the character parsed into the operator is greater than or equal to the second priority, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression.

[0007] In an example of the present application, for each character in each sub-expression, according to the first priority and the second priority of the character parsed into the operator, storing the character parsed into the operator in the operator stack corresponding to the sub-expression includes: for each character in each sub-expression, when the first priority of the character parsed into the operator is less than the second priority, taking out a second operator from the current top of the operator stack corresponding to the sub-expression, and taking out multiple second operands from the current top of the operand stack corresponding to the sub-expression in sequence; for each sub-expression, generating a third expression according to the currently taken out second operator and the multiple second operands, storing the third expression as an operand in the top of the operand stack corresponding to the sub-expression, and storing the character parsed into the operator in the top of the operator stack corresponding to the sub-expression, until all characters in the sub-expression are parsed.

[0008] In an example of the present application, decomposing the expression to be parsed into multiple sub-expressions according to a preset rule includes: determining a first preset character among the characters included in the expression to be parsed; and decomposing the expression to be parsed into multiple sub-expressions according to the first preset character.

[0009] In an example of the present application, the character includes a second preset character, the second preset character includes a first sub-character and a second sub-character that appear in pairs, and for each character in each sub-expression, the character parsed into an operand is stored in an operand stack corresponding to the sub-expression, and the character parsed into an operator is stored in an operator stack corresponding to the sub-expression, including: for each character in each sub-expression, when the character is a first sub-character, determining the second sub-character corresponding to the first sub-character in the sub-expression; for each sub-expression, determining all characters between the first sub-character and the second sub-character as a fourth expression; for each sub-expression, sequentially storing the characters parsed into operands or operators in the fourth expression corresponding to the sub-expression into the corresponding operand stack or operator stack, and then storing the remaining characters parsed into operands or operators in the sub-expression into the corresponding operand stack or operator stack.

[0010] In the example of the present application, obtaining the expression to be parsed input by the user includes: upon receiving a creation instruction from the user for the expression to be parsed, displaying an editing interface for the expression to be parsed according to the creation instruction; determining the preset data items selected by the user through the editing interface; and encapsulating the preset data items to generate the expression to be parsed.

[0011] In the example of the present application, the preset data item is at least one of a preset function, a preset operator, a preset variable and a preset enumeration value, and determining the preset data item selected by the user through the editing interface includes: when the user enters a third preset character through the editing interface, controlling the editing interface to display a function list, so that the user selects the preset function included in the function list through the editing interface; when the user enters a fourth preset character through the editing interface, controlling the editing interface to display a variable list, so that the user selects the preset variable included in the variable list through the editing interface; when the user enters a fifth preset character through the editing interface, controlling the editing interface to display an enumeration value list, so that the user selects the preset enumeration value included in the enumeration value list through the editing interface.

[0012] A second aspect of the present application provides a data processing device, including: a memory configured to store instructions; The processor is configured to call the instructions from the memory and implement the above-mentioned data processing method when executing the instructions.

[0013] A third aspect of the present application provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the above-mentioned data processing method.

[0014] Through the above technical scheme, the expression to be parsed input by the user is obtained; the expression to be parsed is decomposed into multiple sub-expressions according to preset rules; the characters included in each sub-expression are traversed, and each character in each sub-expression is parsed into a corresponding operand or operator; for each character in each sub-expression, the character parsed into the operand is stored in the operand stack corresponding to the sub-expression, and the character parsed into the operator is stored in the operator stack corresponding to the sub-expression; for each sub-expression, a first operator is taken out from the top of the operator stack corresponding to the sub-expression in turn, and multiple first operands are taken out from the top of the operand stack corresponding to the sub-expression in turn; for each sub-expression, a first expression is generated according to the first operator and multiple first operands taken out each time, and the first expression is stored as an operand in the top of the operand stack corresponding to the sub-expression until the operator stack is empty; the operand at the top of the operand stack corresponding to each sub-expression is determined as the second expression corresponding to each sub-expression; and a target expression corresponding to the expression to be parsed is generated according to all the second expressions. The characters of the parsed expression are stored and retrieved through the operand stack and operator stack, so that the natural language or expressions composed by the user can be parsed into expressions recognizable by the computer program, and the processing of expressions driven by natural language can be flexibly and accurately realized.

[0015] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings: Figure 1 A schematic diagram of a data processing method according to an embodiment of the present application is shown; Figure 2 A schematic diagram of a data processing method according to a specific embodiment of the present application is shown; Figure 3 The structure block diagram of a data processing device according to an embodiment of the present application is schematically shown; Figure 4 The schematic diagram shows a structure of a computer device according to an embodiment of the present application. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0018] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), such directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0019] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0020] Figure 1 The following schematically shows a flow chart of a data processing method according to an embodiment of the present application. Figure 1 As shown, an embodiment of the present application provides a data processing method, which may include the following steps.

[0021] S102, obtaining the expression to be parsed input by the user.

[0022] It can be understood that the expression to be analyzed is a combination of numbers, operators, number grouping symbols, free variables and bound variables in a meaningful arrangement method that can obtain values. The bound variables have been assigned values ​​in the expression, while the free variables can be assigned values ​​outside the expression. The expression to be analyzed can be composed of operators and operands. The operands can be constants, variables or their combination. The operator can be an operation, such as "+" (addition), "-" (subtraction), "×" (multiplication), "÷" (division), etc.

[0023] S104, decomposing the expression to be parsed into multiple sub-expressions according to preset rules.

[0024] It can be understood that the expression to be parsed can be a compound expression composed of multiple sub-expressions. The preset rules refer to the disassembly rules for the expression to be parsed that are preset by the technician. For example, the expression to be parsed can support the use of curly braces '{}' to encapsulate a group of expressions to form a compound expression block, which enables the entire expression set to be operated as an independent unit. This encapsulation not only improves the modularity of the expression, but also allows the user to directly assign the calculation result of the expression block to a variable, which is convenient for subsequent data processing. More importantly, the expression block itself can be passed as a parameter to the function, so that the function can directly use these expression blocks for dynamic calculation when called, enhancing the flexibility and extensibility of the program.

[0025] S106, traverse the characters included in each sub-expression, and parse each character in each sub-expression into a corresponding operand or operator.

[0026] It can be understood that by traversing the characters included in each sub-expression, the characters of each sub-expression can be parsed one by one, and during the parsing process, it is confirmed whether the characters are operands or operators. In addition, during the parsing process, the natural language or symbols input by the user can be converted into a format that can be recognized and executed by the computer program, that is, converted into operands or operators. For example, the natural language "increase the asset limit value" in the sub-expression can be converted into "assetLimitValue" that can be recognized by the computer program.

[0027] S108, for each character in each sub-expression, storing the character parsed into an operand into an operand stack corresponding to the sub-expression, and storing the character parsed into an operator into an operator stack corresponding to the sub-expression.

[0028] It can be understood that the operand stack refers to a temporary storage space for storing operands, and the operator stack refers to a temporary storage space for storing operators. Specifically, the operand stack and the operator stack both write data to or extract data from the stack according to the first-in, last-out rule. Each sub-expression has a corresponding operand stack and operator stack, so that the sub-expressions can be processed independently.

[0029] S110, for each sub-expression, sequentially take out a first operator from the top of the operator stack corresponding to the sub-expression, and sequentially take out multiple first operands from the top of the operand stack corresponding to the sub-expression.

[0030] S112, for each sub-expression, generate a first expression according to the first operator and multiple first operands taken out each time, and store the first expression as an operand at the top of the operand stack corresponding to the sub-expression until the operator stack is empty.

[0031] It can be understood that after each character in the sub-expression is stored in the corresponding operand stack and operator stack, the operands can be taken out from the operand stack in sequence, and the operators can be taken out from the operator stack in sequence. Specifically, one first operator can be taken out from the top of the operator stack each time, and multiple first operands can be taken out from the top of the operand stack each time. Specifically, two first operands can be used. The taken out first operator and the two first operands are grouped into an expression, namely the first expression. The first expression can be a binary operation expression. Furthermore, the first expression can be stored in the top of the operand stack in the form of an operand, and the above operation can be repeated until all the operators of the operator stack are taken out, that is, the operator stack is empty.

[0032] S114, determining the top operand of the operand stack corresponding to each sub-expression as the second expression corresponding to each sub-expression.

[0033] S116, generating a target expression corresponding to the expression to be parsed based on all the second expressions, the target expression being a composite expression encapsulated by the second expressions corresponding to each sub-expression.

[0034] It can be understood that when the operator stack of the sub-expression is empty, the operand at the top of the operand stack becomes an expression including multiple operands and operators, i.e., the second expression. When each sub-expression included in the expression to be parsed is converted into a corresponding second expression, all the second expressions can be encapsulated into a composite expression, i.e., the target expression corresponding to the expression to be parsed.

[0035] Through the above technical solution, the characters of the parsed expression are stored and extracted through the operand stack and the operator stack, so that the natural language or conforming expression input by the user can be parsed into an expression recognizable by the computer program, and the processing of natural language-driven expressions can be flexibly and accurately realized, which solves the shortcomings of traditional decision engines in terms of user-friendliness, flexibility, customizability, and inconvenient maintenance.

[0036] With respect to S102, in the example of the present application, obtaining the expression to be parsed input by the user includes: upon receiving a creation instruction from the user for the expression to be parsed, displaying an editing interface for the expression to be parsed according to the creation instruction; determining the preset data items selected by the user through the editing interface; and encapsulating the preset data items to generate the expression to be parsed.

[0037] It can be understood that the user input expression to be parsed can be user-defined input, but this method is often prone to input errors and is inefficient. Therefore, a user-friendly editing interface can be introduced, which can be a visual and interactive editing interface. The editing interface can add an auxiliary function of intelligent input to provide users with preset data items that can be selected, so that users can easily configure and define calculation formulas. Specifically, the user can enter a creation instruction for the expression to be parsed, and an editing interface is displayed according to this creation instruction. The user can select the preset data item in the editing interface. The preset data item refers to the ‌numbers, ‌operators, digit grouping symbols, functions, ‌free variables, and ‌constrained variables pre-set by technicians in the resource library. Furthermore, the editing interface responds to the preset data items selected by the user, and can encapsulate the preset data items to generate the expression to be parsed. In this way, the process of business personnel defining expressions is greatly simplified, the complexity of configuration is effectively reduced, and the dependence on professional technicians is reduced.

[0038] In the example of the present application, the preset data item is at least one of a preset function, a preset operator, a preset variable and a preset enumeration value, and determining the preset data item selected by the user through the editing interface includes: when the user enters a third preset character through the editing interface, controlling the editing interface to display a function list, so that the user selects the preset function included in the function list through the editing interface; when the user enters a fourth preset character through the editing interface, controlling the editing interface to display a variable list, so that the user selects the preset variable included in the variable list through the editing interface; when the user enters a fifth preset character through the editing interface, controlling the editing interface to display an enumeration value list, so that the user selects the preset enumeration value included in the enumeration value list through the editing interface.

[0039] Specifically, the third preset character refers to a custom character that can call a function list through the editing interface. The fourth preset character refers to a custom character that can call a function variable list through the editing interface. The fifth preset character refers to a custom character that can call an enumeration value list through the editing interface. For example, when the user enters the "@" symbol, the system will automatically display the list of variables available in the current context for the user to choose, and display the path and name of the variable in Chinese. After entering the "#" symbol, the system will automatically list the function list of all supported preset functions for the user to choose, and the function name is also displayed in Chinese. When the "$" symbol is entered, the system will display all enumeration values ​​in the input dictionary for the user to choose, and these enumeration values ​​are also presented in Chinese. In this way, based on the intelligent input auxiliary function, the user can quickly access the variable list, function list and enumeration value list through specific symbols during the input process, which greatly improves the input speed and reduces errors. It should be noted that when the third preset character, the fourth preset character, and the fifth preset character exist in the expression to be parsed, these characters are not stored in the operator stack as operators, but are stored in the operand stack together with the subsequent operands.

[0040] With respect to S104, in an example of the present application, decomposing the expression to be parsed into multiple sub-expressions according to a preset rule includes: determining a first preset character among the characters included in the expression to be parsed; and decomposing the expression to be parsed into multiple sub-expressions according to the first preset character.

[0041] It can be understood that the first preset character refers to a custom character that can combine multiple sub-expressions into a composite expression. For example, it can be represented by ";". When the expression to be parsed is decomposed, if ";" is recognized, the character strings before and after ";" can be decomposed into sub-expressions respectively.

[0042] With respect to S108, in the example of the present application, for each character in each sub-expression, storing the character parsed into an operand into an operand stack corresponding to the sub-expression, and storing the character parsed into an operator into an operator stack corresponding to the sub-expression includes: for each character in each sub-expression, determining the first priority of the character parsed into the operator and the second priority of the operator corresponding to the current top of the operator stack corresponding to the sub-expression; for each character in each sub-expression, storing the character parsed into the operator into the operator stack corresponding to the sub-expression according to the first priority and the second priority of the character parsed into the operator.

[0043] It can be understood that the first priority and the second priority are relative. The first priority refers to the priority of the currently parsed character as an operator, and the second priority refers to the priority of the operator at the current top of the operator stack. It can be understood that in the actual mathematical operation process, there are different calculation priorities of different operators, for example, the priority of multiplication is greater than that of addition and subtraction. Then, when the expression to be parsed is parsed into an expression recognizable by a computer program, the original operation priority order must also be maintained during the parsing process. Specifically, in the process of storing the characters of the sub-expression in the operand stack and the operator stack, the priority between the operators needs to be considered. When traversing and parsing the characters in the sub-expression, if the currently parsed character is an operator, then it is necessary to compare the operator with the first priority and the second priority of the operator of the current operator stack, and use the comparison result of the priorities of the two operators as a basis to store the characters of the operator in the operator stack. In this way, the sub-expression can be accurately parsed.

[0044] In the example of the present application, for each character in each sub-expression, according to the first priority and the second priority of the character parsed into the operator, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression, including: when the first priority of the character parsed into the operator is greater than or equal to the second priority, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression.

[0045] Specifically, when the first priority of the character parsed into the operator is greater than or equal to the second priority, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression. Then, at this time, the top of the operator stack will be replaced by the character parsed into the operator. Then, when it is necessary to extract the operator of the operator stack, the operator at the top of the stack will be extracted first, and the character parsed into the operator will be extracted before the operator at the top of the original operator stack, that is, the character parsed into the operator will be operated first to maintain its operation order in the expression to be parsed.

[0046] In an example of the present application, for each character in each sub-expression, according to the first priority and the second priority of the character parsed into the operator, storing the character parsed into the operator in the operator stack corresponding to the sub-expression includes: for each character in each sub-expression, when the first priority of the character parsed into the operator is less than the second priority, taking out a second operator from the current top of the operator stack corresponding to the sub-expression, and taking out multiple second operands from the current top of the operand stack corresponding to the sub-expression in sequence; for each sub-expression, generating a third expression according to the currently taken out second operator and the multiple second operands, storing the third expression as an operand in the top of the operand stack corresponding to the sub-expression, and storing the character parsed into the operator in the top of the operator stack corresponding to the sub-expression, until all characters in the sub-expression are parsed.

[0047] It can be understood that, when the first priority of the character parsed into the operator is less than the second priority, a second operator can be taken out from the current top of the operator stack, and two second operands can be taken out from the top of the operand stack, and the taken out second operator and the second operator are combined into an expression, that is, the third expression. The third expression is stored in the top of the operand stack as an operand. At this time, the operator at the top of the operator stack has been taken out and combined into the third expression, and then the character parsed into the operator is stored in the operator stack corresponding to the sub-expression until all the characters in the sub-expression are parsed. Since the first priority of the character currently parsed into the operator is less than the operator at the current top of the operator stack, the operator at the current top of the operator stack should be operated first, and it is combined with the two operands of the operand stack to form a third expression, so that it can obtain a priority operation order to maintain its operation order in the expression to be parsed.

[0048] In an example of the present application, the character includes a second preset character, the second preset character includes a first sub-character and a second sub-character that appear in pairs, and for each character in each sub-expression, the character parsed into an operand is stored in an operand stack corresponding to the sub-expression, and the character parsed into an operator is stored in an operator stack corresponding to the sub-expression, including: for each character in each sub-expression, when the character is a first sub-character, determining the second sub-character corresponding to the first sub-character in the sub-expression; for each sub-expression, determining all characters between the first sub-character and the second sub-character as a fourth expression; for each sub-expression, sequentially storing the characters parsed into operands or operators in the fourth expression corresponding to the sub-expression into the corresponding operand stack or operator stack, and then storing the remaining characters parsed into operands or operators in the sub-expression into the corresponding operand stack or operator stack.

[0049] It can be understood that the second preset character refers to a custom character that can define the order of operations of some characters in the expression to be parsed. The second preset character includes a first sub-character and a second sub-character that appear in pairs. It can be understood that all characters between the first sub-character and the second sub-character can be combined into a single expression, that is, the fourth expression. The order of operations of the fourth expression is prioritized in this expression. The first sub-character and the second sub-character can be represented by "()". Then, in the parsing process, for each character in each sub-expression, when the character is the first sub-character, the second sub-character corresponding to the first sub-character in the sub-expression is determined, and all characters between the first sub-character and the second sub-character are determined as the fourth expression. When pushing characters into the operator stack and the operand stack, the characters parsed into operands or operators in the fourth expression are preferentially pushed and stored in the corresponding operand stack or operator stack. For the characters of the fourth expression, the priority between operators also needs to be considered, and the priority of the operator at the top of the operator stack and the priority of the character currently parsed into the operator are compared. When the priority of the character parsed into the operator is greater than or equal to the priority of the operator at the top of the operator stack, the character parsed into the operator is stored in the operator stack. For each character in each fourth expression, when the priority of the character parsed into the operator is less than the priority of the operator at the top of the operator stack, an operator is taken out from the current top of the operator stack, and two operands are taken out from the current top of the operand stack in turn, and an expression is combined and stored in the top of the operand stack until all characters in the fourth expression are parsed. Further, the remaining characters parsed into operands or operators in the sub-expression are stored in the corresponding operand stack or operator stack based on the aforementioned priority comparison logic. The above scheme follows the standard priority rules of operators, allowing users to accurately control the calculation process of complex expressions, ensuring that operations are performed in the expected logical order, thereby improving the accuracy of calculations and the readability of expressions.

[0050] In one embodiment, the operators in the expression to be parsed include four arithmetic operators, logical operators, and user-defined preset functions. The symbols of the four arithmetic operations supported are shown in Table 1 below, the symbols of the logical operations supported are shown in Table 2 below, and the user-defined preset functions supported are shown in Table 3 below.

[0051] Table 1 Four operators

[0052] Table 2 Logical operators

[0053] Table 3 Preset functions

[0054] Figure 2 The following schematically shows a flow chart of a data processing method according to a specific embodiment of the present application. Figure 2 As shown, an embodiment of the present application provides a data processing method, which may include the following steps.

[0055] Step 1: The user inputs the expression to be parsed composed of natural language through the editing interface to convert the expression to be parsed. The system can intelligently convert the natural language or symbolic expression input by the user into a format that can be recognized and executed by the computer program, for example: Table 4 Results of user input and program recognition

[0056] Step 2: The system can recognize and decompose the converted compound expression into multiple independent sub-expressions using the semicolon ";" as a separator.

[0057] Step 3: Use Dijkstra's double stack algorithm to parse each subexpression one by one.

[0058] Step 4: Initialize the operand stack and operator stack.

[0059] Step 5, traverse the input string of the expression to be parsed, and parse the operands and operators character by character.

[0060] Step 6, when an operand is encountered, it is pushed into the operand stack.

[0061] Step 7, when encountering an operator, first check whether the priority of the operator is higher than the operator at the top of the stack. If so, push the current operator into the operator stack. Otherwise, pop the top operator from the operator stack, pop two operands from the operand stack in turn, create a binary operation expression, and push this expression into the operand stack, repeating the above process until the operator stack is empty.

[0062] Step 8: If the end of the expression to be parsed has not been reached at this time, continue parsing the characters of the expression and repeat the operations from step 5 to step 7. If the end of the expression to be parsed has been reached and there are operators remaining in the operator stack, pop the top operator from the operator stack and pop two operands from the operand stack in turn to create a binary operation expression and push this expression into the operand stack. Repeat the above process until the operator stack is empty.

[0063] Step 9, return the expression at the top of the operand stack at this time, that is, the parsed expression.

[0064] Step 10, execute the parsed expression.

[0065] Through the above technical solution, a user-friendly visual interface is provided, which enables business personnel to easily define and configure calculation formulas, significantly reducing the complexity of technical operations. Through the intelligent input auxiliary function, users can quickly access variables, functions and dictionary value lists through specific symbols during the input process, which greatly improves the input speed and reduces errors. Compared with traditional decision engines, the intelligent automatic completion prompts, flexible and accurate natural language-driven expression processing, high customizability and easy maintenance and expansion design significantly improve the user experience, operation efficiency, calculation accuracy and long-term cost-effectiveness, while enhancing the adaptability and cross-domain application capabilities of the decision engine. In addition, the expression processing capability is strengthened, the parsing of natural language and symbolic expressions is supported, and the flexibility and customization of the decision engine are enhanced. The above solution can assist enterprises in automated decision making through an intuitive visual interface, giving business personnel the ability to configure complex calculation expressions, significantly improving the efficiency and accuracy of the decision process. It effectively solves the shortcomings of traditional decision engines in terms of user friendliness, flexibility, customizability, and inconvenient maintenance.

[0066] Figure 1 FIG. 1 is a flow chart of a data processing method in one embodiment. It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0067] Figure 3 The structure block diagram of a data processing device according to an embodiment of the present application is schematically shown. Figure 3 As shown, an embodiment of the present application provides a data processing device, which may include: Memory 310, configured to store instructions; The processor 320 is configured to call instructions from the memory 310 and implement the above-mentioned data processing method when executing the instructions.

[0068] Specifically, in the embodiment of the present application, the processor 320 may be configured to: Get the expression to be parsed entered by the user; Decompose the expression to be parsed into multiple sub-expressions according to preset rules; Traverse the characters included in each sub-expression and parse each character in each sub-expression into the corresponding operand or operator; For each character in each subexpression, store the character parsed into an operand in the operand stack corresponding to the subexpression, and store the character parsed into an operator in the operator stack corresponding to the subexpression; For each sub-expression, take out a first operator from the top of the operator stack corresponding to the sub-expression, and take out multiple first operands from the top of the operand stack corresponding to the sub-expression; For each sub-expression, generate a first expression according to the first operator and the first operands taken out each time, and store the first expression as an operand at the top of the operand stack corresponding to the sub-expression until the operator stack is empty; Determine the top operand of the operand stack corresponding to each sub-expression as the second expression corresponding to each sub-expression; A target expression corresponding to the expression to be parsed is generated according to all the second expressions, where the target expression is a composite expression encapsulated by the second expressions corresponding to each sub-expression.

[0069] In the example of the present application, the processor 320 may also be configured to: For each character in each sub-expression, determine the first priority of the character parsed into the operator and the second priority of the operator corresponding to the current top of the operand stack corresponding to the sub-expression; for each character in each sub-expression, store the character parsed into the operator in the operator stack corresponding to the sub-expression according to the first priority and second priority of the character parsed into the operator.

[0070] In the example of the present application, the processor 320 may also be configured to: When the first priority of the character parsed into the operator is greater than or equal to the second priority, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression.

[0071] In the example of the present application, the processor 320 may also be configured to: For each character in each sub-expression, when the first priority of the character parsed into the operator is less than the second priority, take out a second operator from the current top of the operator stack corresponding to the sub-expression, and take out multiple second operands from the current top of the operand stack corresponding to the sub-expression in sequence; for each sub-expression, generate a third expression according to the currently taken out second operator and the multiple second operands, and store the third expression as an operand at the top of the operand stack corresponding to the sub-expression, and store the character parsed into the operator at the top of the operator stack corresponding to the sub-expression, until all characters in the sub-expression are parsed.

[0072] In the example of the present application, the processor 320 may also be configured to: Determine a first preset character among the characters included in the expression to be parsed; and decompose the expression to be parsed into a plurality of sub-expressions according to the first preset character.

[0073] In an example of the present application, the character includes a second preset character, and the second preset character includes a first sub-character and a second sub-character that appear in pairs. The processor 320 may also be configured as follows: For each character in each sub-expression, when the character is the first sub-character, determine the second sub-character corresponding to the first sub-character in the sub-expression; for each sub-expression, determine all characters between the first sub-character and the second sub-character as the fourth expression; for each sub-expression, sequentially store the characters parsed into operands or operators in the fourth expression corresponding to the sub-expression into the corresponding operand stack or operator stack, and then store the remaining characters parsed into operands or operators in the sub-expression into the corresponding operand stack or operator stack.

[0074] In the example of the present application, the processor 320 may also be configured to: When receiving a creation instruction from the user for an expression to be parsed, an editing interface for the expression to be parsed is displayed according to the creation instruction; preset data items selected by the user are determined through the editing interface; and the preset data items are packaged to generate the expression to be parsed.

[0075] In the example of the present application, the preset data item is at least one of a preset function, a preset operator, a preset variable, and a preset enumeration value. The processor 320 may also be configured to: When the user inputs the third preset character through the editing interface, the editing interface is controlled to display a function list, so that the user can select the preset function included in the function list through the editing interface; when the user inputs the fourth preset character through the editing interface, the editing interface is controlled to display a variable list, so that the user can select the preset variable included in the variable list through the editing interface; when the user inputs the fifth preset character through the editing interface, the editing interface is controlled to display an enumeration value list, so that the user can select the preset enumeration value included in the enumeration value list through the editing interface.

[0076] The data processing device provided in the embodiment of the present application may include an application server PC and a database system. Among them, the application server PC is responsible for carrying the client and server systems of the decision engine. The database system is used to store and manage the calculation formulas configured by the user. The client system provides an interactive user interface that enables users to easily configure and define calculation formulas. The server system is responsible for parsing and executing the calculation formulas. The database system serves as a backend support to ensure the safe storage and rapid retrieval of the calculation formula data saved by the user.

[0077] An embodiment of the present application also provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the above-mentioned data processing method.

[0078] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor A01, a network interface A02, a memory (not shown in the figure) and a database (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non-volatile storage medium A04. The non-volatile storage medium A04 stores an operating system B01, a computer program B02 and a database (not shown in the figure). The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non-volatile storage medium A04. The database of the computer device is used to store data of the data processing method. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program B02 is executed by the processor A01, a data processing method is implemented.

[0079] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0080] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0081] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0082] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0084] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0085] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0086] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0087] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0088] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A data processing method, characterized in that: The method comprises: Get the expression to be parsed entered by the user; Decomposing the expression to be parsed into multiple sub-expressions according to preset rules; Traverse the characters included in each sub-expression and parse each character in each sub-expression into the corresponding operand or operator; For each character in each sub-expression, storing the character parsed into an operand in an operand stack corresponding to the sub-expression, and storing the character parsed into an operator in an operator stack corresponding to the sub-expression; For each sub-expression, sequentially take out a first operator from the top of an operator stack corresponding to the sub-expression, and sequentially take out a plurality of first operands from the top of an operand stack corresponding to the sub-expression; For each sub-expression, generate a first expression according to the first operator and the plurality of first operands taken out each time, and store the first expression as an operand at the top of an operand stack corresponding to the sub-expression until the operator stack is empty; Determine the top operand of the operand stack corresponding to each sub-expression as the second expression corresponding to each sub-expression; A target expression corresponding to the expression to be parsed is generated according to all the second expressions, wherein the target expression is a composite expression encapsulated by the second expressions corresponding to each of the sub-expressions.

2. The data processing method according to claim 1, characterized in that: The step of storing, for each character in each sub-expression, the characters parsed into operands into an operand stack corresponding to the sub-expression, and storing the characters parsed into operators into an operator stack corresponding to the sub-expression comprises: For each character in each sub-expression, determine the first priority of the character parsed into the operator and the second priority of the operator corresponding to the current top of the stack of operands corresponding to the sub-expression; For each character in each sub-expression, according to the first priority and the second priority of the character parsed into the operator, the character parsed into the operator is stored in the operator stack corresponding to the sub-expression.

3. The data processing method according to claim 2, characterized in that: The step of storing, for each character in each sub-expression, the characters parsed into the operators into an operator stack corresponding to the sub-expression according to the first priority and the second priority of the characters parsed into the operators comprises: In a case where the first priority of the character parsed into the operator is greater than or equal to the second priority, the character parsed into the operator is stored in an operator stack corresponding to the sub-expression.

4. The data processing method according to claim 2, characterized in that: The step of storing, for each character in each sub-expression, the characters parsed into the operators into an operator stack corresponding to the sub-expression according to the first priority and the second priority of the characters parsed into the operators comprises: For each character in each sub-expression, if the first priority of the character parsed into the operator is less than the second priority, take out a second operator from the current top of the operator stack corresponding to the sub-expression, and take out multiple second operands from the current top of the operand stack corresponding to the sub-expression in sequence; For each sub-expression, a third expression is generated based on the second operator currently taken out and multiple second operands, and the third expression is stored as an operand at the top of the operand stack corresponding to the sub-expression, and the characters parsed into operators are stored at the top of the operator stack corresponding to the sub-expression, until all characters in the sub-expression are parsed.

5. The data processing method according to claim 1, characterized in that: Decomposing the expression to be parsed into multiple sub-expressions according to preset rules comprises: Determine a first preset character among the characters included in the expression to be parsed; The expression to be parsed is decomposed into a plurality of sub-expressions according to the first preset characters.

6. The data processing method according to claim 1, characterized in that: The character includes a second preset character, the second preset character includes a first sub-character and a second sub-character that appear in pairs, and for each character in each sub-expression, storing the character parsed into an operand in an operand stack corresponding to the sub-expression, and storing the character parsed into an operator in an operator stack corresponding to the sub-expression comprises: For each character in each sub-expression, if the character is the first sub-character, determine a second sub-character corresponding to the first sub-character in the sub-expression; For each sub-expression, determining all characters between the first sub-character and the second sub-character as a fourth expression; For each sub-expression, the characters parsed into operands or operators in the fourth expression corresponding to the sub-expression are stored in the corresponding operand stack or operator stack in turn, and then the remaining characters parsed into operands or operators in the sub-expression are stored in the corresponding operand stack or operator stack.

7. The data processing method according to claim 1, characterized in that: The expression to be parsed obtained from the user input includes: When receiving a creation instruction from a user for an expression to be parsed, displaying an editing interface for the expression to be parsed according to the creation instruction; Determining the preset data item selected by the user through the editing interface; The preset data items are encapsulated to generate the expression to be parsed.

8. The data processing method according to claim 7, characterized in that: The preset data item is at least one of a preset function, a preset operator, a preset variable, and a preset enumeration value, and determining the preset data item selected by the user through the editing interface includes: In a case where the user inputs a third preset character through the editing interface, controlling the editing interface to display a function list, so that the user selects the preset function included in the function list through the editing interface; In a case where the user inputs a fourth preset character through the editing interface, controlling the editing interface to display a variable list, so that the user selects the preset variable included in the variable list through the editing interface; In a case where the user inputs a fifth preset character through the editing interface, the editing interface is controlled to display an enumeration value list, so that the user selects the preset enumeration value included in the enumeration value list through the editing interface.

9. A data processing device, characterized in that: include: a memory configured to store instructions; A processor is configured to call the instructions from the memory and implement the data processing method according to any one of claims 1 to 8 when executing the instructions.

10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions, which are used to enable a machine to execute the data processing method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data processing method and device, equipment and storage medium

    CN114462381A

  • VB6-based expression processing method

    CN115310424A

  • Compilation method of expression in normalized statement, readable storage medium and compiler

    CN115841145A

  • Character string expression processing method and device, equipment and storage medium

    CN117610555A

  • Method for specifying and parsing expressions

    US20040015473A1