Data processing method of rule engine, electronic equipment and storage medium

By parsing business rules into target expressions through a parser and a runner, running them and determining the execution results, the problem of low efficiency and high difficulty caused by the reliance on large amounts of open-source components in rule engines is solved, and lightweight and efficient business rule processing is achieved.

CN118963868AInactive Publication Date: 2024-11-15NINGBO PORT INFORMATION COMM CO LTD

Patent Information

Application Number
CN202411425770.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-14
Publication Date
2024-11-15
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing rule engines rely on open-source program components with large data volumes, resulting in low efficiency, high difficulty in use, and difficulty in supporting integration.

Method used

The parser reads business rules from the business rule base and parses them into target expressions; the runner uses the input data to run the target expressions, determines the execution result, and determines subsequent business rules based on the execution result. This process of parsing and execution does not rely on open-source program components with large amounts of data.

Benefits of technology

It reduces the difficulty of using the rules engine and the amount of data required, improves efficiency and system integration, and enables lightweight and visual editing of business rules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963868A_ABST
    Figure CN118963868A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method of a rule engine, electronic equipment and a storage medium, and relates to the technical field of data processing. The method comprises the following steps: reading a business rule from a business rule base through an analyzer, and analyzing the business rule into a target expression; running the target expression by using the input data through a running device, and determining an execution result of the input data; according to an execution result, determining a subsequently executed business rule, and continuing to read the corresponding business rule from the business rule base for analysis and execution; therefore, the problems of low use efficiency and high use difficulty caused by the fact that a rule engine needs to depend on an open source program component with a large data volume and is difficult to support integration in the prior art are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of data processing technology, and in particular to a data processing method, electronic device and storage medium for a rule engine. Background Art

[0002] The rule engine can solve the problems caused by hard-coding business rules, such as difficulty in maintenance, difficulty in coping with changes, and the need to modify code and restart services when business rules change. The independence of the rule engine allows business analysts to participate in editing and maintaining the system's business rules, improving the scalability and maintainability of the system.

[0003] The rule engine is developed from the reasoning engine and is a component embedded in the application. There are many open source implementations of the rule engine, such as drools, groovy, etc. The components of these rule engines are relatively heavy, and the visual configuration and application system integration support are not very friendly, which may lead to low efficiency and high difficulty in use.

[0004] Currently, no effective solution has been proposed to address the problem that rule engines in related technologies need to rely on open source program components with large amounts of data and are difficult to support integration, resulting in low efficiency and high difficulty in use. Summary of the invention

[0005] The invention provides a data processing method, electronic device and storage medium for a rule engine, which at least solves the problem in the related art that the rule engine needs to rely on open source program components with large data volumes and is difficult to support integration, resulting in low efficiency and high difficulty in use.

[0006] The invention provides a data processing method for a rule engine, comprising: reading business rules from a business rule library through a parser and parsing them into target expressions; using input data through an executor to run the target expression and determine the execution result of the input data; determining the business rules for subsequent execution based on the execution result, and continuing to read corresponding business rules from the business rule library for parsing and execution.

[0007] As an optional embodiment, the method further includes: responding to the business rule definition operation and displaying the corresponding visualization interface; and responding to the business rule editing operation in the visualization interface and inputting the edited business rule into the business rule library before reading the business rule from the business rule library through the parser and parsing it into the target expression.

[0008] As an optional embodiment, inputting the edited business rules into a business rule library includes: storing the business rules in a tree structure in the business rule library; storing the business rules of the tree structure in the business rule library through a parent representation method, wherein the business rules of the tree structure include multiple nodes, and the nodes include at least one of the following: node ID, business attributes, operators, business values, parent node ID, and node description.

[0009] As an optional embodiment, business rules are read from a business rule library through a parser and parsed into a target expression, including: constructing a hash table of business rule nodes and business rule sub-nodes by traversing the read business rules, wherein the data structure of the hash table is a flat structure; parsing the nodes of the business rules in the hash table through the parser, parsing the sub-nodes of the hash table into sub-target expressions, and storing them in a linked list, wherein the data structure of the linked list is a tree structure; parsing the business rules into a target expression by parsing the tree structure.

