[go: up one dir, main page]

CN117827897A - Rule construction method and system based on basic rule and electronic equipment - Google Patents

Rule construction method and system based on basic rule and electronic equipment Download PDF

Info

Publication number
CN117827897A
CN117827897A CN202311580236.2A CN202311580236A CN117827897A CN 117827897 A CN117827897 A CN 117827897A CN 202311580236 A CN202311580236 A CN 202311580236A CN 117827897 A CN117827897 A CN 117827897A
Authority
CN
China
Prior art keywords
rule
basic
parameter
business
logic
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311580236.2A
Other languages
Chinese (zh)
Inventor
郭大勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Tongban Information Service Co ltd
Original Assignee
Shanghai Tongban Information Service Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Tongban Information Service Co ltd filed Critical Shanghai Tongban Information Service Co ltd
Priority to CN202311580236.2A priority Critical patent/CN117827897A/en
Publication of CN117827897A publication Critical patent/CN117827897A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention relates to the technical field of computers and discloses a rule construction method, a rule construction system and electronic equipment based on basic rules. With respect to the method, it comprises: preparing basic rules required for configuring a business rule grammar tree, and carrying out logic processing on the basic rules; custom business rules, wherein the business rules are composed of rule grammar trees; creating a business rule instance by using business rules, wherein one business rule is selected, setting expected values for each parameter according to an expected parameter ordered sequence collected when the business rule is created in the custom business rule, forming a business rule parameter expected value ordered sequence, and binding the selected business rule and the filled parameter expected value sequence with the instance; business rule instances are used. According to the technical scheme, the configuration of a user is facilitated, higher learning cost is not needed, the business rule can be decoupled from the code, and the rule reading data target value can be flexibly configured.

Description

