Rule optimization processing method and device of rule engine, equipment and storage medium
By creating a knowledge graph and dividing rule packages, the difficulty of manually eliminating rule engine conflicts and redundant rules in the existing technology is solved, and efficient rule optimization processing is achieved.
Patent Information
- Application Number
- CN202411442309.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-25
AI Technical Summary
In the prior art, it is difficult and less efficient to manually eliminate conflicts and redundant rules in the rule engine.
By obtaining the rule package, creating a knowledge graph, dividing the rule package, and calling rules with the same parameters in the sub-rule package, calculating the correlation of the output results. If it is related, post-processing is performed to delete or edit redundant rules.
It realizes the rapid and efficient identification and processing of redundant rules in the rule engine, improving the efficiency and accuracy of rule optimization.
Smart Images

Figure CN119514753A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing and big data technology, and in particular to a rule optimization processing method, device, equipment and storage medium for a rule engine. Background Art
[0002] With the continuous development of information technology, a large number of businesses are automatically executed by programs. Business personnel can use rule engines to write business rules or other rules, but there must be no conflicts between the written rules.
[0003] At present, in related technologies, whether there is a conflict between rules in the rule engine requires a dedicated person to have an in-depth understanding of the business logic and rule definitions in order to make a judgment, and the conflicting rules need to be manually eliminated.
[0004] However, the inventors have discovered that the related technology has at least the following technical problems: manually eliminating conflicts and redundant rules is difficult and inefficient. Summary of the invention
[0005] The embodiments of the present application provide a rule optimization processing method, apparatus, device and storage medium of a rule engine, so as to solve the problem that it is difficult and inefficient to manually eliminate conflicting rules.
[0006] In the first aspect, an embodiment of the present application provides a rule optimization processing method for a rule engine, including: obtaining a rule package, wherein the rule package includes text rules, decision tables, decision trees and rule flows; using text rules, decision tables, decision trees and rule flows to create a rule package calling a knowledge graph; calling the knowledge graph based on the rule package to determine at least one sub-rule package; determining the rules containing the same input parameters in the sub-rule package as a rule subset, wherein the rule subset includes at least two rules to be compared; using the same input parameters of any two rules to be compared, calling any two rules to be compared, and obtaining two sets of rule output results; determining the correlation between the two sets of rule output results; if the correlation is correlated, post-processing any two rules to be compared.
[0007] In a possible implementation, any two rules to be compared are called using the same input parameter to obtain two sets of rule output results, including: determining the value range of the same input parameter of any two rules to be compared; extracting the parameter value in the value range; calling any two rules to be compared using the parameter value to obtain two sets of rule output results.
[0008] In one possible implementation, text rules, decision tables, decision trees and rule flows are used to create a rule package call knowledge graph, including: using text rules, decision tables and variables used in decision trees to create rule-use-variable triplets; using rules called by rule flows to create rule flow-call-rule triplets; using rule-use-variable triplets and rule flow-call-rule triplets to create a rule package call knowledge graph.
[0009] In a possible implementation, after calling the knowledge graph according to the rule package and determining at least one sub-rule package, it also includes: determining the sub-rules of any text rule in the sub-rule package; obtaining the variables referenced by the sub-rules; if there are identical variables in the variables referenced by at least two sub-rules, obtaining the corresponding first boundary conditions; using preset rules to determine whether the first boundary conditions are abnormal; if the first boundary conditions are abnormal, post-processing the sub-rules to obtain a new sub-rule package.
[0010] In a possible implementation, after calling the knowledge graph according to the rule package and determining at least one sub-rule package, it also includes: determining the left subtree and the right subtree of any decision tree in the sub-rule package; obtaining the second boundary conditions of the left subtree and the right subtree; using preset rules to determine whether the second boundary conditions are abnormal; if the second boundary conditions are abnormal, post-processing any decision tree to obtain a new sub-rule package.
[0011] In a possible implementation, after creating a rule package calling a knowledge graph using text rules, decision tables, decision trees, and rule flows, it also includes: determining the importance value of each vertex in the rule package calling the knowledge graph; determining at least one sub-rule package based on the rule package calling the knowledge graph; determining the rule package importance of each sub-rule package based on the importance value; determining the rule package to be tested in the sub-rule package based on the rule package importance; accordingly, determining the rules containing the same input parameters in the sub-rule package as a rule subset, including: determining the rules containing the same input parameters in the rule package to be tested as a rule subset.
[0012] In the second aspect, an embodiment of the present application provides a rule optimization processing device for a rule engine, including: a rule package acquisition module, used to acquire a rule package, wherein the rule package includes text rules, decision tables, decision trees and rule flows; a graph creation module, used to use text rules, decision tables, decision trees and rule flows to create a rule package to call a knowledge graph; a sub-package determination module, used to call the knowledge graph according to the rule package to determine at least one sub-rule package; a subset determination module, used to determine the rules containing the same input parameters in the sub-rule package as a rule subset, wherein the rule subset includes at least two rules to be compared; a rule calling module, used to use the same input parameters of any two rules to be compared, call any two rules to be compared, and obtain two sets of rule output results; a correlation determination module, used to determine the correlation of the two sets of rule output results; a post-processing module, used to post-process any two rules to be compared if the correlation is correlated.
[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the first aspect above and / or various possible implementations of the first aspect.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0016] The rule optimization processing method, apparatus, device and storage medium of the rule engine provided in the embodiments of the present application obtain a rule package, create a knowledge graph using the content in the rule package, divide the knowledge graph to obtain sub-rule packages, call the rules with the same input parameters in the sub-rule packages, determine the correlation of the output results, determine whether the rules are related, post-process the related rules, and quickly and efficiently find out the redundant rules in the rule package. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] Figure 1 A schematic diagram of a scenario of a rule optimization processing method of a rule engine provided in this application;
[0019] Figure 2 A flowchart of a rule optimization processing method of a rule engine provided in an embodiment of the present application;
[0020] Figure 3 A schematic diagram of the structure of a rule optimization processing device of a rule engine provided in an embodiment of the present application;
[0021] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0022] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0023] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0024] With the rapid advancement of information technology, more and more business processes can be automatically executed through rule engines. Rule engines often contain a large number of judgment rules and processing rules, which work together to ensure the accuracy and efficiency of business. However, this also puts strict requirements on the design of rules: the rules must be highly consistent and there must be no conflicts, otherwise it will cause program errors or distorted business results.
[0025] In current related technologies, determining whether rules in a rule engine conflict is still a very challenging task, which requires professionals to deeply study business logic, carefully read rule definitions, and manually troubleshoot potential conflicting rules with rich experience. This method is difficult and inefficient.
[0026] In response to the above technical problems, the inventors proposed the following technical concept: by creating a knowledge graph corresponding to the rule package and dividing the knowledge graph to obtain sub-rule packages, the rules using the same input parameters in the sub-rule packages are determined as rules to be compared, the input parameters are used to call the rules to be compared to obtain output results, and the correlation between the two sets of output results is calculated. When the correlation is relevant, the rules to be compared are deleted, deduplicated, edited, and other post-processed.
[0027] Figure 1 A schematic diagram of a scenario of a rule optimization processing method of a rule engine provided in this application. Figure 1 , this scenario includes: a server 101 and a terminal device 102.
[0028] In the specific implementation process, the server 101 can be implemented by using a server with more powerful processing capabilities and higher security or a cluster of multiple servers. If possible, a computer or laptop with stronger computing power can be used as a substitute.
[0029] The terminal device 102 may include a computer, a server, a tablet, a mobile phone, a PDA (Personal Digital Assistant), a notebook, etc., which can input data.
[0030] The connection between the server 101 and the terminal device 101 may be a wired connection or a wireless connection.
[0031] The server 101 is used to perform rule optimization processing of the rule engine after receiving the instructions sent by the terminal device 102, and can also perform rule optimization processing of the rule engine periodically, wherein the rule optimization processing of the rule engine can be performed by obtaining a rule package, creating a knowledge graph from the rule package, creating a sub-rule package from the knowledge graph, and taking the rules containing the same input parameters in the sub-rule package as a rule subset, using the input parameters commonly used in the rule subset, calling the rules in the rule subset, obtaining two sets of rule output results, comparing the correlation of the output results, and modifying, deleting, and other post-processing on the rules in the rule subset if they are correlated.
[0032] It is understandable that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the rule optimization processing method of the rule engine. In other feasible implementations of the present application, the above architecture may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently, which can be determined according to the actual application scenario and is not limited here. Figure 1 The components shown may be implemented by hardware, software, or a combination of software and hardware.
[0033] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0034] Figure 2 A flowchart of a rule optimization processing method for a rule engine provided in an embodiment of the present application. The execution subject of the embodiment of the present application may be Figure 1The server 101 in the embodiment may also be a computer and / or a mobile phone, etc., which is not particularly limited in this embodiment. Figure 2 As shown, the method includes:
[0035] S201: Obtain a rule package, wherein the rule package includes text rules, decision tables, decision trees, and rule flows.
[0036] In this step, obtaining the rule package can be achieved by reading the content in the database and variable library. Text rules represent rules such as conditional statements written by staff, decision tables are composed of different conditions, and decision trees are composed of different decisions or conditions as nodes. Rule flows reference text rules, decision tables, and decision trees to form more complex rules.
[0037] S202: Use text rules, decision tables, decision trees and rule flows to create a rule package to call the knowledge graph.
[0038] In this step, the fields in text rules, decision tables, decision trees, and rule flows are combined into triples, and rule packages are created from the triples to call the knowledge graph.
[0039] S203: Call the knowledge graph according to the rule package to determine at least one sub-rule package.
[0040] In this step, the rule package may be called to cluster nodes in the knowledge graph, and the content in the cluster obtained by clustering may be used as a sub-rule package. It may also include using a community discovery algorithm such as a strong / weakly connected graph and the Louvain algorithm to perform community cutting, divide the knowledge graph, and obtain sub-rule packages.
[0041] S204: Determine the rules in the sub-rule package that contain the same input parameters as a rule subset, where the rule subset includes at least two rules to be compared.
[0042] In this step, the input parameters of the rule can be obtained by reading the content of the rule.
[0043] For example, if the input parameters of rules A, B, and C in the sub-rule package all contain parameter a and parameter b, then rules A, B, and C are collectively determined as a rule subset. Rules A, B, and C are used as the rules to be compared. For another example, if the input parameters of rules E and F in the sub-rule package all contain parameter d, then rule d is collectively determined as a rule subset.
[0044] S205: Using the same input parameters of any two rules to be compared, calling any two rules to be compared, and obtaining two sets of rule output results.
[0045] In this step, the above-mentioned same input parameter value may be randomly adopted as an input value, the rule to be compared is called, and the rule output results of the two groups of rules to be compared are obtained.
[0046] S206: Determine the correlation between the output results of the two sets of rules.
[0047] In this step, the relevance of the output results may be determined by calculating the Pearson coefficient, the Spearman coefficient, the Kendall coefficient, etc.
[0048] S207: If the correlation is related, post-processing is performed on any two rules to be compared.
[0049] In this step, when the correlation is relevant, the two rules to be compared are output, the deletion instructions, modification instructions, and review results input by the staff according to the rules to be compared are received, and the corresponding deletion operations, modification operations, and editing operations are performed to achieve post-processing.
[0050] From the description of the above embodiments, it can be seen that the embodiments of the present disclosure obtain a rule package, create a knowledge graph using the content in the rule package, divide the knowledge graph, obtain sub-rule packages, call the rules with the same input parameters in the sub-rule packages, determine the correlation of the output results, determine whether the rules are related, post-process the related rules, and quickly and efficiently find out the redundant rules in the rule package.
[0051] In a possible implementation, in the above step S205, the same input parameters of any two rules to be compared are used to call any two rules to be compared, and two sets of rule output results are obtained, including:
[0052] S2051: Determine the value range of the same input parameter of any two rules to be compared.
[0053] In this step, the value range can be obtained by determining the parameter type of the input parameter. Integers, floating point numbers, and strings have corresponding value ranges; the value range can also be obtained through pre-calibration by the staff.
[0054] S2052: Extract the parameter value from the value range.
[0055] In this step, the parameter value may be randomly selected from the value range; or the parameter value may be averagely selected from the value range.
[0056] Specifically, the extraction uses parameter values, and the uniform bucketing method can be used for extraction. When the variance of the parameter value range is large, the logarithmic bucket method can be used for extraction, and the progressive binary search traversal method can also be used for extraction.
[0057] S2053: Call any two rules to be compared using parameter values to obtain two sets of rule output results.
[0058] In this step, the rule to be compared can be called by using the position and name using the parameter value to obtain two sets of rule output results.
[0059] From the description of the above embodiments, it can be seen that the embodiments of the present disclosure determine the value range of the same input parameters of the rules to be compared, extract the usage parameter values in the value range, and use the extracted usage parameter values to call the rules to be compared to obtain the rule output results, thereby automatically using appropriate input values to run the rules to be compared, which facilitates the subsequent use of the rule output results to determine whether the rules to be compared are related.
[0060] In a possible implementation, in the above steps S2051 to S2053, it can also include parsing the input parameter list of the rule package to obtain the input parameter data type, for each variable in the variable library, summarizing the rule subsets (general rules, decision tables, decision trees, etc.) involving the use of the same variable, and pairing them two by two to generate rules to be compared; determining the variables commonly used by the rules to be compared, determining the value range of the commonly used variables, sampling by uniform bucketing or logarithmic bucketing to obtain the use parameter value, calling the rule to be compared by using the use parameter value, obtaining the rule output result of the rule to be compared, and performing correlation analysis using the rule output result to determine whether it is related.
[0061] In a possible implementation, in the above step S202, text rules, decision tables, decision trees and rule flows are used to create a rule package to call a knowledge graph, including:
[0062] S2021: Create rule-use-variable triplets using text rules, decision tables, and variables used by decision trees.
[0063] In this step, the variables used in the text rules, decision tables, and decision trees are read, and the text rules, decision tables, and decision trees are used as "rules", and the variables they use are used as "variables" to construct rule-usage-variable triples.
[0064] S2022: Use the rule called by the rule flow to create a rule flow-call-rule triple.
[0065] In this step, the rule flow is used as the "rule flow" in the "rule flow-call-rule triple", and the rule called by the rule flow is used as the "rule" in the "rule flow-call-rule triple" to create a triple, thereby obtaining the "rule flow-call-rule triple".
[0066] The edge “call” in the triple “rule flow-call-rule” can also be “use”.
[0067] S2023: Use rule-use-variable triples and rule flow-call-rule triples to create a rule package call knowledge graph.
[0068] In this step, the two types of triples are input into the knowledge graph creation tool to obtain the rule package output by the knowledge graph creation tool to call the knowledge graph.
[0069] Among them, the knowledge graph creation tool can be pre-configured by the staff.
[0070] From the description of the above embodiments, it can be seen that the embodiments of the present disclosure create two different triples based on text rules, the relationship between decision tables and decision trees and variables, and the relationship between rule flows and rules, and use the triples to create a knowledge graph, which facilitates the subsequent use of the knowledge graph to divide sub-rule packages and reduce the number and difficulty of comparisons between rules.
[0071] In a possible implementation, in the above step S203, after calling the knowledge graph according to the rule package and determining at least one sub-rule package, the following is further included:
[0072] S220: Determine a sub-rule of any text rule in the sub-rule package.
[0073] In this step, a large model may be used to analyze the semantics of the rules, thereby identifying nested results in the rules and forming sub-rules at different levels.
[0074] S221: Obtain the variable referenced by the sub-rule.
[0075] This step may include reading variable names in the sub-rules.
[0076] S222: If there is an identical variable among the variables referenced by at least two sub-rules, obtain a corresponding first boundary condition.
[0077] In this step, the boundary conditions corresponding to the two sub-rules may be obtained respectively, or the boundary conditions corresponding to the two sub-rules may be combined to obtain the first boundary condition.
[0078] For example, if both rule A and rule B use variable d, then the boundary conditions of variable d in rule A and the boundary conditions of variable d in rule B are obtained. For another example, if both rule C and rule D use variables e and f, then the boundary conditions of variable e in rule C, the boundary conditions of variable f in rule C, the boundary conditions of variable e in rule D, and the boundary conditions of variable f in rule D are obtained, and the two boundary conditions of variable f and the two boundary conditions of variable e are combined to obtain the first boundary condition.
[0079] S223: Using a preset rule to determine whether the first boundary condition is abnormal.
[0080] In this step, it may include using rules pre-written by the staff using AND, OR, and NOT logic to determine whether the first boundary condition is abnormal.
[0081] S224: If the first boundary condition is abnormal, post-process the sub-rule to obtain a new sub-rule package.
[0082] In this step, the process of post-processing the sub-rules is similar to the process of post-processing in the above step S207, and will not be repeated here.
[0083] From the description of the above embodiments, it can be seen that the embodiments of the present disclosure determine the sub-rules of the text rules in the sub-rule package, judge whether the boundary conditions of the variables referenced by the sub-rules are abnormal, and post-process the sub-rules in abnormal cases, so as to judge whether there are conflicts or redundancies between the sub-rules based on the boundary conditions of the sub-rules.
[0084] In a possible implementation, after the above step S203 calls the knowledge graph according to the rule package and determines at least one sub-rule package, it also includes:
[0085] S230: Determine the left subtree and the right subtree of any decision tree in the sub-rule package.
[0086] In this step, the decision tree is a binary tree, the root node is connected to two nodes, the subtree corresponding to the node next to the root node is used as the left subtree, and the subtree corresponding to the other node is used as the right subtree.
[0087] S231: Obtain the second boundary conditions of the left subtree and the right subtree.
[0088] In this step, the second boundary condition may be a boundary condition of each parameter in the left subtree, or may be a boundary condition of each parameter in the right subtree.
[0089] S232: Using a preset rule to determine whether the second boundary condition is abnormal.
[0090] This step is similar to the above step S223 and will not be repeated here.
[0091] S233: If the second boundary condition is abnormal, post-process any decision tree to obtain a new sub-rule package.
[0092] This step is similar to the above step S224 and will not be repeated here.
[0093] From the description of the above embodiments, it can be seen that the embodiments of the present disclosure determine the left and right subtrees of the decision tree in the sub-rule package, obtain the boundary conditions of the subtrees, judge whether the boundary conditions of the subtrees are abnormal, and post-process the decision tree in abnormal cases to obtain a new sub-rule package, thereby automatically screening out unreasonable situations in the decision tree, eliminating the situation of boundary condition conflicts in the decision tree, and improving the efficiency of rule optimization.
[0094] In a possible implementation, after the above step S202 uses text rules, decision tables, decision trees and rule flows to create a rule package to call the knowledge graph, it also includes:
[0095] S240: Determine the importance value of each vertex in the knowledge graph called by the rule package.
[0096] In this step, the calculation rule package may be included to call the degree centrality, betweenness centrality, closeness centrality, etc. of each vertex in the knowledge graph.
[0097] S241: Call the knowledge graph according to the rule package to determine at least one sub-rule package.
[0098] This step is similar to the above step S203 and will not be repeated here.
[0099] S242: Determine the rule package importance of each sub-rule package according to the importance value.
[0100] In this step, the importance of the rule package may be obtained by weighted summing of the importance values of all vertices corresponding to the sub-rule package; or the importance of the rule package may be calculated by using the importance values of all vertices corresponding to the sub-rule package and the number of vertices.
[0101] Specifically, calculating the importance of the rule package using the importance values of all vertices corresponding to the sub-rule package and the number of vertices may include summing the importance values of all vertices corresponding to the sub-rule package and dividing the sum by the number of vertices to obtain the importance of the rule package.
[0102] S243: Determine the rule package to be detected in the sub-rule package according to the importance of the rule package.
[0103] In this step, the first N sub-rule packages with the highest importance of the corresponding rule package may be determined as the rule packages to be detected, or the first M% sub-rule packages with the highest importance of the corresponding rule package may be determined as the rule packages to be detected.
[0104] Among them, N is a positive integer preset by the staff, and M is a value greater than 0 preset by the staff.
[0105] Accordingly, in the above step S204, the rules in the sub-rule package containing the same input parameters are determined as a rule subset, including:
[0106] S2041: Determine the rules containing the same input parameters in the rule package to be detected as a rule subset.
[0107] This step is similar to the above step S204 and will not be repeated here.
[0108] Figure 3This is a schematic diagram of the structure of the rule optimization processing device of the rule engine provided in the embodiment of the present application. Figure 3 As shown, the rule optimization processing device 300 of the rule engine includes: a rule package acquisition module 301, a graph creation module 302, a sub-package determination module 303, a subset determination module 304, a rule calling module 305, a correlation determination module 306 and a post-processing module 307.
[0109] A rule package acquisition module 301 is used to acquire a rule package, wherein the rule package includes text rules, decision tables, decision trees and rule flows;
[0110] A graph creation module 302 is used to create a rule package to call a knowledge graph using text rules, decision tables, decision trees and rule flows;
[0111] A sub-package determination module 303 is used to call the knowledge graph according to the rule package to determine at least one sub-rule package;
[0112] A subset determination module 304 is used to determine the rules containing the same input parameters in the sub-rule package as a rule subset, wherein the rule subset includes at least two rules to be compared;
[0113] A rule calling module 305 is used to use the same input parameters of any two rules to be compared, call any two rules to be compared, and obtain two sets of rule output results;
[0114] A correlation determination module 306, used to determine the correlation between the output results of two sets of rules;
[0115] The post-processing module 307 is used to perform post-processing on any two rules to be compared if the correlation is related.
[0116] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0117] In a possible implementation, the rule calling module 305 is specifically used to determine the value range of the same input parameter of any two rules to be compared; extract the parameter value in the value range; and call any two rules to be compared using the parameter value to obtain two sets of rule output results.
[0118] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0119] In one possible implementation, the graph creation module 302 is specifically used to create rule-use-variable triples using text rules, decision tables, and variables used in decision trees; to create rule flow-call-rule triples using rules called by rule flows; and to create a rule package call knowledge graph using rule-use-variable triples and rule flow-call-rule triples.
[0120] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0121] In a possible implementation, the rule optimization processing device 300 of the rule engine further includes: a rule optimization processing module 308 of the sub-rule engine.
[0122] The rule optimization processing module 308 of the sub-rule engine is specifically used to determine the sub-rules of any text rule in the sub-rule package; obtain the variables referenced by the sub-rules; if there are identical variables in the variables referenced by at least two sub-rules, obtain the corresponding first boundary conditions; use preset rules to determine whether the first boundary conditions are abnormal; if the first boundary conditions are abnormal, post-process the sub-rules to obtain a new sub-rule package.
[0123] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0124] In a possible implementation, the rule optimization processing device 300 of the rule engine further includes: a subtree processing module 309 .
[0125] The subtree processing module 309 is specifically used to determine the left subtree and the right subtree of any decision tree in the sub-rule package; obtain the second boundary conditions of the left subtree and the right subtree; use preset rules to determine whether the second boundary conditions are abnormal; if the second boundary conditions are abnormal, post-process any decision tree to obtain a new sub-rule package.
[0126] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0127] In a possible implementation, the rule optimization processing device 300 of the rule engine further includes: a rule package determination module 310 .
[0128] The rule package determination module 310 is specifically used to determine the importance value of each vertex in the knowledge graph called by the rule package; determine at least one sub-rule package based on the rule package calling the knowledge graph; determine the rule package importance of each sub-rule package based on the importance value; determine the rule package to be detected in the sub-rule package based on the rule package importance; accordingly, determine the rules containing the same input parameters in the sub-rule package as a rule subset, including: determining the rules containing the same input parameters in the rule package to be detected as a rule subset.
[0129] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0130] In order to implement the above embodiment, the embodiment of the present application also provides an electronic device.
[0131] refer to Figure 4 , which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present application, and the electronic device 400 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (Portable Media Players, PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0132] like Figure 4 As shown, the electronic device 400 may include a processor (such as a central processing unit, a graphics processing unit, etc.) 401, and a memory 402 connected to the processor in communication, which can perform various appropriate actions and processes according to the program stored in the memory 402, the computer execution instruction, or the program loaded from the storage device 408 to the random access memory (Random Access Memory, referred to as RAM) 403, to implement the rule optimization processing method of the rule engine in any of the above embodiments, wherein the memory may be a read-only memory (Read Only Memory, referred to as ROM). In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the memory 402, and the RAM 403 are connected to each other via a bus 404. The input / output (I / O) interface 405 is also connected to the bus 404.
[0133] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0134] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the memory 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0135] It should be noted that the computer-readable storage medium mentioned above in the present application may be a computer-readable signal medium or a computer storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable storage medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0136] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0137] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.
[0138] The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0140] The modules involved in the embodiments described in this application may be implemented by software or hardware. The name of the unit does not limit the module itself in some cases. For example, the sub-package determination module may also be described as a "sub-rule package determination module".
[0141] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0142] The present application also provides a computer-readable storage medium, which stores computer execution instructions. When the processor executes the computer execution instructions, the technical solution of the rule optimization processing method of the rule engine in any of the above-mentioned embodiments is implemented. The implementation principle and beneficial effects are similar to the implementation principle and beneficial effects of the rule optimization processing method of the rule engine. Please refer to the implementation principle and beneficial effects of the rule optimization processing method of the rule engine, which will not be repeated here.
[0143] In the context of the present application, 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 equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0144] The present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the technical solution of the rule optimization processing method of the rule engine in any of the above-mentioned embodiments. Its implementation principle and beneficial effects are similar to the implementation principle and beneficial effects of the rule optimization processing method of the rule engine. Please refer to the implementation principle and beneficial effects of the rule optimization processing method of the rule engine, which will not be repeated here.
[0145] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
[0146] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0147] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A rule optimization processing method for a rule engine, characterized in that: include: Obtaining a rule package, wherein the rule package includes text rules, decision tables, decision trees, and rule flows; Using the text rules, the decision table, the decision tree and the rule flow, a rule package is created to call a knowledge graph; Calling the knowledge graph according to the rule package to determine at least one sub-rule package; Determine the rules in the sub-rule package that contain the same input parameters as a rule subset, wherein the rule subset includes at least two rules to be compared; Using the same input parameters of any two rules to be compared, calling the two rules to be compared, and obtaining two sets of rule output results; Determining the correlation between the output results of the two sets of rules; If the correlation is related, post-processing is performed on any two rules to be compared.
2. The method according to claim 1, characterized in that The method adopts the same input parameters of any two rules to be compared, calls any two rules to be compared, and obtains two sets of rule output results, including: Determine the value range of the same input parameter of any two rules to be compared; Extracting a parameter value from the value range; The usage parameter values are used to call any two rules to be compared to obtain two groups of rule output results.
3. The method according to claim 1, characterized in that The step of using the text rule, the decision table, the decision tree and the rule flow to create a rule package to call a knowledge graph includes: Using the text rule, the decision table and the variables used by the decision tree, create a rule-usage-variable triple; Using the rule called by the rule flow, creating a rule flow-call-rule triple; The rule package call knowledge graph is created by using the rule-use-variable triple and the rule flow-call-rule triple.
4. The method according to claim 1, characterized in that: After calling the knowledge graph according to the rule package to determine at least one sub-rule package, the method further includes: Determine a sub-rule of any text rule in the sub-rule package; Obtain the variable referenced by the sub-rule; If there are the same variables among the variables referenced by at least two sub-rules, the corresponding first boundary condition is obtained; Using a preset rule to determine whether the first boundary condition is abnormal; If the first boundary condition is abnormal, the sub-rule is post-processed to obtain a new sub-rule package.
5. The method according to claim 1, characterized in that After calling the knowledge graph according to the rule package to determine at least one sub-rule package, the method further includes: Determine the left subtree and the right subtree of any decision tree in the sub-rule package; Obtaining second boundary conditions of the left subtree and the right subtree; Using a preset rule to determine whether the second boundary condition is abnormal; If the second boundary condition is abnormal, post-processing is performed on any of the decision trees to obtain a new sub-rule package.
6. The method according to any one of claims 1 to 5, characterized in that: After the text rule, the decision table, the decision tree and the rule flow are used to create a rule package to call the knowledge graph, the method further includes: Determine the importance value of each vertex in the knowledge graph called by the rule package; Calling the knowledge graph according to the rule package to determine at least one sub-rule package; Determining the rule package importance of each sub-rule package according to the importance value; Determining the rule package to be detected in the sub-rule package according to the importance of the rule package; Accordingly, the rules in the sub-rule package containing the same input parameters are determined as a rule subset, including: The rules containing the same input parameters in the rule package to be detected are determined as a rule subset.
7. A rule optimization processing device for a rule engine, characterized in that: include: A rule package acquisition module, used to acquire a rule package, wherein the rule package includes text rules, decision tables, decision trees and rule flows; A graph creation module, used to create a rule package calling a knowledge graph by using the text rules, the decision table, the decision tree and the rule flow; A sub-package determination module, used to call the knowledge graph according to the rule package to determine at least one sub-rule package; A subset determination module, used for determining the rules containing the same input parameters in the sub-rule package as a rule subset, wherein the rule subset includes at least two rules to be compared; A rule calling module, used to use the same input parameters of any two rules to be compared, call the any two rules to be compared, and obtain two sets of rule output results; A correlation determination module, used to determine the correlation between the output results of the two sets of rules; A post-processing module is used to post-process any two rules to be compared if the correlation is related.
8. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Patent Citations
Rule base generation method and device
CN112347235A
Supply chain supervision rule conflict detection method based on topological sorting and constraint solution
CN118586496A
Knowledge graph-based auditing rule abnormity checking method and device and electronic equipment
CN118673437A
Conflicting rule resolution system
US20080275838A1