[0010] As an optional embodiment, the nodes of the business rules are parsed by a parser, and the child nodes of the hash table are parsed into sub-target expressions, including: parsing the current node by the parser, wherein the current node is the node of the business rule currently being parsed; when the current node has no child nodes, generating a corresponding target expression according to the expression parameters of the current node, wherein the expression parameters include at least one of the following: a left expression, an operator, and a right expression; when the current node has child nodes, parsing the child nodes by the parser, and generating a recursive calling relationship between the child nodes and the current node.

[0011] As an optional embodiment, a corresponding target expression is generated according to the expression parameters of the current node, including: when the expression parameters of the current node include a prefix type operator, determining that the linked list has a single child node, and generating the target expression with the expression parameters according to a first mode; when the expression parameters of the current node include an infix type operator, determining that the linked list has multiple child nodes, and generating the target expression with the expression parameters according to a second mode; in the target expression, when the number of sub-expressions corresponding to the child node is multiple, adding left and right brackets before and after the sub-expressions.

[0012] As an optional embodiment, the target expression is run by an executor using input data to determine the execution result of the input data, including: creating an expression context and a corresponding default parser; modifying the corresponding variables of the expression context through the input data to set the default parser as the parser; parsing business rules through the parser, loading and executing the target expression, and outputting the execution result.

[0013] An electronic device provided by an embodiment of the present invention includes: a processor and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes a data processing method of a rule engine described above.

[0014] An embodiment of the present invention provides a non-transitory machine-readable medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the data processing method of the rule engine described above.

[0015] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the data processing method of a rule engine described above is implemented.

[0016] The data processing method of the rule engine provided by the embodiment of the invention reads business rules from the business rule library through a parser and parses them into target expressions; uses an operator to use input data to run the target expression and determine the execution result of the input data; determines the business rules for subsequent execution based on the execution result, and continues to read the corresponding business rules from the business rule library for parsing and execution; that is, the business rules are parsed into target expressions for execution by using a parser and an operator, and there is no need to call open source program components, which solves the problem in the related art that the rule engine needs to rely on open source program components with large data volumes, which is difficult to support integration, resulting in low usage efficiency and high usage difficulty, and achieves the technical effect of reducing the usage difficulty and data volume of the rule engine, improving usage efficiency, and improving system integration. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other embodiments can be obtained based on these drawings without creative work.

[0018] Figure 1 It is a flow chart of a data processing method of a rule engine according to an embodiment of the present invention; Figure 2 It is a flow chart of data processing of the rule engine of the implementation mode created by the present invention; Figure 3 It is a structural schematic diagram of the electronic device created by the present invention. DETAILED DESCRIPTION

[0019] The embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.

[0020] In order to solve the problem in the related art that the rule engine needs to rely on external open source program components and is difficult to support integration, resulting in low efficiency and high difficulty in use, an embodiment created by the present invention provides a data processing method for a rule engine.

[0021] in, Figure 1 is a flow chart of a data processing method of a rule engine according to an embodiment of the present invention, such as Figure 1 As shown, the data processing method of the rule engine provided by the embodiment of the invention comprises the following steps: Step S101, reading business rules from a business rule library through a parser, and parsing them into a target expression; Step S102, using the input data through the executor to execute the target expression and determine the execution result of the input data; Step S103, determining the business rules to be executed subsequently according to the execution result, and continuing to read the corresponding business rules from the business rule library, and performing parsing and execution.

[0022] The data processing method of the rule engine provided by the embodiment of the invention reads business rules from the business rule library through a parser and parses them into target expressions; uses an executor to use input data to run the target expression and determine the execution result of the input data; determines the business rules for subsequent execution based on the execution result, and continues to read corresponding business rules from the business rule library for parsing and execution; that is, using the parser, the executor parses the business rules into target expressions for execution, and there is no need to call open source program components with large data volumes, thereby achieving the technical effects of reducing the difficulty and data volume of the rule engine, improving usage efficiency, and improving system integration.

[0023] The execution subject of the above steps may be a rule engine, or a software development framework platform running the rule engine, such as Spring. The above parser may be a built-in functional component of the above software development framework platform, and the runner may also be a built-in functional component of the above software development framework platform.

[0024] In the related art, when using the rule engine to analyze business rules, it often relies on some open source components, which are relatively heavy in themselves, and may lead to low efficiency and high difficulty in using the rule engine. To this end, this embodiment uses the built-in functional components of the software development framework platform and the target expressions of the built-in expression language to implement the rule engine. Compared with the related art that uses open source program components with large amounts of data to implement the rule engine, it has less resource usage, lower difficulty and data volume, and improves the efficiency of use and the system integration of the software development framework platform.