Rule construction method and system based on basic rule and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to a rule construction method, a rule construction system and electronic equipment based on basic rules.
Background
With the increasing proportion of digital construction occupied in various industries, the requirements on data use are also increasing, and it is hoped that data can be used secondarily according to certain dimensions by writing some rules, such as data processing, extraction, conversion and the like. When a measure specifically lands, an existing rule engine framework is generally selected to construct and use data for the rule, and rule engines are generally classified into two types.
One type is a relatively mature rules engine, such as drools; the method has a complete rule using scheme, such as rule making and service code separation, dynamic rule loading, remote analysis rule and the like; but requires learning the syntax of its rule engine and writing the data fields that the rule needs to read in advance in the rule, which is costly for the user to learn and maintain.
Another class is simpler rule engines, such as easylule; the method needs to write the required rules in advance to be embedded into codes, the rules cannot be flexibly expanded, and the writing of the rules is handed to users for configuration.
Therefore, the method is convenient for the user to configure, does not need higher learning cost, and becomes a difficulty in realizing the data comparison rule.
Disclosure of Invention
The application provides a rule construction method, a rule construction system and electronic equipment based on basic rules, and aims to solve the technical problems that a user is inconvenient to configure and learning cost is high in the prior art.
According to an aspect of the present application, an embodiment provides a rule construction method based on a basic rule, including:
preparing basic rules required for configuring a business rule grammar tree, and carrying out logic processing on the basic rules;
the method comprises the steps of customizing a service rule, wherein the service rule is composed of a rule grammar tree, and the rule grammar tree comprises logic nodes and basic rule nodes;
creating a business rule instance by using business rules, wherein one business rule is selected, setting expected values for each parameter according to an expected parameter ordered sequence collected when the business rule is created in the custom business rule, forming a business rule parameter expected value ordered sequence, and binding the selected business rule and the filled parameter expected value sequence with the instance;
business rule instances are used.
In one embodiment, the rule construction method based on the basic rule further includes:
and preparing a data two-dimensional table used by the basic rule, wherein the basic rule reads data in the data table as a second parameter of the basic rule when performing logic operation, and the data two-dimensional table has a table name and a table field.
In one embodiment, the preparing the two-dimensional table of data for use by the base rule includes:
arranging the fields and the field types of the operation of the rules required to be used in the service, and finally arranging all the fields;
creating a data two-dimensional table;
and carrying out data acquisition on the created data two-dimensional table.
In one embodiment, in the service rule using example, according to the bound service rule and parameter expected value sequence, the parameter expected value sequence is taken as input, a rule grammar tree configured by the service rule is analyzed, and arithmetic logic is used for processing to obtain a calculation result.
In one embodiment, the preparing the basic rules required for configuring the business rule syntax tree and performing logic processing on the basic rules includes:
arranging all basic rules required by a rule service system, wherein the basic rules comprise two input parameters, the first input parameter is an expected value, the second input parameter is a target value, and the basic rules comprise at least one of logic greater than, logic less than, logic greater than or equal to and logic less than or equal to;
and according to the sorted basic rules, logic processing is realized, wherein each basic rule serves as a logic calculation unit.
In one embodiment, the usage business rule instance comprises:
according to the business rule and the parameter expected value sequence bound by the business rule instance created by the business rule, analyzing a rule grammar tree configured by the business rule by taking the parameter expected value sequence as input;
traversing the rule grammar tree in a preamble traversing mode, carrying out different logic processing on different node types, recording the number of processed basic rule nodes, and recording by using a parameter count, wherein the initial value of the count is 0, and if one basic rule is processed, the count is plus 1;
if the node type encountered by the traversal is a logic node, continuing to process all the child nodes, returning the processing result true or false of the child node, performing corresponding logical AND, logical OR and logical NOT operation on the logic configured by the child node processing result, and returning the operation result true or false;
if the node type encountered in the traversing is a basic rule node, the count value described in the traversing process is a group index, a value corresponding to a parameter expected sequence is taken and recorded as a parameter 1, a table field value maintained in a data two-dimensional table used for preparing the basic rule is read according to table and field information configured by the basic rule node and recorded as a parameter 2, finally, the basic rule configured by the basic rule node is used, the parameter 1 is taken as an expected value, the parameter 2 is taken as a target value, and the logic calculation unit is called to return a calculation result true or false.
In one embodiment, the custom business rule includes:
determining a grammar tree rule, wherein when a logic node is created, a corresponding logic operation is selected, when a basic rule node is created, one basic rule is required to be selected, and a specific table and a specific field of the data two-dimensional table are selected, and the value of the table field is read as a target value of the basic rule when the rule grammar tree is analyzed;
according to grammar rules, designing a structure of a logic grammar tree, and determining meaning represented by each node and father-son relations among the nodes;
constructing a rule grammar tree according to the determined grammar tree rule and grammar tree structure;
collecting a basic rule expected parameter sequence of the rule grammar tree, traversing all nodes in an advanced traversing mode, and judging the node type in traversing; if the node is a basic rule node, collecting expected parameters of the basic rule configured by the node until all the nodes are traversed; binding the collected expected parameter sequence and the business rule.
According to an aspect of the present application, an embodiment provides a rule building system based on a base rule, including:
the preparation module is used for preparing basic rules required by the configuration business rule grammar tree and carrying out logic processing on the basic rules;
the self-defining module is used for self-defining a service rule, wherein the service rule is composed of a rule grammar tree, and the rule grammar tree comprises logic nodes and basic rule nodes;
the first use module is used for creating a business rule instance by using business rules, wherein one business rule is selected, expected values are set for each parameter according to an expected parameter ordered sequence collected when the business rule is created in the custom business rule, an expected value ordered sequence of the business rule parameter is formed, and the selected business rule and the filled expected value sequence of the parameter are bound with the instance; and
the second use module is used for using the service rule instance, wherein according to the bound service rule and parameter expected value sequence, the parameter expected value sequence is taken as input, a rule grammar tree configured by the service rule is analyzed, and the operation logic is used for processing to obtain a calculation result.
According to an aspect of the present application, an embodiment provides an electronic device, including:
a memory; and
a processor;
wherein the memory is configured to store one or more computer instructions; the one or more computer instructions are executed by the processor to implement a method as described in any of the preceding claims.
According to an aspect of the present application, an embodiment provides a readable storage medium having stored thereon computer instructions; wherein the computer instructions, when executed by a processor, implement a method as described in any of the above.
The embodiment of the application is convenient for the user to configure, does not need higher learning cost, can decouple the business rule from the code, and can flexibly configure the rule to read the data target value. Specifically, by preparing the basic rules, the user dynamically combines the basic rules to form a rule grammar tree with business meaning, thereby realizing specific data use, realizing business rule separation and conveniently constructing business rules.
Drawings
FIG. 1 is a flow diagram of a method of rule construction based on base rules in one embodiment;
FIG. 2 is a flow diagram of a rule building method based on base rules in one embodiment;
FIG. 3 is a visual logic diagram of a business rule syntax tree in one embodiment;
FIG. 4 is a schematic diagram of the processing of the operation logic of step 5 in one embodiment;
FIG. 5 is a schematic diagram of a rule building system based on base rules in one embodiment;
FIG. 6 is a schematic diagram of a rule visualization page in step 1 of embodiment six;
fig. 7 and 8 are schematic diagrams of a visualized page in step 2 of the sixth embodiment;
fig. 9 to 11 are schematic diagrams of the page in step 3 of the sixth embodiment;
fig. 12 and 13 are schematic views of step 4 of the sixth embodiment;
fig. 14 is a schematic diagram of step 5 of the sixth embodiment.
Detailed Description
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
In order to enable those skilled in the art to better understand the present application, the following description will make clear and complete descriptions of the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. It will be apparent that the described embodiments are merely some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, shall fall within the scope of the present application.
It should be noted that the terms "first," "second," and the like herein are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the present application described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It will be understood that when an element such as a layer, film, region, or substrate is referred to as being "on" another element, it can be directly on the other element or intervening elements may also be present. In addition, in the present application, when an element is described as being "connected" to another element, the element may be "directly connected" to the other element or "connected" to the other element through a third element.
Example 1
Referring to fig. 1 and 2, an embodiment provides a rule construction method based on a basic rule, which includes the following steps:
s1, preparing basic rules required by a service rule grammar tree, and carrying out logic processing on the basic rules;
s2, customizing a service rule, wherein the service rule is composed of a rule grammar tree, and the rule grammar tree comprises logic nodes and basic rule nodes;
s3, creating a business rule instance by using business rules, wherein one business rule is selected, according to an expected parameter ordered sequence collected when the business rule is created in the custom business rule, setting an expected value for each parameter to form a business rule parameter expected value ordered sequence, and binding the selected business rule and the filled parameter expected value sequence with the instance;
s4, using a business rule instance.
In one embodiment, the rule construction method based on the basic rule further includes the following steps:
s0. preparing a two-dimensional data table for the basic rule, wherein the basic rule reads data in the data table as a second parameter of the basic rule when performing logic operation, and the two-dimensional data table has a table name and a table field. As an example, step S0 includes the steps of:
s01, arranging fields and field types of the operation of rules required to be used in the service, and finally arranging all the fields;
s02, creating a data two-dimensional table;
s03, data acquisition is carried out on the created data two-dimensional table.
In one embodiment, step S1 comprises the steps of:
s11, arranging all basic rules required by a rule service system, wherein the basic rules comprise two input parameters, the first input parameter is an expected value, the second input parameter is a target value, and the basic rules comprise at least one of logic greater than, logic less than, logic greater than or equal to and logic less than or equal to;
s12, according to the arranged basic rules, logic processing is achieved, wherein each basic rule serves as a logic calculation unit.
In one embodiment, step S2 comprises the steps of:
s21, determining a grammar tree rule, wherein when a logic node is created, a corresponding logic operation is selected, when a basic rule node is created, one basic rule is required to be selected, and a specific table and a field of the data two-dimensional table are selected and used for reading the value of the table field as a target value of the basic rule when the rule grammar tree is analyzed;
s22, designing a structure of a logic grammar tree according to grammar rules, and determining meaning represented by each node and parent-child relations among the nodes;
s23, constructing a rule grammar tree according to the determined grammar tree rule and grammar tree structure;
s24, collecting a basic rule expected parameter sequence of the rule grammar tree, traversing all nodes in an order traversing mode, and judging the node type in the traversing mode; if the node is a basic rule node, collecting expected parameters of the basic rule configured by the node until all the nodes are traversed; binding the collected expected parameter sequence and the business rule.
In one embodiment, in step S4, according to the bound business rule and parameter expected value sequence, the parameter expected value sequence is taken as input, a rule syntax tree configured by the business rule is analyzed, and the arithmetic logic processes to obtain a calculation result. As an example, step S4 includes the steps of:
s41, analyzing a rule grammar tree configured by the service rule by taking the parameter expected value sequence as input according to the service rule and the parameter expected value sequence bound by the service rule instance created by the service rule;
s42, traversing the rule grammar tree in a preamble traversing mode, carrying out different logic processing on different node types, recording the number of processed basic rule nodes, and recording by using a parameter count, wherein the initial value of the count is 0, and when one basic rule is processed, the count is +1;
s43, if the node type encountered by traversal is a logic node, continuing to process all the child nodes, returning the processing result true or false of the child node, performing corresponding logical AND, logical OR and logical NOT operation on the logic configured by the child node processing result, and returning the operation result true or false;
s44, if the node type encountered by traversing is a basic rule node, the count value described in the traversing process is a plurality of subscripts, a value corresponding to a parameter expected sequence is taken and recorded as a parameter 1, a table field value maintained in the data two-dimensional table used for preparing the basic rule is read and recorded as a parameter 2 according to table and field information configured by the basic rule node, finally the basic rule configured by the basic rule node is used, the parameter 1 is taken as an expected value, the parameter 2 is taken as a target value, and the logic calculation unit is called to return a calculation result true or false.
According to the rule construction method based on the basic rule, the basic rule is prepared, and the user dynamically combines the basic rule to form the rule grammar tree with business meaning, so that specific data use is realized, business rule separation is realized, and the business rule is conveniently constructed.
Example two
Referring to fig. 1 and 2, an embodiment provides a rule construction method based on a basic rule, which includes the following steps:
1. preparing a two-dimensional table of data for use by the underlying rules
In general, when a base rule performs a logical operation, data in a data table is read as a second parameter of the base rule, and a two-dimensional table has a table name and a plurality of table fields.
In detail. Step 1 comprises the following steps:
1.1: the fields and field types, such as field a, which are used for operation according to rules in the arrangement service, are character strings, and all fields, such as a, b, c, d, e, f, g, are finally arranged;
1.2: creating a data two-dimensional table;
1.3: and (3) data acquisition, namely performing data acquisition on the created two-dimensional table, wherein the acquisition result is shown in table 1.
a b c d e f g
1 2 3 4 5 6 7
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
List one
2. Preparing basic rules
In general, basic rules required for configuring a business rule syntax tree are prepared and logically implemented. The basic rule has two input parameters, wherein the first input parameter is an expected value, the second input parameter is a target value, and each basic rule is a logic calculation unit.
In detail. Step 2 comprises the following steps:
2.1: arranging all basic rules required by a rule service system, wherein the basic rules comprise two input parameters, the first input parameter is an expected value, the second input parameter is a target value, and the basic rules comprise logic greater than, logic less than, logic greater than or equal to, logic less than or equal to and the like;
2.2: according to the sorted basic rules, logic processing is realized, and each basic rule serves as a logic calculation unit.
3. Custom business rules
In general, business rules are composed of a rule syntax tree, including logical nodes and base rule nodes. The logical nodes are non-leaf nodes and comprise three types of logical AND (and), logical OR (or) and logical NOT (not). The basic rule node is a leaf node; the basic rule node needs to configure a basic rule and a two-dimensional table and fields taken by the basic rule target value, after the rule grammar tree configuration is completed, the business rule grammar tree is traversed in a preface traversing mode, and expected parameters required by the basic rule configured by the leaf node are collected to form an expected parameter ordered sequence.
In detail. Step 3 comprises the following steps:
3.1: determining a grammar tree rule, wherein the grammar tree is composed of two types of nodes, a logic node and a basic rule node. When creating the logic node, the corresponding logic operation including operation and (and), or and non-operation is needed, when creating the basic rule node, the basic rule created by the step 2 is needed to be selected, and the specific table and field created by the step 1 are selected for reading the value of the table field as the target value of the basic rule when analyzing the rule grammar tree;
3.2: designing a grammar tree structure, designing a structure of a logic grammar tree according to grammar rules, determining meaning represented by each node and parent-child relations among the nodes, and representing the nodes by using a directed graph;
3.3: constructing a grammar tree, and constructing a business rule grammar tree according to the determined grammar tree rule and grammar tree structure, wherein a visual logic diagram is shown in fig. 3;
3.4: and collecting a basic rule expected parameter sequence of the rule grammar tree, traversing all the nodes in an advanced traversing mode, judging the node type in the traversing mode, and collecting expected parameters of a basic rule configured by the node if the node is a basic rule node. Until all nodes are traversed, the ordered sequence of expected parameters finally collected by the rule syntax tree shown in fig. 3 is: and binding the collected expected parameter sequences with the business rules by the expected parameter sequences of the A, B, C, D, E, F and G basic rules.
4. Creating business rule instances
In general, a business rule instance is created by using a business rule, a certain business rule is selected, expected values are set for each parameter according to the expected parameter ordered sequence collected when the business rule is created in the step 3, a business rule parameter expected value ordered sequence is formed, and the selected business rule and the filled parameter expected value ordered sequence are bound with the instance.
In detail. Step 4 comprises the steps of:
4.1: when a business rule instance is created, selecting the business rule created in the step 3, and filling expected values for each expected parameter according to an expected parameter sequence of the business rule;
4.2: binding the business rule instance with the selected business rule and the filled parameter expected value sequence.
5. Using business rule instances
In general, in the rule instance use, according to the service rule and the parameter expected value sequence bound with the rule instance use, the parameter expected value sequence is taken as an input parameter, and the rule grammar tree configured by the service rule is traversed in an advanced manner; if the encountered node is a logic node, continuing traversing the child node, and returning a processing result true or false; then, carrying out logical AND, logical OR and logical NOT processing on the returned result, and returning a processing result true or false; if the encountered node is a leaf node, reading a corresponding field value of a corresponding table as a target value according to the configured basic rule information, selecting a value of a corresponding ordered parameter expected value sequence as an expected value, calling the logic operation of the basic rule, and returning a calculation result true or false until all the nodes are processed; and returning a processing result true or false.
In detail. Step 5 comprises the steps of:
5.1: when a specific service rule example is used, according to the service rule and the parameter expected value sequence bound by the service rule example maintained in the step 4, analyzing a rule grammar tree configured by the service rule by taking the parameter expected value sequence as input, and processing the arithmetic logic as shown in figure 4;
5.2: traversing the rule grammar tree in a preamble traversing mode, carrying out different logic processing on different node types, recording the number of processed basic rule nodes, recording by using a parameter count, wherein the initial value of the count is 0, and counting+1 when one basic rule is processed;
5.3: if the node type encountered by the traversal is a logic node, continuing to process all the child nodes, returning the processing result true or false of the child node, performing corresponding logical AND, logical OR and logical NOT operation on the logic configured by the child node processing result, and returning the operation result true or false;
5.4: if the node type encountered by traversal is a basic rule node, taking a value corresponding to a parameter expected sequence as a parameter 1 according to a count value described in the step 5.2 as a group index, reading a table field value maintained in the step 1 as a parameter 2 according to a table and field information configured by the basic rule node, finally using a basic rule configured by the basic rule node, taking the parameter 1 as an expected value, taking the parameter 2 as a target value, calling a basic rule logic calculation unit realized in the step 2.2, and returning a calculation result true or false.
According to the rule construction method based on the basic rule, the basic rule is prepared, and the user dynamically combines the basic rule to form the rule grammar tree with business meaning, so that specific data use is realized, business rule separation is realized, and the business rule is conveniently constructed.
Example III
Referring to fig. 5, based on the same inventive concept, an embodiment of the present application provides a rule building system based on basic rules, which takes the following form:
1. preparation Module 10
The preparation module 10 is configured to prepare basic rules required for configuring the business rule syntax tree and perform logic processing on the basic rules.
2. Custom module 20
The customization module 20 is configured to customize a service rule, where the service rule is composed of a rule syntax tree, and the rule syntax tree includes a logical node and a base rule node.
3. First usage module 30
The first usage module 30 is configured to create a business rule instance using business rules, wherein one business rule is selected, and according to an expected parameter ordered sequence collected when creating a business rule in the custom business rule, an expected value is set for each parameter to form a business rule parameter expected value ordered sequence, and the selected business rule and the filled parameter expected value sequence are bound with the instance.
4. Second usage module 40
The second usage module 40 is configured to use a service rule instance, wherein, according to the bound service rule and parameter expected value sequence, the parameter expected value sequence is taken as input, a rule syntax tree configured by the service rule is analyzed, and arithmetic logic processes to obtain a calculation result.
The modules of the rule constructing system based on the basic rule have a one-to-one correspondence relationship with the steps of the rule constructing method based on the basic rule in the above embodiment, and will not be described again.
Example IV
Based on the same inventive concept, an embodiment of the present application provides an electronic device, including: a memory and a processor; wherein the memory is configured to store one or more computer instructions; the one or more computer instructions are executable by the processor to perform the base rule-based rule construction method according to any one of the various embodiments described above.
Wherein the one or more computer instructions may be formed as a program.
Example five
Based on the same inventive concept, one embodiment of the present application provides a readable storage medium having computer instructions stored thereon; the computer instructions, when executed by a processor, implement the rule construction method based on a base rule according to any one of the above embodiments.
Wherein the one or more computer instructions may be formed as a program.
The above-described programs may be run on a processor or may also be stored in memory (or referred to as computer-readable media), including both permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technique. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD, -RO digital M-word) versatile discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
These computer programs may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks and/or block diagram block or blocks, and corresponding steps may be implemented in different modules.
Example six
Referring to fig. 6-14, one embodiment provides a rule construction method for user portrayal based on basic rules. Namely, the embodiment provides a method for carrying out user portrayal based on rule construction of basic rules. Wherein, the rule constructing method based on the basic rule can be selected from the above embodiments.
User portrayal refers to building labels according to certain dimensions, such as: such as labels for adults, minors, students, teachers, etc. A certain rule is described in the label for judging whether the user accords with the label; and associating the labels which are met by the user with the user through a certain mechanism, namely, the user portrait. Wherein, the mechanism of user portrayal can be divided into a timed task reading population database data informative person to carry out user portrayal; or when the user logs in a website, the user is triggered to read data from the population library and perform user portrait.
In an example, to achieve this goal, users and related policies need to be labeled with corresponding labels to recommend different, highly relevant data to different users when they log in. To achieve this goal, it is critical to the representation of the user, which is the keystone that implements the user data recommendation.
And implementing user portrayal on the user by using a rule construction method based on the basic rule. Firstly, sorting the types of user portrait labels according to the research of requirements, and abstracting out the required business rules; further abstracting basic rules required by the business rules according to the business rules; the Java language is selected to realize the basic rule; the relevant rules are subjected to structured json description and stored according to the requirements of visual configuration and maintenance rules and labels required by companies, and corresponding pages can be constructed according to the description structures when the specific use rules are provided; after writing specific basic rules, selecting the specific basic rules to create business rules with business meanings; finally creating a label, selecting a corresponding business rule and filling in a corresponding expected parameter to be used as a calculation rule whether a user accords with the label; and finally, reading the data of the population library through a user login or timing task, and correlating the label which accords with the calculation with the user as input for calculating the expected value of the label so as to realize the user portrait.
The specific implementation steps are as follows:
1. determining basic rules and implementing logic
If a minor label is to be made, i.e. less than 18 years old, the age-age field of the userInfo in the user information table in the mouth library is used for calculation. According to the information, the judgment of age can be obtained, and digital comparison is needed, so that a basic rule digital comparison can be abstracted, the basic rule digital comparison is recorded as a number greater than or equal to number groterOrequals, the basic rule needs a function expected parameter and a population database data parameter, and the rule is realized by using java language. Such as:
the rule visualizes the page as in fig. 6.
2. Constructing a two-dimensional table of data
And reading the age field age when the population library user information table userInfo is used as a data two-dimensional table for specific rules. Because visual knowledge about the table is required in this project, the demographic library information table is described by json description and the data is written into the database. Such as:
the page is visualized as in fig. 7 and 8.
3. Determining business rule grammar rule definitions
The grammar tree is an operation taking logical nodes (and), or (or) and non (not) as non-leaf nodes as the logical relations of child nodes, and the leaf nodes are judgment fields for configuring specific judgment rules and use. The structure is as follows:
because the grammar tree needs to be configured in a visual way, according to the grammar definition of the grammar tree, rules of the grammar tree are configured and created (adult Shanghai city residents or graminers) through pages (shown in fig. 9-11), the grammar tree is analyzed when the rules are stored, expected parameter sequences required by all basic functions of the configuration are obtained, and the expected parameters are bound to the business rules for filling in the specific business rule examples.
4. Creating portrait labels
The method includes the steps of taking a label as a service rule example, creating the label, configuring related service rules and expected parameters, creating a label (can handle Shanghai resident certificate labels), and taking adult Shanghai residents or graminers as judgment rules, wherein parameter sequences needing to be filled are of ages and regions and cultural degrees of household registering. As shown in fig. 12 and 13.
5. Using business rule examples
Namely, portrait is carried out on the person, and labels conforming to the business rules are marked. When a person logs in, reading all configured portrait labels, analyzing service rules and expected parameter sequences used by the portrait labels, and traversing and analyzing each node according to a service rule grammar tree. If the encountered node is a logic node, performing corresponding logic operation; if the encountered node is a leaf node, the information of the person is read according to the configured table and the field and is compared with the expected parameter, and finally a calculation result is returned; if the return value is true, the person is marked with a response tag. As shown in fig. 14.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the same, but rather, various modifications and variations may be made by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims (10)