[0025] Specifically, the above-mentioned business rules are read from the business rule library through the parser and parsed into the target expression. The above-mentioned business rule library is a database that can be customized by the software development framework platform, and can store data in a predetermined format. In order to facilitate the management and calling of business rules, this embodiment sets a business rule library to store business rules, and the business rules in the business rule library can be modified according to needs. The modification authority can also be set according to actual conditions.

[0026] The parser can directly read business rules from the business rule library and parse them into target expressions, so that the rule information of the business rule library can be expressed according to the target expression. There is no need to introduce other components, making it lightweight to use, thereby reducing the amount of data in the rule engine.

[0027] The runner uses the input data to run the target expression and determine the execution result of the input data. The input data may be the context object, the runtime environment initialization parameters, etc. required for the runner to run the target expression. The business rule runner may be implemented using a parser, which will be described in detail later.

[0028] The target expression is run through the runner to determine the execution result of the input data after executing the business rules of the target expression. This facilitates subsequent actions based on the execution results.

[0029] After obtaining the execution result, the business rules for subsequent execution can be determined based on the execution result, and the corresponding business rules can be read from the business rule library according to the needs, and analyzed and executed.

[0030] As an optional embodiment, the method further includes: responding to the definition operation of the business rules by displaying the corresponding visualization interface; and responding to the editing operation of the business rules in the visualization interface by inputting the edited business rules into the business rule library.

[0031] In the related art, business rules can be input using open source components or manually input, which usually requires professional operation. In order to achieve visualization, this embodiment displays the corresponding visualization interface according to the definition of the business rules before reading the business rules through the parser.

[0032] The description of business rules can be entered on the visual interface, and business rules will be automatically generated. In response to the editing operation of business rules in the visual interface, the edited business rules will be entered into the business rule library. This enables visual editing of business rules and reduces the difficulty of editing business rules.

[0033] As an optional embodiment, the edited business rules are input into the business rule library, including: storing the business rules in a tree structure in the business rule library; storing the business rules with a tree structure in the business rule library through a parent representation method, wherein the business rules with a tree structure include multiple nodes, and the nodes include at least one of the following: node ID, business attributes, operators, business values, parent node ID, and node description.

[0034] The business rules are stored in the business rule library in a tree structure, which can accurately describe more complex business rules. The business rules in the tree structure include multiple nodes, and the nodes include at least one of the following: node ID, business attribute, operator, business value, parent node ID, node description.

[0035] As an optional embodiment, a parser is used to read business rules from a business rule library and parse them into target expressions, including: constructing a hash table of business rule nodes and business rule sub-nodes by traversing the read business rules, wherein the data structure of the hash table is a flat structure; parsing the nodes of the business rules in the hash table by the parser, parsing the sub-nodes of the hash table into sub-target expressions, and storing them in a linked list, wherein the data structure of the linked list is a tree structure; parsing the business rules into a target expression by parsing the tree structure.

[0036] The business rule parser reads the business rules in the business rule library, parses the nodes of the flat structure into a tree structure, and then parses the business rule library into a SpEL expression based on the tree structure.

[0037] Specifically, read the business rule data of the business rule library; traverse the business rule data; construct a hash table with business rules as the key and the business rule sub-node list as the value; parse the node, parse the sub-node of the node into Spel expressions, and put them into the sub-expression linked list.

[0038] As an optional embodiment, the nodes of the business rules are parsed by a parser, and the child nodes of the hash table are parsed into sub-target expressions, including: parsing the current node by a parser, wherein the current node is the node of the business rule currently being parsed; when the current node has no child nodes, generating a corresponding target expression according to the expression parameters of the current node, wherein the expression parameters include at least one of the following: a left expression, an operator, and a right expression; when the current node has child nodes, parsing the child nodes by a parser, and generating a recursive calling relationship between the child nodes and the current node.

[0039] That is, if the node has no child nodes, take out the expression parameters of the node, including the left expression, operator, and right expression, and assemble them into the following format: left expression + space + operator + space + right expression, which is the above target expression.

[0040] If the node has child nodes, re-execute the parser to parse the nodes of the business rules in the hash table, parse the child nodes of the hash table into sub-target expressions, and store them in the linked list, and perform a recursive call.

[0041] As an optional embodiment, a corresponding target expression is generated according to the expression parameters of the current node, including: when the expression parameters of the current node include a prefix type operator, determining that the linked list has a single child node, and generating the target expression with the expression parameters according to a first mode; when the expression parameters of the current node include an infix type operator, determining that the linked list has multiple child nodes, and generating the target expression with the expression parameters according to a second mode; in the target expression, when there are multiple sub-expressions corresponding to the child nodes, adding left and right brackets before and after the sub-expressions.

[0042] If the current node is a prefix type operator (such as not), it can be determined that the sub-expression list has only one child node, which is assembled into the following first pattern: operator + space + sub-expression.

[0043] If the current node is an infix operator (such as and, or), it can be determined that the sub-expression list must have more than two child nodes, assembled into the following second pattern: sub-expression 1+space+sub-expression 2+space+….

[0044] If the number of sub-expressions is greater than 1, add left and right parentheses before and after the sub-expressions. This will improve the accuracy of the target expression according to different representation methods.

[0045] As an optional embodiment, the runner utilizes input data to run the target expression and determine the execution result of the input data, including: creating an expression context and a corresponding default parser; modifying the corresponding variables of the expression context through the input data to set the default parser as the parser; parsing business rules through the parser, loading and executing the target expression, and outputting the execution result.

[0046] The business rule runner loads the SpEL expression, runs the context object, initializes the running environment, and outputs the running results. Specifically, first create a standard expression context, construct the bean factory parser of the software development framework platform, set the bean parser of the expression context to the bean factory parser constructed above; design variables in the expression context; business rule parser, parse business rules; load the parsed target expression, execute the target expression, return the expression result, and make business logic judgments.

[0047] It should be noted that this embodiment also provides an optional implementation method, which is described in detail below. This implementation method provides a lightweight rule engine implementation and provides a friendly visual configuration interface. It mainly includes the data structure, parser, runner and other functions of the business rule expression, realizes some functions of the rule engine, and does not support process functions while being lightweight.

[0048] Figure 2 Flowchart of data processing of the rule engine of the embodiment of the present invention, such as Figure 2 As shown, the process steps are as follows: (1) System administrators define business rules through a visual interface to form a business rule library; (2) The business rule parser reads the business rule base and parses it into a business SpEL expression, which is the target expression mentioned above; (3) The business rule runner loads the SpEL expression, initializes the relevant context, executes the expression, and generates the execution result; (4) Business processing handles subsequent business logic according to the execution results; The above SpEL expression supports the following expressions: 1. Basic expressions: literal expressions, relations, logical and arithmetic expressions, string concatenation and truncation expressions, ternary operations and Elivis expressions, regular expressions, bracket priority expressions; 2. Class-related expressions: class type expression, class instantiation, instanceof expression, variable definition and reference, assignment expression, custom function, object attribute access and safe navigation expression, object method call, Bean reference; 3. Collection-related expressions: inline list, inline array, collection, dictionary access, list, dictionary, array modification, collection projection, collection selection; does not support multi-dimensional inline array initialization; does not support inline dictionary definition; 4. Other expressions: template expressions.

[0049] Considering the complexity of business rules, business rules are stored in a tree structure. The parent representation method is used to store each node and attach a variable to the node to record the position of its father node. The value of the root node is -1. The above node is the most basic unit, including node ID, business attributes, operators, business values, parent node ID, description and other information; Typical business rule examples are as follows:

[0050] Business rules are stored in the business rule library, and each node is a record in the database.

[0051] The meaning of the above business rules is: in the business document (the declaration number starts with K and it is an empty box) or (the declaration number starts with R2 and it is a full box); the business rule executor can determine the business documents that meet the conditions and perform specific business logic processing, such as business review, business activation, etc.