1. A rule construction method based on basic rules, comprising:
preparing basic rules required for configuring a business rule grammar tree, and carrying out logic processing on the basic rules;
the method comprises the steps of customizing a service rule, wherein the service rule is composed of a rule grammar tree, and the rule grammar tree comprises logic nodes and basic rule nodes;
creating a business rule instance by using business rules, wherein one business rule is selected, setting expected values for each parameter according to an expected parameter ordered sequence collected when the business rule is created in the custom business rule, forming a business rule parameter expected value ordered sequence, and binding the selected business rule and the filled parameter expected value sequence with the instance;
business rule instances are used.
2. The rule construction method based on the basic rule according to claim 1, wherein the rule construction method based on the basic rule further comprises:
and preparing a data two-dimensional table used by the basic rule, wherein the basic rule reads data in the data table as a second parameter of the basic rule when performing logic operation, and the data two-dimensional table has a table name and a table field.
3. The rule building method based on the basic rule according to claim 2, wherein the preparing the two-dimensional table of data used by the basic rule includes:
arranging the fields and the field types of the operation of the rules required to be used in the service, and finally arranging all the fields;
creating a data two-dimensional table;
and carrying out data acquisition on the created data two-dimensional table.
4. The rule construction method based on basic rules according to claim 2, wherein in the service rule case, according to the bound service rule and parameter expected value sequence, the parameter expected value sequence is taken as input, a rule syntax tree configured by the service rule is analyzed, and the calculation logic processes to obtain a calculation result.
5. The rule construction method based on the basic rule according to claim 2, wherein preparing the basic rule required for configuring the business rule syntax tree and performing logic processing on the basic rule comprises:
arranging all basic rules required by a rule service system, wherein the basic rules comprise two input parameters, the first input parameter is an expected value, the second input parameter is a target value, and the basic rules comprise at least one of logic greater than, logic less than, logic greater than or equal to and logic less than or equal to;
and according to the sorted basic rules, logic processing is realized, wherein each basic rule serves as a logic calculation unit.
6. The rule building method based on basic rules according to claim 5, wherein the usage business rule instance comprises:
according to the business rule and the parameter expected value sequence bound by the business rule instance created by the business rule, analyzing a rule grammar tree configured by the business rule by taking the parameter expected value sequence as input;
traversing the rule grammar tree in a preamble traversing mode, carrying out different logic processing on different node types, recording the number of processed basic rule nodes, and recording by using a parameter count, wherein the initial value of the count is 0, and if one basic rule is processed, the count is plus 1;
if the node type encountered by the traversal is a logic node, continuing to process all the child nodes, returning the processing result true or false of the child node, performing corresponding logical AND, logical OR and logical NOT operation on the logic configured by the child node processing result, and returning the operation result true or false;
if the node type encountered in the traversing is a basic rule node, the count value described in the traversing process is a group index, a value corresponding to a parameter expected sequence is taken and recorded as a parameter 1, a table field value maintained in a data two-dimensional table used for preparing the basic rule is read according to table and field information configured by the basic rule node and recorded as a parameter 2, finally, the basic rule configured by the basic rule node is used, the parameter 1 is taken as an expected value, the parameter 2 is taken as a target value, and the logic calculation unit is called to return a calculation result true or false.
7. The rule construction method based on the basic rule according to claim 2, wherein the custom business rule comprises:
determining a grammar tree rule, wherein when a logic node is created, a corresponding logic operation is selected, when a basic rule node is created, one basic rule is required to be selected, and a specific table and a specific field of the data two-dimensional table are selected, and the value of the table field is read as a target value of the basic rule when the rule grammar tree is analyzed;
according to grammar rules, designing a structure of a logic grammar tree, and determining meaning represented by each node and father-son relations among the nodes;
constructing a rule grammar tree according to the determined grammar tree rule and grammar tree structure;
collecting a basic rule expected parameter sequence of the rule grammar tree, traversing all nodes in an advanced traversing mode, and judging the node type in traversing; if the node is a basic rule node, collecting expected parameters of the basic rule configured by the node until all the nodes are traversed; binding the collected expected parameter sequence and the business rule.
8. A rule building system based on basic rules, comprising:
the preparation module is used for preparing basic rules required by the configuration business rule grammar tree and carrying out logic processing on the basic rules;
the self-defining module is used for self-defining a service rule, wherein the service rule is composed of a rule grammar tree, and the rule grammar tree comprises logic nodes and basic rule nodes;
the first use module is used for creating a business rule instance by using business rules, wherein one business rule is selected, expected values are set for each parameter according to an expected parameter ordered sequence collected when the business rule is created in the custom business rule, an expected value ordered sequence of the business rule parameter is formed, and the selected business rule and the filled expected value sequence of the parameter are bound with the instance; and
the second use module is used for using the service rule instance, wherein according to the bound service rule and parameter expected value sequence, the parameter expected value sequence is taken as input, a rule grammar tree configured by the service rule is analyzed, and the operation logic is used for processing to obtain a calculation result.
9. An electronic device, comprising:
a memory; and
a processor;
wherein the memory is configured to store one or more computer instructions; the one or more computer instructions being executable by the processor to implement the method of any one of claims 1 to 7.
10. A readable storage medium having stored thereon computer instructions; wherein the computer instructions, when executed by a processor, implement the method of any of claims 1 to 7.
CN202311580236.2A 2023-11-24 2023-11-24 Rule construction method and system based on basic rule and electronic equipment Pending CN117827897A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311580236.2A CN117827897A (en) 2023-11-24 2023-11-24 Rule construction method and system based on basic rule and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311580236.2A CN117827897A (en) 2023-11-24 2023-11-24 Rule construction method and system based on basic rule and electronic equipment