[0052] The above business rule parser reads the business rule library in the business rule library, parses the nodes of the flat structure into a tree structure, and then parses the business rule library into a SpEL expression according to the tree structure. The specific steps are as follows: (1) Read the business rule data from the business rule library; (2) Traverse business rule data; (3) Construct a hash table with business rules as the key and the business rule sub-node list as the value; (4) Parse the node, parse the child nodes of the node into Spel expressions, and put them into the sub-expression list; (5) If the node has no child nodes, take out the left expression, operator, and right expression of the node and assemble them into the following format: left expression + space + operator + space + right expression; (6) If the node has child nodes, go to step (4) for recursive call; (7) If the current node is a prefix type operator (such as not), the assertion sub-expression list has only one child node, assembled into the following format: operator + space + sub-expression; (8) If the current node is an infix operator (such as and, or), the assertion sub-expression list must have more than two child nodes, assembled into the following format: sub-expression 1 + space + sub-expression 2 + space + ; (9) If the number of sub-expressions is greater than 1, add left and right parentheses before and after the sub-expressions; (10) Recursive return, parsing ends; The above business rule runner loads the SpEL expression, runs the context object, initializes the running environment, and outputs the running results. The specific steps are as follows; (1) Create a standard expression context (StandardEvaluationContext); (2) Construct the bean factory resolver (BeanFactoryResolver) of the spring framework; (3) Set the bean resolver of the expression context to the resolver built in step (2); (4) Design a variable in the expression context, with the variable key being "context" and the value being itself; (5) Business rule parser, parsing business rules; (6) Load the expression parsed in step (5); (7) Execute the expression; (8) Return the expression result and perform business logic judgment.

[0053] This implementation method implements a business rule engine based on SpEL expressions. Spring is a very popular and common technical component. SpEL is Spring's own expression language, which does not require the introduction of other components and is lightweight to use. SpEL expressions are stored in a tree structure, and each node is designed in a universal way. While supporting complex expressions, it is convenient for users to customize expressions.

[0054] Using a rule engine can solve the problems caused by hard-coding business rules, such as difficulty in maintenance, difficulty in coping with changes, and the need to modify code and restart services when business rules change. The independence of the rule engine allows business analysts to participate in editing and maintaining the system's business rules, improving the scalability and maintainability of the system.

[0055] Based on the above-mentioned data processing method of a rule engine provided by an embodiment of the invention, an embodiment of the invention further provides a data processing device of a rule engine, the device comprising: The parsing module is used to read business rules from the business rule library through the parser and parse them into target expressions; The running module is used to use the input data through the runner to run the target expression and determine the execution result of the input data; The determination module is used to determine the business rules for subsequent execution based on the execution results, and continue to read the corresponding business rules from the business rule library for parsing and execution.

[0056] The data processing device of the rule engine provided by the embodiment of the invention reads business rules from the business rule library through a parser and parses them into a target expression; uses an operator to run the target expression using input data and determines the execution result of the input data; determines the business rules to be executed subsequently based on the execution result, and continues to read the corresponding business rules from the business rule library for parsing and execution. That is, the business rules are parsed into target expressions for execution using a parser and an operator, and there is no need to call open source program components, thereby achieving the technical effect of reducing the difficulty and data volume of the rule engine, improving the efficiency of use, and improving the system integration.

[0057] The embodiments of the present invention also provide a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiments of the present invention.

[0058] The embodiments of the present invention further provide a computer program product, including a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiments of the present invention.

[0059] The embodiment of the invention also provides an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and the computer program is used to enable the electronic device to perform the method of the embodiment of the invention when executed by the at least one processor.

[0060] refer to Figure 3, a block diagram of an electronic device that can be used as a server or client of an embodiment of the invention will now be described, which is an example of hardware devices that can be applied to various aspects of the invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the invention described and / or required herein.

[0061] like Figure 3 As shown, the electronic device includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 302 or a computer program loaded from a storage unit 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device can also be stored. The computing unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0062] Multiple components in the electronic device are connected to the I / O interface 305, including: an input unit 306, an output unit 307, a storage unit 308, and a communication unit 309. The input unit 306 can be any type of device that can input information to the electronic device, and the input unit 306 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device. The output unit 307 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 308 can include but is not limited to a disk, an optical disk. The communication unit 309 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, and / or a wireless communication transceiver, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0063] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a CPU, a graphics processing unit (GPU), various special artificial intelligence (AI) computing units, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 301 performs the various methods and processes described above. For example, in some embodiments, the method embodiments created by the present invention may be implemented as a computer program, which is tangibly contained in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on an electronic device via a ROM 302 and / or a communication unit 309. In some embodiments, the computing unit 301 may be configured to perform the above-described method in any other appropriate manner (e.g., by means of firmware).

[0064] The computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the computer program, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0065] In the context of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, or infrared systems, devices, or equipment, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0066] It should be noted that the term "including" and its variations used in the embodiments of the present invention are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative and not restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0067] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0068] The various steps described in the method implementation methods provided by the embodiments of the present invention can be performed in different orders and / or in parallel. In addition, the method implementation methods may include additional steps and / or omit the steps shown. The scope of protection of the present invention is not limited in this respect.

[0069] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same and similar parts between the various embodiments refer to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.

[0070] The above-described embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of protection. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the attached claims.

Claims

1. A data processing method for a rule engine, characterized in that: include: Through the parser, the business rules are read from the business rule library and parsed into target expressions; The target expression is run by the runner using the input data to determine the execution result of the input data; According to the execution result, the business rules to be executed subsequently are determined, and the corresponding business rules are continuously read from the business rule library for parsing and execution.

2. The data processing method of a rule engine according to claim 1, characterized in that: Before reading the business rules from the business rule library by the parser and parsing them into target expressions, the method further includes: Respond to the definition operation of business rules and display the corresponding visual interface; In response to an editing operation on the business rules in the visualization interface, the edited business rules are input into a business rule library.

3. The data processing method of a rule engine according to claim 2, characterized in that: Enter the edited business rules into the business rule library, including: Storing the business rules in a tree structure in the business rule library; The business rules of the tree structure are stored in the business rule library through parent representation, wherein the business rules of the tree structure include multiple nodes, and the nodes include at least one of the following: node ID, business attribute, operator, business value, parent node ID, node description.

4. The data processing method of a rule engine according to claim 1, characterized in that: The parser reads business rules from the business rule library and parses them into target expressions, including: By traversing the read business rules, a hash table of business rule nodes and business rule sub-nodes is constructed, wherein the data structure of the hash table is a flat structure; Parsing the nodes of the business rules in the hash table by a parser, parsing the child nodes of the hash table into sub-target expressions, and storing them in a linked list, wherein the data structure of the linked list is a tree structure; By parsing the tree structure, the business rules are parsed into target expressions.

5. The data processing method of a rule engine according to claim 4, characterized in that: Parsing the nodes of the business rules by a parser, parsing the child nodes of the hash table into child target expressions, including: Parsing a current node by the parser, wherein the current node is a node of a business rule currently being parsed; In the case that the current node has no child node, generating a corresponding target expression according to expression parameters of the current node, wherein the expression parameters include at least one of the following: a left expression, an operator, and a right expression; In the case that the current node has child nodes, the child nodes are parsed by a parser, and a recursive calling relationship between the child nodes and the current node is generated.

6. A data processing method for a rule engine according to claim 5, characterized in that: Generate a corresponding target expression according to the expression parameters of the current node, including: In the case where the expression parameter of the current node includes an operator of a prefix type, determining that the linked list has a single child node, and generating a target expression from the expression parameter according to a first mode; In the case where the expression parameter of the current node includes an infix operator, determining that the linked list has a plurality of child nodes, and generating a target expression from the expression parameter according to the second mode; In the target expression, if the number of sub-expressions corresponding to the sub-node is multiple, add left brackets and right brackets before and after the sub-expressions.

7. The data processing method of a rule engine according to claim 1, characterized in that: The target expression is run by the runner using the input data to determine the execution result of the input data, including: Create an expression context and the corresponding default parser; By inputting data, modifying a corresponding variable of the expression context to set the default parser as the parser; The business rules are parsed by the parser, the target expression is loaded and executed, and the execution result is output.

8. An electronic device comprising: A processor, and a memory storing a program, wherein the program includes instructions, and when the instructions are executed by the processor, the processor executes a data processing method of a rule engine according to any one of claims 1 to 7.

9. A non-transitory machine-readable medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute a data processing method of a rule engine according to any one of claims 1 to 7.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, a data processing method for a rule engine according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Service approval method, device and equipment and medium

    CN108647883A

  • Rule editing method, a rule editing device and rule editing equipment

    CN109656453A

  • Data processing method and device based on rule engine and computer equipment

    CN116975105A

  • Rule matching method and device, electronic equipment and storage medium

    CN118296218A

  • Tree structural data display device

    JP1992307685A

Cited By

  • Data processing method, electronic device, storage medium and computer program product

    CN121614886A