Publications (1)

Publication Number Publication Date
CN117827897A true CN117827897A (en) 2024-04-05

Family

ID=90512202

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311580236.2A Pending CN117827897A (en) 2023-11-24 2023-11-24 Rule construction method and system based on basic rule and electronic equipment

Country Status (1)

Country Link
CN (1) CN117827897A (en)

Similar Documents

Publication Publication Date Title
US8930919B2 (en) Modernization of legacy software systems based on modeled dependencies
CN105335412A (en) Method and device for data conversion and data migration
CN109740122A (en) Method and device for converting mind map use case files
Zanoni et al. Pattern detection for conceptual schema recovery in data‐intensive systems
CN111708760B (en) Model migration deployment method, device, electronic equipment and storage medium
Cano et al. Quality Control with R
CN110019111A (en) Data processing method, device, storage medium and processor
CN103646049A (en) Method and system for automatically generating data report
CN112463149A (en) Software-defined satellite-oriented reusable code library construction method and device
US20200151582A1 (en) Ascriptive and descriptive entities for process and translation: a limited iterative ontological notation
CN116089275A (en) Database test method, database system, electronic device, and storage medium
CN103049494B (en) Method and device for storing table of extensible markup language (XML) file
George Practical data science with Python: learn tools and techniques from hands-on examples to extract insights from data
Reekie et al. A software architecture primer
CN101814064B (en) Report template creating method, report generating method and report system
CN117827897A (en) Rule construction method and system based on basic rule and electronic equipment
CN102486731A (en) Method, device and system for enhancing visualization of software call stack of software
Tufek et al. On the provenance extraction techniques from large scale log files
CN117874118A (en) Feature data conversion method, device, electronic equipment and readable storage medium
CN117492756A (en) Front-end design method and device for draggable forms and lists of low-code platform
Srikantaiah et al. Knowledge management in practice: connections and context
CN103577533B (en) Open network computing system
Barlas et al. Extending standards with formal methods: Open document architecture
Patten et al. Geographic And Taxonomic Occurrence R‐based Scrubbing (gatoRs): An R package and workflow for processing biodiversity data
Zhang et al. Solutions to All‐Colors Problem on Graph Cellular Automata

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination