CN115167826B - Method and device for realizing Chinese business rule engine, server side and storage medium - Google Patents

Method and device for realizing Chinese business rule engine, server side and storage medium Download PDF

Info

Publication number
CN115167826B
CN115167826B CN202210592375.6A CN202210592375A CN115167826B CN 115167826 B CN115167826 B CN 115167826B CN 202210592375 A CN202210592375 A CN 202210592375A CN 115167826 B CN115167826 B CN 115167826B
Authority
CN
China
Prior art keywords
rule
chinese
action
library
model
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.)
Active
Application number
CN202210592375.6A
Other languages
Chinese (zh)
Other versions
CN115167826A (en
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.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN202210592375.6A priority Critical patent/CN115167826B/en
Publication of CN115167826A publication Critical patent/CN115167826A/en
Application granted granted Critical
Publication of CN115167826B publication Critical patent/CN115167826B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Machine Translation (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method and a device for realizing a Chinese business rule engine, a server and a storage medium, wherein the method is applied to the server and comprises the following steps: pre-constructing a Chinese business rule mode, a rule guiding word library and a Chinese object model library; receiving Chinese business rules written according to a Chinese business rule mode, checking the Chinese business rules by using a Chinese rule engine, converting Chinese names into English names of the checked Chinese business rules, splicing the converted English names into corresponding sentences, and storing the English names in an English form; a rule set is formed by utilizing a plurality of Chinese business rules and is linked to an event, so that a Chinese business rule engine is called through the event, and when the event is triggered, the rule set is called for calculation so as to directly convert the rule set into a computer executable code and return a result. The invention omits the process of developing service logic by programmers, and effectively improves service efficiency.

Description

Method and device for realizing Chinese business rule engine, server side and storage medium
Technical Field
The present invention relates to the technical field of chinese business rule engines, and in particular, to a method and apparatus for implementing a chinese business rule engine, a server side, and a storage medium.
Background
The business rule engine is developed by the reasoning engine, is a component embedded in the business system, writes business rules through predefined semantics, receives input business data, and makes corresponding decisions according to the business rules. The business rule engine is used for releasing complex and changeable business rules from the system codes, and storing the business rules into files or specific storage media (such as a database) in the form of rule scripts, so that the change of the business rules can be immediately effective in an online environment without modifying the codes or restarting a server.
Most of the rule generation methods adopted by the existing rule engines describe rules based on the frames and grammar of programming languages, generally require rule editors to have higher software technical knowledge, and also require rule editors to be familiar with related grammar and algorithm principles and to know related program variable meanings so as to understand and configure the rules, and common business personnel generally do not have the technical capabilities, and the obtained rule contents are still not friendly and intuitive enough for the common business personnel.
Such rule generating methods need to directly call data objects in system codes, for example, open source rule engine Drools developed based on Java language, and usually need to use programs to create entity class objects when rule writing is performed, the attributes of the entity class objects are difficult to dynamically change, and the creation and maintenance of the entity class objects need to be completed by personnel with software development capability; the grammar of the Drools built-in language is mainly compatible with Java grammar, and has high learning cost although the language is easy to compile and execute.
Moreover, because the current rule engine is basically based on English environment, the words and grammar in the Chinese are not friendly, the formed rules are very different from natural language, and common business personnel are difficult to independently complete the rule programming work. In addition, current rule engines lack the necessary classification, dimension, and conflict checking.
Disclosure of Invention
Based on the above-mentioned current situation, the main objective of the present invention is to provide a method and apparatus for implementing a chinese business rule engine, a server, and a storage medium, so as to overcome the above-mentioned drawbacks in the background art.
In a first aspect, the present invention provides a method for implementing a chinese business rule engine, applied to a server, including the steps of:
S100, a Chinese business rule mode, a rule guiding word stock and a Chinese object model library are built in advance, wherein the Chinese business rule mode is a rule mode conforming to a Chinese grammar format, and rule content comprises a condition part and an action part so as to describe the activity and/or the relation of the object model; the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part; the Chinese object model library comprises a plurality of object models, and each object model comprises a plurality of attributes and methods;
s200, receiving Chinese business rules written according to the Chinese business rule mode, and checking the received Chinese business rules by using a Chinese rule engine, wherein the checking comprises dividing the Chinese business rules into conditional sentences and action sentences by using preset keywords, respectively processing the conditional sentences and the action sentences to form a conditional set and an action set, and judging the legality of the conditional set and the action set; then, converting the Chinese name into English name according to the Chinese business rule after the verification is successful, splicing the converted English name into a corresponding sentence, and storing in an English form;
S300, forming a rule set by utilizing a plurality of Chinese business rules, and linking the rule set into an event so as to call a Chinese business rule engine through the event; and when the event is triggered, calling the rule set to calculate so as to directly convert the rule set into computer executable codes and returning a result.
Preferably, in the step S100, a model action library is further constructed in advance, and the model action library includes a plurality of first functions, each first function is used for associating with one object model, so that the first functions operate on the associated object model.
Preferably, in the step S100, a dictionary model library is further constructed in advance, and the dictionary model library includes a plurality of dictionaries, and the dictionaries include information item keys and information item values; when the data type of a certain attribute of the object model is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model library.
Preferably, in the step S100, a dimension model library is further constructed in advance, the dimension model library includes a plurality of dimensions, and the dimensions include a plurality of units and conversion relationships therebetween; when the data type of a certain attribute of the object model is set as a numerical value type, the attribute is associated with a certain dimension in the dimension model library.
Preferably, in the step S200, determining validity of the condition set and the action set includes performing semantic checking on the rule, and specifically includes: it is checked whether the rule-guided words are used correctly, whether object models, attributes and/or associated function models exist, whether the data types of the attributes and function models agree, whether the literal quantity assignment and the dictionary model agree, and whether the literal quantity assignment includes a dimension model.
Preferably, in the step S300, after linking the rule set to an event, a conflict check is performed on each rule linked to the event, if there is conflict content, the conflict content is prompted and the user is prompted to revise the rule, and if there is no conflict content, the rule is maintained in english form in the database.
Preferably, the collision check includes:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not null and the action part of the first rule and the action part of the second rule are identical, or if the conditional part of the first rule and the conditional part of the second rule are identical and the intersection of the action part of the first rule and the action part of the second rule is not null, the first rule and the second rule are in a partial inclusion relationship;
If the condition part of the first rule and the condition part of the second rule are partially or completely identical, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
repeating the steps until the conflict check of all rules is completed.
Preferably, in the step S300, the event includes, but is not limited to, the following scenarios: such as page refreshed, button pressed, form submitted, form flow completed, or timing of system control.
Preferably, in the step S300, the calculating includes: firstly checking rules to ensure the correctness and the validity of the rules, initializing input data after the rules pass, transmitting the input data to a model, compiling the processed rule content into a program language or directly transmitting the compiled code as the input data, injecting the processed input data into the compiled code as input parameters, and returning the result.
Preferably, in the step S300, the calculating further includes: after the initialization processing of the input data is completed, performing classification relation processing, wherein the classification relation processing comprises the following steps: if the parent class is referenced in the rule, classification loop checking can be performed on all child pairs until all child data checking is completed.
Preferably, in the step S100, a dimension model library is pre-constructed, and when the data type of a certain attribute of the object model is set to be a numerical type, the attribute is associated with a certain dimension in the dimension model library;
in the step S300, the calculating further includes: after the initialization processing of the input data is completed, dimension processing is performed, the dimension processing including: and unifying all the dimensions of the variables to the standard units of the dimensions, and recording the original dimension units of the variables.
In a second aspect, the present invention provides an implementation apparatus of a chinese business rule engine, including:
the system comprises a library and rule pattern construction module, a rule guide word library and a Chinese object model library, wherein the library and rule pattern construction module is used for constructing a Chinese business rule pattern, a rule guide word library and a Chinese object model library in advance, the Chinese business rule pattern is a rule pattern conforming to a Chinese grammar format, and rule contents comprise a condition part and an action part so as to describe activities and/or relations of the object model; the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part; the Chinese object model library comprises a plurality of object models, and each object model comprises a plurality of attributes and methods;
The verification and Chinese-English conversion module is used for receiving Chinese business rules written according to the Chinese business rule mode, verifying the received Chinese business rules by utilizing a Chinese rule engine, wherein the verification comprises the steps of dividing the Chinese business rules into conditional sentences and action sentences by utilizing preset keywords, respectively processing the conditional sentences and the action sentences to form a conditional set and an action set, and judging the legality of the conditional set and the action set; then, converting the Chinese name into English name according to the Chinese business rule after the verification is successful, splicing the converted English name into a corresponding sentence, and storing in an English form;
the event linking and calculating module is used for forming a rule set by utilizing a plurality of Chinese business rules, and linking the rule set into an event so as to call a Chinese business rule engine through the event; and when the event is triggered, calling the rule set to calculate so as to directly convert the rule set into computer executable codes and returning a result.
Preferably, the library and rule pattern construction module is further configured to pre-construct a model action library, where the model action library includes a plurality of first functions, each of the first functions being configured to associate with an object model, so that the first functions operate on the object model associated therewith.
Preferably, the library and rule pattern construction module is further configured to construct a dictionary model library in advance, where the dictionary model library includes a plurality of dictionaries, and the dictionaries include information item keys and information item values; when the data type of a certain attribute of the object model is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model library.
Preferably, the library and rule pattern construction module is further configured to pre-construct a dimension model library, where the dimension model library includes a plurality of dimensions, and the dimensions include a plurality of units and conversion relationships therebetween; when the data type of a certain attribute of the object model is set as a numerical value type, the attribute is associated with a certain dimension in the dimension model library.
Preferably, the verifying and Chinese-English converting module includes performing semantic checking on the rule when judging validity of the condition set and the action set, and specifically includes: it is checked whether the rule-guided words are used correctly, whether object models, attributes and/or associated function models exist, whether the data types of the attributes and function models agree, whether the literal quantity assignment and the dictionary model agree, and whether the literal quantity assignment includes a dimension model.
Preferably, after the rule set is linked to an event, the event linking and calculating module further performs conflict checking on each rule linked to the event, if conflict content exists, prompts the conflict content and prompts a user to revise the rule, and if conflict content does not exist, the rule is kept in the database in an English form.
Preferably, the collision check includes:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not null and the action part of the first rule and the action part of the second rule are identical, or if the conditional part of the first rule and the conditional part of the second rule are identical and the intersection of the action part of the first rule and the action part of the second rule is not null, the first rule and the second rule are in a partial inclusion relationship;
if the condition part of the first rule and the condition part of the second rule are partially or completely identical, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
Repeating the steps until the conflict check of all rules is completed.
Preferably, the event includes a page being refreshed, a button being pressed, a form being submitted, a form flow being completed, or a timed start task of system control.
Preferably, the event linking and calculating module performs calculation in a manner including: firstly checking rules to ensure the correctness and the validity of the rules, initializing input data after the rules pass, transmitting the input data to a model, compiling the processed rule content into a program language or directly transmitting the compiled code as the input data, injecting the processed input data into the compiled code as input parameters, and returning the result.
Preferably, the manner of calculating by the event link and calculation module further includes: after the initialization processing of the input data is completed, performing classification relation processing, wherein the classification relation processing comprises the following steps: if the parent class is referenced in the rule, classification loop checking can be performed on all child pairs until all child data checking is completed.
Preferably, the library and rule pattern construction module is further configured to pre-construct a dimension model library, and when a data type of a certain attribute of the object model is set to be a numerical type, associate the attribute with a certain dimension in the dimension model library;
The event link and the calculation module further calculate in a manner that: after the initialization processing of the input data is completed, dimension processing is performed, the dimension processing including: and unifying all the dimensions of the variables to the standard units of the dimensions, and recording the original dimension units of the variables.
In a third aspect, the present invention provides a server,
comprises a processor; and
a memory having stored thereon a computer program which, when executed by the processor, is capable of implementing a method as described above.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon a computer program for execution to perform a method as described above.
The method for realizing the Chinese business rule engine directly converts the rules similar to Chinese rule language into the executable codes of the computer through the guide word library and the object model library which form the rule content, and the automatic conversion omits the process of developing business logic of programmers, so that business personnel can directly obtain the final operation result of writing the business logic.
Other advantages of the present invention will be set forth in the description of specific technical features and solutions, by which those skilled in the art should understand the advantages that the technical features and solutions bring.
Drawings
The above and other objects, features and advantages of the present invention will become more apparent from the following description of embodiments of the present invention with reference to the accompanying drawings, in which:
FIG. 1 is a flow chart of a method for implementing a Chinese business rules engine according to one embodiment of the present invention;
fig. 2 is a schematic diagram of an implementation apparatus of a chinese business rule engine according to an embodiment of the present invention.
Detailed Description
The present invention is described below based on examples, but the present invention is not limited to only these examples. In the following detailed description of the present invention, certain specific details are set forth in order to avoid obscuring the present invention, and in order to avoid obscuring the present invention, well-known methods, procedures, flows, and components are not presented in detail.
Moreover, those of ordinary skill in the art will appreciate that the drawings are provided herein for illustrative purposes and that the drawings are not necessarily drawn to scale.
Unless the context clearly requires otherwise, throughout the description and the claims, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is, it is the meaning of "including but not limited to".
In the description of the present invention, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. Furthermore, in the description of the present invention, unless otherwise indicated, the meaning of "a plurality" is two or more.
It should be noted that step numbers (letter or number numbers) are used in the present invention to refer to certain specific method steps for convenience and brevity only, and are not intended to limit the order of the method steps by letter or number in any way. It will be apparent to those skilled in the art that the sequence of the steps of the relevant method should be determined by the technique itself and should not be unduly limited by the presence of step numbers.
In a first aspect, referring to fig. 1, fig. 1 is a flowchart of an implementation method for a chinese business rule engine according to an embodiment of the present invention, where the rule engine implementation method is applied to a server, and includes:
s100, a Chinese business rule mode, a rule guiding word stock and a Chinese object model library are built in advance, wherein the Chinese business rule mode is a rule mode conforming to a Chinese grammar format, and rule content comprises a condition part and an action part so as to describe the activity and/or the relation of the object model; the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part; the Chinese object model library comprises a plurality of object models, and each object model comprises a plurality of attributes and methods;
S200, receiving Chinese business rules written according to the Chinese business rule mode, and checking the received Chinese business rules by using a Chinese rule engine, wherein the checking comprises dividing the Chinese business rules into conditional sentences and action sentences by using preset keywords, respectively processing the conditional sentences and the action sentences to form a conditional set and an action set, and judging the legality of the conditional set and the action set; then, converting the Chinese name into English name according to the Chinese business rule after the verification is successful, splicing the converted English name into a corresponding sentence, and storing in an English form;
s300, forming a rule set by utilizing a plurality of Chinese rules, and linking the rule set into an event so as to call a Chinese rule engine through the event; and when the event is triggered, calling the rule set to calculate so as to directly convert the rule set into computer executable codes and returning a result.
The method for realizing the Chinese business rule engine directly converts the rules similar to Chinese rule language into the executable codes of the computer through the guide word library and the object model library which form the rule content, and the automatic conversion omits the process of developing business logic of programmers, so that business personnel can directly obtain the final operation result of writing the business logic.
Specifically, in step S100, the present invention constructs a chinese business rule pattern, a rule guiding word library and a chinese object model library, which conform to the chinese grammar characteristics, so as to facilitate the business personnel to grasp.
Regarding chinese business rules, the rule content of which includes a condition part and an action part, may be written in a predefined semantic format to describe the activities and/or relationships of the first object model and/or the second object model. Specifically, the predefined grammar format takes { if } < condition > { then } < action > as the principal form;
to reduce the conditional expression statement, a { if }, a { when } complex condition may also be set:
{ if } < Condition 1 ]
{ when } < condition 2> { then } < action 1>
{ when } < condition 3> { then } < action 2>
That is, since the format requirements of the chinese rules engine are relatively fixed, the format of the chinese business rules can only be either format 1 or format 2:
format 1:
{ if } < condition > { then } < action >
Format 2:
{ if } < Condition 1 ]
{ when } < condition 2> { then } < action 1>
{ when } < condition 3> { then } < action 2>
It will be appreciated by those skilled in the art that the conditions in format 1 AND format 2 described above for the chinese business rules may be a combination of a plurality of specific condition clauses, for example, the form of < condition > in format 1 may be < expression 1> { AND } < expression 2> { AND } < expression 3>, where { AND } ({ AND }) is used to represent an intersection operation, AND { AND } may also be replaced with { OR } ({ OR }) is used to represent a union calculation, thereby enabling a determination that a plurality of conditions are satisfied simultaneously.
The condition clause is also called a logic condition, specifically, the logic condition refers to an expression capable of returning a boolean variable, and may be a method or a logic operation. Execution of the condition returns that the result should be a boolean variable (one of True, false). The action may be a combination of a plurality of sub-actions, and the actions may be separated according to a predetermined convention, for example, by a semicolon.
The rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part;
preferably, the first rule guide is one of "if", "when", "if" and the second rule guide is one of "then", "then".
For example: for a material purchase order, if the purchase period of the specified components is 3 months, the rule expression statement using the rule guide word may be:
if material classification= component
Then purchase cycle = 3 months
Wherein the meaning represented by "= =" is a condition judgment operator, checking whether the values of two operands are equal, if equal, the condition is true; the meaning of "=" is an assignment.
The rule guiding word library can also comprise Chinese circulation guiding words, which are similar to Chinese rules, if an object set is set and circulation is expected to be carried out according to the identification of the object, the keyword 'certain' must be adopted when the object appears for the first time, and the keyword 'the' must be adopted when the object appears every time later, so long as the same object is referred to.
That is, the third rule guide word is "certain", the fourth rule guide word is "this", and both the third rule guide word and the fourth rule guide word are chinese cyclic guide words.
For example: for reimbursement list, the travel of difference has many days, except for return, the stipulated department stem part is subsidized for 200 yuan every day, and then the regular expression statement containing Chinese circulation guide words can be:
if a sales person is reporting that level= is in place and some [ day of travel ]. Date ]! End day of travel
Then the [ day of travel ] the additional amount = 200 yuan.
The meaning represented by "= =" is a condition judgment operator, which checks whether the values of two operands are equal, and if equal, the condition is true. "|! The meaning of the = "expression is to check whether the values of the two operands are equal, and if the values are not equal, the condition is true.
The Chinese object model library comprises a plurality of object models for the condition part and/or the action part, and each object model comprises a plurality of attributes and methods.
For example, for a material purchase order, the object model includes attributes such as material category, advance period, person filled in, date filled in, etc. The reimbursement list can be divided into a main table, wherein the object model of the reimbursement list main table can comprise the attributes of reimbursement person, level, departure date of travel, end date of travel and the like, the reimbursement list is for example a travel table, the travel date is used as a unique identifier, and the object model of the travel table can comprise the attributes of travel date (mark attribute), reimbursement amount, auxiliary amount and the like.
Each object model may also include a method, which may be an action performed on the object, such as querying whether the object exists, taking the object model of a reimbursement list master table as an example, and which may be querying whether a reimbursement list master table numbered xxxxx exists.
The object model is used for the condition part or action part of Chinese business rules, such as the condition part "if a person is reported, level= is positive and some [ day of travel ]. Date ]! The object model of the reimbursement list is used, and the attributes of reimbursement person, business day and the like are adopted to write the conditions.
Specifically, in step S200, after the user writes the chinese business rule according to the chinese business rule mode, the server invokes the chinese rule engine to verify the rule after receiving the chinese business rule, so as to ensure validity and executable of the chinese business rule.
In one example, the verification is divided into the following steps:
(1) The Chinese business rules are first partitioned into conditional statements and action statements using rule guide words (if, when, etc.).
(2) Processing the conditional statement to form a conditional set
In this processing step, two OR more logical conditions connected by AND OR OR are formed into a condition set that includes all the logical conditions in the rule.
In this process, it is also determined whether or not each logical condition has a logical operator (>, < etc. logical operator). If a logic operator exists in a certain logic condition, the logic operator is extracted, and two end parts of the logic operator are respectively extracted and identified, and the content of each part can be any one of the following:
the first is model and attributes (e.g., person. Age);
the second is a model approach (e.g., people & query ages);
the third is the literal quantity, which may be of the character type or of the numerical type (in this case, the dimension is necessary);
the fourth is a variable, which is divided into a user-defined variable and a built-in system variable,
where the system variable is a variable that the system knows the content, such as: current time, current login user, etc. The user may also customize the variables in Chinese, but the user-defined variables can only be validated within the rules.
If there is no logical operator in a logical condition, then the content of the logical condition must contain a certain method of the model, and the action must return a boolean variable (one of True, false).
For example, a logical condition is "reimbursement sheet & query exists (number: 111027)", meaning whether reimbursement sheet with query number 111027 exists, the logical condition does not exist as a logical operator, but includes a method, and its corresponding action must also return a boolean variable (True indicates that the reimbursement sheet exists, false indicates that the reimbursement sheet does not exist).
(3) Processing the action sentences to form an action set
In this processing step, all actions are formed into an action set, specifically, each "in chinese business rules; "the previous parts are actions.
The actions are divided into an assignment type and a method type, and in the processing process, whether the actions are of the assignment type or the method type is also judged:
if the action is of an assigned type (i.e. the action includes "=", such as reimbursement order, business trip subsidy=200 elements), the extraction is also performed on the two end portions of "=", and the content of each portion may be any of the following:
the first is model and attributes (person. Age);
the second is the literal quantity, which may be of the character type, and may be of the numerical type (which must have dimensions);
the third is a variable, which is classified into a user-defined variable and a built-in system variable.
"=" is an assignment symbol, and appears in an action instead of a conditional statement (when judging whether or not the conditions are equal in the conditional statement, it is necessary to judge the symbol "= =") with a relationship.
If the action is of the method type (i.e. the action contains "&", such as reimbursement sheet & set business trip subsidy (200 yuan)), then the content of the action includes the model and method.
(4) A check set is generated for each model, including the names of the model, attributes, and methods.
(5) And judging the validity of the rule in a manner of semantically checking the rule, including checking whether the rule guide word is used correctly, whether an object model and an attribute exist or not, and the like.
Through the steps, the compliance and consistency of the rule content can be ensured, the Chinese rule engine can easily interpret the rule content, and the accuracy of the rule content and the efficiency of rule execution can be improved. Moreover, the rule content is checked or semantically checked when the rule content needs to be stored, so that the problem can be found out in time and the error can be corrected.
(6) And performing language conversion on the Chinese business rule after successful verification, automatically converting the Chinese names of the model, the attribute, the method, the variable and the dimension into corresponding English names in a system platform, splicing the converted English names into corresponding sentences according to the conversion of the logic operator and the content, and storing the English names in a full English form.
For example: extracting contents of two end parts according to the condition part of 'reimbursement bill and amount >100 yuan' in the Chinese business rule, and converting the 'reimbursement bill and amount' after verification is legal into bxd. After the 100-element verification is legal, converting the result into 100yuan; finally, splicing: bxd.nine >100yuan.
Specifically, in step S300, a plurality of chinese business rules may constitute a rule set, and the rule set may be linked to a certain event. The event is a call entry of the Chinese business rule engine, the event can be that a certain link is clicked, a certain button is pressed, a certain page is refreshed, and the like, and the event represents a trigger action. For example, a button name called "subsidy calculation" may be set on the page of the reimbursement sheet, and when the button is pressed by the user, an event of "subsidy calculation button press" is triggered. When the rules engine receives this event, it invokes the "subsidy calculation button press" corresponding rule set, which in one example has a plurality of rules therein, including, for example:
rule 1: if a sales person is reporting that level= is in place and some [ day of travel ]. Date ]! The [ day of travel ] is the end of travel =200 yuan of the additional amount =
Rule 2: if a sales person reports a level= secondary and a certain [ day of travel ]. Date ]! The [ business day ] is the last day of business trip =the additional amount =150 yuan =
Rule 3: if a sales person, job title= =researcher and some [ travel day ]. Date-! The [ day of travel ] = end of travel ] the additional amount = 300 yuan
After the event of 'subsidy calculation button pressing' is triggered, the rule set is called to calculate, the rule set is directly converted into a computer executable code, and a corresponding result is returned.
Further, in the step S100, a model action library is further constructed in advance, where the model action library includes a plurality of first functions, and each first function is used to associate with one object model, so that the first function operates on the associated object model.
In particular, according to chinese language habits, the first function must be a verb in the language and must adhere to the model. The first function may be a simple verb (action) or a verb (action) with a specific description, and the specific description may be a parameter of the first function.
For example: for the reimbursement sheet, the object model may be subject to the action of nullification, and the first function may be a mere nullification action, e.g., the first function associated with the reimbursement sheet, the object model is "reimbursement sheet & nullification ()".
However, the reimbursement bill will have a reason for reimbursement, such as expiration date, false invoice, reimbursement person withdrawal, etc., so the reason for the reimbursement action can be specifically described, and the specific reason description can be taken as a parameter, and the first function associated with the object model of the reimbursement bill can be "reimbursement bill & reimbursement (expiration date)".
Further, in the step S100, a dictionary model library is pre-built, and the dictionary model library includes a plurality of dictionaries, and the dictionaries include information item keys and information item values; when the data type of a certain attribute of the object model is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model library.
For example, the material classification may be a dictionary and may include components, raw materials, metals, non-metals, and others, one of which must be selected.
The business city may also be a dictionary, which may be composed of province and city two-level sites. For reimbursement sheets, the object model may include an attribute of the business trip destination, the data type of which is text (since city names are typically entered in text form), and the data source of which may be associated with the dictionary of business trip cities.
Further, in the step S100, a dimension model library is further constructed in advance, the dimension model library includes a plurality of dimensions, and the dimensions include a plurality of units and conversion relationships therebetween; when the data type of a certain attribute of the object model is set as a numerical value type, the attribute is associated with a certain dimension in the dimension model library.
For example, the dimension model library may include a monetary dimension that includes a plurality of units, such as RMB, euro, dollars, and the like, and a conversion relationship between these units.
For the object model of the reimbursement bill, there is usually an attribute of reimbursement fee, obviously the data type of the attribute is usually a numerical value, the attribute can be associated with the currency dimension in the dimension model library, the default unit of reimbursement fee is (element, RMB) or (element, euro) when reimbursement is performed, and the real-time exchange can be realized according to the real-time exchange rate of the RMB and the Euro.
Further, in the step S200, determining validity of the condition set and the action set includes performing semantic checking on the rule, and specifically includes: it is checked whether the rule-guided words are used correctly, whether object models, attributes and/or associated function models exist, whether the data types of the attributes and function models agree, whether the literal quantity assignment and the dictionary model agree, and whether the literal quantity assignment includes a dimension model.
Further, in the step S300, after linking the rule set to an event, it further includes performing a conflict check on each rule linked to the event, if there is a conflict content, prompting the conflict content and prompting the user to revise the rule, and if there is no conflict content, maintaining the rule in the database in english form.
Conflict checking: when a rule is referenced to an event, the system automatically checks the rule for conflicts with other rules in the event.
Specifically, rule contents of all rules are combined into a rule set, and conflict checking is performed on the rule set.
Further, the conflict check includes:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not null and the action part of the first rule and the action part of the second rule are identical, or if the conditional part of the first rule and the conditional part of the second rule are identical and the intersection of the action part of the first rule and the action part of the second rule is not null, the first rule and the second rule are in a partial inclusion relationship;
If the condition part of the first rule and the condition part of the second rule are partially or completely identical, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
repeating the steps until the conflict check of all rules is completed.
Examples of partial inclusion relationships are as follows:
the content of the first rule is:
"if reimbursement sheet, reimbursement person, job=in place
Then reimburse list, subsidy = 300 yuan'
The content of the second rule is:
' if reimbursement sheet. Reimbursement person job=in place
Then reimburse list, subsidize >200 yuan'
The first rule and the second rule belong to partial inclusion relation, no conflict exists, and modification is not needed.
Examples of conflicting relationships are as follows:
the content of the first rule is:
"if reimbursement sheet, reimbursement person, job=in place
Then reimburse list, subsidy = 300 yuan'
The content of the second rule is:
' if reimbursement sheet. Reimbursement person job=in place
Then reimburse list, complement >400 yuan'
The first rule and the second rule belong to a conflicting relationship and must be modified.
As a further improvement of the above embodiment, the conflict check further includes:
Selecting any rule as a third rule;
if the condition part of the third rule is limited by the preamble rule and the judging object of the condition part is empty, the third rule is an invalid rule;
and if the action part of the third rule has cyclic application, the third rule is a cyclic rule.
If the conflict check fails, the conflict content is prompted, and because the existence of the conflict causes an uncertain execution result, the conflict information is reported to the user after the conflict, and the user is prompted to revise the rule again. If the conflict check is successful, the Chinese business rule is saved in a database in Json format according to all English modes in consideration of the Chinese compatibility problem of the programming language.
The storage format of the Chinese business rule is exemplified as follows:
Figure BDA0003665930850000151
/>
Figure BDA0003665930850000161
further, in the step S300, the event includes, but is not limited to, the following scenarios: such as page refreshed, button pressed, form submitted, form flow completed, or timing of system control.
Further, in the step S300, the calculating includes: firstly checking rules to ensure the correctness and the validity of the rules, initializing input data after the rules pass, transmitting the input data to a model, compiling the processed rule content into a program language or directly transmitting the compiled code as the input data, injecting the processed input data into the compiled code as input parameters, and returning the result.
Since elements in the rule, such as models, attributes, methods (functions) and dimensions, may change after the rule is stored, the calling time of the rule is affected by the event and is uncertain, so that the correctness and validity of the rule are affected. So that a check is made before rule execution, if these factors change (e.g., are modified or deleted) the rule is mislaid, stopping rule execution. If the check is passed, the input data is initialized.
The input data (typically in terms) is initialized according to a list of models contained in the rules, and in particular, if the model names in the input data match, the part of the data is assigned to the corresponding model.
For example, in the rule of subsidized calculation, attributes such as the level and title of the sales person are used, and records in the bad travel schedule are also used, and these data are all transferred to the model.
And taking the initialized input data as input parameters, injecting the input parameters into the constructed function statement, triggering an execution command to execute the constructed statement, and returning a result. Because the Chinese rule engines have good independence, when the data volume is large, the data can be grouped, and a plurality of rule engines can be called to complete tasks in parallel.
When constructing the function statement, the processed rule content is directly translated into the corresponding computer language according to the rule format requirement of the corresponding computer language. If the language is a compiling type language, executing a dynamic compiling program; if interpreted language, the steps are not needed.
The pre-translation rules are invoked in a stored format into a rules engine, in the form shown below:
if_condition_expression = "xmfp. Xmleixing=" research and development class "".
·or_condition_expression_list:"xmfp.jine<200yuan"
·action_expression_list:"bxd.bxjine=200yuan"
The above rules are translated into programming language according to a fixed format, for example "= =" is translated into an equivalent () function, model attributes are translated into model get ("attribute value"), assignments are translated into model put functions, taking the above rules as an example, the following Java language can be translated, class binary files are obtained after compiling, and the virtual machine directly calls hardware to calculate to obtain results:
if (xmfp. Get ("xmleixing")) equal ("research and development class") |
xmfp.get("jine")<200){
bxd.put("bxjine",200);}
The method is easy to expand to other programming languages such as C, C++, GO and the like.
And dimension processing is also performed on the calculated result, so that the dimension in the calculation process is consistent, and if the dimension is inconsistent, the dimension conversion program is required to be called for processing the dimension.
Further, each rule is provided with a priority, the priority of the rule is ordered from low to high before checking the rule, and the last execution with high priority is performed; priority is a description of the importance of a rule, with higher values being higher. Since the rules are executed orderly, the rules with the assigned values at the back can wash out the rules with assigned values at the front, and the rules with low priority at the front can be washed out when the level is larger and then executed.
Further, in the step S300, the calculating further includes: after the initialization processing of the input data is completed, performing classification relation processing, wherein the classification relation processing comprises the following steps: if the parent class is referenced in the rule, classification loop checking can be performed on all child pairs until all child data checking is completed.
The invention supports a class system in the model, and classes are inherited step by step. The lower level classification inherits the properties and actions of the upper level classification, and the lower level classification can create special properties and actions of its own class, but the created properties and actions must not conflict with the upper level classification.
For example: the invoice is classified into train ticket, food ticket, taxi ticket, airplane ticket, accommodation ticket and other subclasses, and each subclass has its own special attribute and method. Taking train tickets as an example, the train tickets can inherit invoice attributes of ticket numbers, billing units and the like, and can also build own attributes of train numbers, starting stations, arrival stations, seats, students, passengers, identity card numbers and the like.
Actions are inherited along with the category system, and invoices have actions of reimbursement and revocation. The train ticket has the special action of checking the ticket besides the action of reimbursement and revocation.
The model in the Chinese rule engine supports classification, and when the parent class is referenced in the rule, classification cycle checking is needed for all the sub-class objects until all the sub-class data checking is completed.
For example, for rules:
if $current date-certain invoice · date of invoicing > 90 days
Then the invoice & invalidate ();
the rule performs a cyclic check of all sub-class invoices (restaurant invoices, air tickets, train tickets, accommodation tickets, etc.) in the reimbursement ticket and performs an action.
Further, in the step S100, a dimension model library is pre-constructed, and when the data type of a certain attribute of the object model is set as a numerical value type, the attribute is associated with a certain dimension in the dimension model library;
in the step S300, the calculating further includes: after the initialization processing of the input data is completed, dimension processing is performed, the dimension processing including: and unifying all the dimensions of the variables to the standard units of the dimensions, and recording the original dimension units of the variables.
For example, in the case of performing the dimension processing, all the dimensions of the variables may be unified into a standard unit (element) of the dimension for the monetary dimension, and the original dimension unit of the variables may be recorded.
For the time dimension, if the default unit of the dimension of the pre-built model is seconds, but the unit in the rule is days, then it is converted to seconds.
Thus, the number dimensions in the rule can be different from those in the database, and the correct result can be obtained.
A preferred embodiment of the invention is shown below by way of example.
Example 1
The method for realizing the Chinese business rule engine specifically comprises the following steps:
1. pre-constructing Chinese business rule and object model library
By constructing a rule mode which accords with the Chinese grammar characteristics, the rule guide words and the Chinese object model are convenient for business personnel to master.
Regarding chinese business rules, the rule content of which includes a condition part and an action part, may be written in a predefined semantic format to describe the activities and/or relationships of the first object model and/or the second object model. Specifically, the predefined grammar format takes { if } < condition > { then } < action > as a body form, wherein the form of < condition > may be < expression 1> { and } < expression 2> { and } < expression 3>, wherein { and } is used to represent an intersection operation, { and } may also be replaced with { or } is used to represent a union calculation, thereby enabling judgment that a plurality of conditions are satisfied simultaneously.
To reduce the conditional expression statement, a { if }, a { when } complex condition may also be set:
{ if } < Condition 1 ]
{ when } < condition 2> { then } < action 1>
{ when } < condition 3> { then } < action 2>
Pre-constructing a Chinese rule condition guiding word library and a Chinese object model library, wherein: the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part, and specifically comprises a first rule guiding word and a second rule guiding word;
the Chinese circulation leading word is constructed in advance, and is similar to the Chinese rule, if an object set is set and circulation is expected according to the identification of the object, the keyword 'certain' must be adopted when the object appears for the first time, and the keyword 'the' must be adopted when the object appears every time later, so long as the same object is referred to.
The object model library comprises a number of object models for the condition part and/or the action part, each object model comprising a number of properties and methods.
For example, for a material purchase order, there are attributes such as material category, lead time, person filled in, date filled in, and the like. The reimbursement list can be divided into a main list, wherein the main list of the reimbursement list has the attributes of reimbursement person, grade, business trip departure day, business trip ending day and the like, the reimbursement list has a business trip list, the business trip day is taken as a unique identifier, and the attributes in the business trip list have the attributes of business trip day (mark attribute), reimbursement amount, auxiliary amount and the like.
The variables in the system are divided into user-defined variables and built-in system variables. Where the system variable is a variable that the system knows the content, such as: current time, current login user, etc. The user may also customize the Chinese variables, but the customized Chinese variables can only be validated within the rules.
Pre-constructing a model action library, wherein the model action library comprises a plurality of first functions, each first function is associated with one or more object models, and the first functions are used for operating the associated object models; according to Chinese language habit, the function must be a verb in the language, must be attached to a model, and if the function is a simple verb, the function is also a function. If the action is also described, parameters may be used as a function of the action.
For example: the reimbursement bill can be voided, the voiding means that the reimbursement bill is sealed and stored, the attribute state is changed into 'voiding', and meanwhile, the reimbursement bill has voiding reasons: the status describing the nullification actions, such as expiration, false invoice, reimbursement, etc., may be validated together as parameters by the nullification actions. Examples are as follows:
reimbursement sheet & voiding ()
Reimbursement sheets & conducing (outdated)
A class system is supported in the model, and classes are inherited step by step. The lower level classification inherits the properties and actions of the upper level classification, which may establish own class-specific properties and actions, but the newly created properties and actions must not conflict with the upper level classification.
For example: the invoice is classified into train ticket, food ticket, taxi ticket, airplane ticket, accommodation ticket and other subclasses, and each subclass has its own special attribute and method. Taking a train ticket as an example, the train ticket inherits invoice attributes of a ticket number, an invoicing unit and the like, and also has information such as a train number, a starting station, an arrival station, a seat, whether students, passengers, an identity card and the like.
Actions are inherited along with the category system, and invoices have actions of reimbursement and revocation. In addition to this, the train ticket has the special action of checking the ticket.
Pre-constructing a dictionary model library, wherein the dictionary model library comprises a plurality of dictionaries, and the dictionaries comprise information item keys and information item values; the pre-built object model further comprises: when the data type of the attribute is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model base.
For example, the material classification may be a dictionary and may include components, raw materials, metals, non-metals, and others, one of which must be selected. In the case of reimbursement sheets, the business trip city can also be a dictionary, and can be composed of two-level places of province and city.
Pre-constructing a dimension model library, wherein the dimension model library comprises a plurality of dimensions, and the dimensions comprise a plurality of units and conversion relations among the units; the pre-built object model further comprises: when the data type of the attribute is set to be a value type, the attribute is associated with a certain dimension in the dimension model library.
For example, the reimbursement bill usually has reimbursement fees, and the default unit is (Yuan, RMB) or (Yuan, euro) can be selected, so that real-time conversion can be realized according to the conversion prices of the RMB and the Euro.
2. Chinese business rule checksum storage
The user writes according to the Chinese rule grammar requirements, and when the user writes, namely when receiving a rule preservation command, the user invokes a Chinese rule engine which verifies the rule to ensure the validity and the executable of the Chinese business rule. The checksum storage is divided into the following steps:
1. Firstly, cutting out a conditional statement and an action statement by using keywords (if, when, then); since the format requirements of the chinese rules engine are relatively fixed, it is only format 1 or format 2.
Format 1:
{ if } < condition > { then } < action >
Format 2:
{ if } < Condition 1 ]
{ when } < condition 2> { then } < action 1>
{ when } < condition 3> { then } < action 2>
It should be understood that the condition in the above-described format 1 and format 2 may be a combination of a plurality of specific condition clauses, which are also referred to as logic conditions, and specifically, the logic conditions refer to expressions capable of returning boolean variables, which may be methods or logical operations. The conditional clauses may be connected by AND OR, AND the execution return result of the condition should be a boolean variable (one of True AND False). The action may be a combination of a plurality of sub-actions, and the actions may be separated according to a predetermined convention, for example, by a semicolon.
2. Conditional statement processing
(1) More than two logical conditions connected by AND OR OR form a condition set comprising all the logical conditions in the rule;
(2) Extracting logical operators of each logical condition (>, < etc. logical operation symbols), if a logical operator exists in a certain logical condition, extracting and identifying two end portions of the logical operator respectively, wherein the content of each portion can comprise any one of the following:
The first is a model and attributes (e.g., person. Age),
the second is a model method (e.g. person & query age ()),
the third is the literal quantity, which may be of the character type or of the numerical type (in which case it is necessary to have dimensions),
the fourth is a variable, which is divided into a user-defined variable and a built-in system variable;
if there is no logical operator in a logical condition, then the content of the logical condition must contain a certain method of the model, and the action must return a boolean variable (one of True, false).
For example, whether a reimbursement sheet & query exists (number 111027), meaning whether a reimbursement sheet with query number 111027 exists.
In addition, no assignment symbol can exist in the conditional statement, and a judgment symbol "= =" for judging equality needs.
3. Action sentence processing:
(1) Each "; "the previous parts are actions (i.e., actions), all of which form an action set;
(2) Actions are classified into an assignment type and a method type, and thus it is necessary to determine whether an action is an assignment type or a method type:
if the assignment type (i.e., the action includes "=", such as reimbursement list, business trip subsidy=200 yuan), the two end portions of "=" are extracted and identified, and the content of each portion may include any of the following: the first is model and attribute (person, age), the second is literal, can be character type, can be numerical (with dimension), the third is variable, and is divided into user-defined variable and built-in system variable; if method type (i.e. action contains "&", such as reimbursement sheet & set business trip subsidy (200 yuan)), then the content of the action includes model and method;
4. After decomposition is completed, generating a check set for each model, wherein the check set comprises the names of the model, the attribute and the method;
5. the rules are checked semantically. Whether the rule directs the use of words correctly, whether an object model, an attribute and/or an associated function model exists, whether the data types of the attribute and the function model are consistent, whether the literal quantity assignment and the dictionary model are consistent, whether the literal quantity assignment includes a dimension model, and the like.
Through the steps, the compliance and consistency of the rule content can be ensured, the Chinese rule engine can easily interpret the rule content, and the accuracy of the rule content and the efficiency of rule execution can be improved. Moreover, the rule content is checked or semantically checked when the rule content needs to be stored, so that the problem can be found out in time and the error can be corrected.
6. Chinese names of models, attributes, methods, variables and dimensions are automatically converted into corresponding English names in a system platform, then the converted English names are spliced into corresponding sentences according to the conversion of logical operators and contents, and the corresponding sentences are stored in a full English form.
For example: the reimbursement bill and the sum of money is more than 100yuan. Extracting contents on two sides according to 'and reimbursement bill', and converting the contents into bxd.nine after the amount verification is legal; after the 100-element verification is legal, converting the result into 100yuan; finally, splicing: bxd.nine >100yuan.
7. Conflict checking: when a rule is referenced to an event, the system automatically checks the rule for conflicts with other rules in the event.
Specifically, rule contents of all rules are formed into a rule set, and conflict checking is carried out on the rule set, wherein the conflict checking comprises the following steps:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not empty, and the action part of the first rule and the action part of the second rule are completely the same; or if the condition part of the first rule and the condition part of the second rule are identical, and the intersection of the action part of the first rule and the action part of the second rule is not empty, the first rule and the second rule are in a part inclusion relationship;
if the condition part of the first rule and the condition part of the second rule are partially the same, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
repeating the steps until the conflict check of all rules is completed.
Examples of partial inclusion relationships are as follows:
the content of the first rule is:
"if reimbursement sheet, reimbursement person, job=in place
Then reimburse list, subsidy = 300 yuan'
The content of the second rule is:
' if reimbursement sheet. Reimbursement person job=in place
Then reimburse list, subsidize >200 yuan'
The first rule and the second rule belong to part of the inclusion relation without modification.
Examples of conflicting relationships are as follows:
the content of the first rule is:
"if reimbursement sheet, reimbursement person, job=in place
Then reimburse list, subsidy = 300 yuan'
The content of the second rule is:
' if reimbursement sheet. Reimbursement person job=in place
Then reimburse list, complement >400 yuan'
The first rule and the second rule belong to a conflicting relationship and must be modified.
As a further improvement of the above embodiment, the conflict check further includes:
selecting any rule as a third rule;
if the condition part of the third rule is limited by the preamble rule and the judging object of the condition part is empty, the third rule is an invalid rule;
and if the action part of the third rule has cyclic application, the third rule is a cyclic rule.
8. If the conflict check fails, the conflict content is prompted, and because the existence of the conflict causes an uncertain execution result, the conflict information is reported to the user after the conflict, and the user is prompted to revise the rule again. If the conflict check is successful, the Chinese business rule is saved in a database in Json format according to all English modes in consideration of the Chinese compatibility problem of the programming language.
3. Execution of rules
Multiple Chinese business rules may form a rule set that may be linked to an event. The event is a call entry of the Chinese business rule engine, the event can be that a certain link is clicked, a certain button is pressed, a certain page is refreshed, and the like, and the event represents a trigger action. For example, a button name called "subsidy calculation" may be set on the page of the reimbursement sheet, and when the button is pressed by the user, an event of "subsidy calculation button press" is triggered. When the rule engine receives the event, the rule set corresponding to "the auxiliary calculation button is pressed" is called, and a plurality of rules exist in the rule set, for example:
rule 1 (priority 1): if a sales person is reporting that level= is in place and some [ day of travel ]. Date ]! The [ day of travel ] is the end of travel =200 yuan of the additional amount =
Rule 2 (priority 1): if a sales person reports a level= secondary and a certain [ day of travel ]. Date ]! The [ business day ] is the last day of business trip =the additional amount =150 yuan =
Rule 3 (priority 2): if a sales person, job title= =researcher and some [ travel day ]. Date-! The [ day of travel ] = end of travel ] the additional amount = 300 yuan
When a user or system triggers a corresponding event, the rule set in the event starts to execute, and the executing process is as follows:
1. ordering rule priority from low to high, and executing last with high priority; priority is a description of the importance of a rule, with higher values being higher. Since the rules are executed orderly, the rules with the assigned values at the back can wash out the rules with assigned values at the front, and the rules with low priority at the front can be washed out when the level is larger and then executed. In this example, rule 3 has a high priority level and so is executed later. At this time, if the reimburser is both a long and a researcher, then in rule 1, the subsidy is set to 200 yuan/day; later execution goes to rule 3, the subsidy is reset to 300 yuan/day.
2. Rule check (validity check, model validity check)
Since elements in the rule, such as models, attributes, methods (functions) and dimensions, may change after the rule is stored, the calling time of the rule is affected by the event and is uncertain, so that the correctness and validity of the rule are affected. So that a check is made before rule execution, if these factors change (e.g., are modified or deleted) the rule is mislaid, stopping rule execution. If the check passes, the next step is performed.
3. Input data processing: the input data (typically in terms) is initialized according to a list of models contained in the rules, and in particular, if the model names in the input data match, the part of the data is assigned to the model.
For example, in the rule of subsidized calculation, attributes such as the level and title of the sales person are used, and records in the bad travel schedule are also used, and these data are all transferred to the model.
4. And (5) classifying relation processing. The model in the Chinese rule engine supports classification, and when the parent class is referenced in the rule, classification cycle checking is needed for all the sub-class objects until all the sub-class data checking is completed.
For example, for rules:
if $current date-certain invoice · date of invoicing > 90 days
Then the invoice & invalidate ();
the rule performs a cyclic check of all sub-class invoices (restaurant invoices, air tickets, accommodation tickets, etc.) in the reimbursement ticket and performs an action.
5. Dimension treatment: unifying all the variable dimensions to a standard unit (element) of the dimension (currency), and recording the original dimension unit of the variable; if the default unit of dimension of the pre-built model is seconds, but the unit in the rule is days, then it is converted to seconds. Thus, the number dimensions in the rule can be different from those in the database, and the correct result can be obtained.
6. Constructing a function statement: according to the rule format requirements of the corresponding computer language, the processed rule content is directly translated into the corresponding computer language, the rules are ordered according to the priority, and the higher the priority is, the later the rule is, and the corresponding rule statement is executed later. If the language is a compiling type language, executing a dynamic compiling program; if interpreted language, the steps are not needed.
The pre-processing rules are invoked in a stored format into a rules engine, in the form shown below:
if_condition_expression = "xmfp. Xmleixing=" research and development class "".
·or_condition_expression_list:"xmfp.jine<200yuan"
·action_expression_list:"bxd.bxjine=200yuan"
Converting the above rule into a programming language according to a fixed format, for example, converting into a Java language, converting "=" into an equivalent () function, converting model attributes into model_get ("attribute value"), converting assignments into model_put functions, taking the above rule as an example, converting into the following Java language, compiling to obtain a Class binary file, and directly calling hardware by a virtual machine to calculate to obtain a result:
if (xmfp. Get ("xmleixing")) equal ("research and development class") |
xmfp.get("jine")<200){
bxd.put("bxjine",200);}
The method is easy to expand to other programming languages such as C, C++, GO and the like.
7. Rule execution: and taking the processed input data as input parameters, injecting the input parameters into the constructed function statement, triggering an execution command to execute the constructed statement, and returning a result. Because the Chinese rule engines have good independence, when the data volume is large, the data can be grouped, and a plurality of rule engines can be called to complete tasks in parallel.
8. And D, dimension processing is carried out on the calculated result, so that the dimension in the calculation process is consistent, and if the dimension is inconsistent, the dimension conversion program is required to be called to process the dimension.
In a second aspect, referring to fig. 2, the present invention provides an implementation apparatus of a chinese business rule engine, including:
the system comprises a library and rule pattern construction module, a rule guide word library and a Chinese object model library, wherein the library and rule pattern construction module is used for constructing a Chinese business rule pattern, a rule guide word library and a Chinese object model library in advance, the Chinese business rule pattern is a rule pattern conforming to a Chinese grammar format, and rule contents comprise a condition part and an action part so as to describe activities and/or relations of the object model; the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part; the Chinese object model library comprises a plurality of object models, and each object model comprises a plurality of attributes and methods;
the verification and Chinese-English conversion module is used for receiving Chinese business rules written according to the Chinese business rule mode, verifying the received Chinese business rules by utilizing a Chinese rule engine, wherein the verification comprises the steps of dividing the Chinese business rules into conditional sentences and action sentences by utilizing preset keywords, respectively processing the conditional sentences and the action sentences to form a conditional set and an action set, and judging the legality of the conditional set and the action set; then, converting the Chinese name into English name according to the Chinese business rule after the verification is successful, splicing the converted English name into a corresponding sentence, and storing in an English form;
The event linking and calculating module is used for forming a rule set by utilizing a plurality of Chinese business rules, and linking the rule set into an event so as to call a Chinese business rule engine through the event; and when the event is triggered, calling the rule set to calculate so as to directly convert the rule set into computer executable codes and returning a result.
Preferably, the library and rule pattern construction module is further configured to pre-construct a model action library, where the model action library includes a plurality of first functions, each of the first functions being configured to associate with an object model, so that the first functions operate on the object model associated therewith.
Preferably, the library and rule pattern construction module is further configured to construct a dictionary model library in advance, where the dictionary model library includes a plurality of dictionaries, and the dictionaries include information item keys and information item values; when the data type of a certain attribute of the object model is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model library.
Preferably, the library and rule pattern construction module is further configured to pre-construct a dimension model library, where the dimension model library includes a plurality of dimensions, and the dimensions include a plurality of units and conversion relationships therebetween; when the data type of a certain attribute of the object model is set as a numerical value type, the attribute is associated with a certain dimension in the dimension model library.
Preferably, the verifying and Chinese-English converting module includes performing semantic checking on the rule when judging validity of the condition set and the action set, and specifically includes: it is checked whether the rule-guided words are used correctly, whether object models, attributes and/or associated function models exist, whether the data types of the attributes and function models agree, whether the literal quantity assignment and the dictionary model agree, and whether the literal quantity assignment includes a dimension model.
Preferably, after the rule set is linked to an event, the event linking and calculating module further performs conflict checking on each rule linked to the event, if conflict content exists, prompts the conflict content and prompts a user to revise the rule, and if conflict content does not exist, the rule is kept in the database in an English form.
Preferably, the collision check includes:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not null and the action part of the first rule and the action part of the second rule are identical, or if the conditional part of the first rule and the conditional part of the second rule are identical and the intersection of the action part of the first rule and the action part of the second rule is not null, the first rule and the second rule are in a partial inclusion relationship;
If the condition part of the first rule and the condition part of the second rule are partially or completely identical, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
repeating the steps until the conflict check of all rules is completed.
Preferably, the event includes a page being refreshed, a button being pressed, a form being submitted, a form flow being completed, or a timed start task of system control.
Preferably, the event linking and calculating module performs calculation in a manner including: firstly checking rules to ensure the correctness and the validity of the rules, initializing input data after the rules pass, transmitting the input data to a model, compiling the processed rule content into a program language or directly transmitting the compiled code as the input data, injecting the processed input data into the compiled code as input parameters, and returning the result.
Preferably, the manner of calculating by the event link and calculation module further includes: after the initialization processing of the input data is completed, performing classification relation processing, wherein the classification relation processing comprises the following steps: if the parent class is referenced in the rule, classification loop checking can be performed on all child pairs until all child data checking is completed.
Preferably, the library and rule pattern construction module is further configured to pre-construct a dimension model library, and when a data type of a certain attribute of the object model is set to be a numerical type, associate the attribute with a certain dimension in the dimension model library;
the event link and the calculation module further calculate in a manner that: after the initialization processing of the input data is completed, dimension processing is performed, the dimension processing including: and unifying all the dimensions of the variables to the standard units of the dimensions, and recording the original dimension units of the variables.
The realization device of the Chinese business rule engine provided by the invention can well execute the realization method of the Chinese business rule engine, provides convenience for directly converting rules similar to Chinese rule language into executable codes of a computer, is beneficial to omitting the process of developing business logic of programmers, and enables business personnel to directly obtain the final operation result of writing the business logic.
In a third aspect, the present invention provides a server comprising a processor and a memory, the memory having stored thereon a computer program which, when executed by the processor, is capable of implementing a method as described above.
In a fourth aspect, the present invention provides a computer readable storage medium having stored thereon a computer program for execution to perform a method as described above.
Those skilled in the art will appreciate that the above-described preferred embodiments can be freely combined and stacked without conflict.
It will be understood that the above-described embodiments are merely illustrative and not restrictive, and that all obvious or equivalent modifications and substitutions to the details given above may be made by those skilled in the art without departing from the underlying principles of the invention, are intended to be included within the scope of the appended claims.

Claims (20)

1. A method for realizing a Chinese business rule engine is applied to a server and is characterized by comprising the following steps:
s100, a Chinese business rule mode, a rule guiding word stock and a Chinese object model library are built in advance, wherein the Chinese business rule mode is a rule mode conforming to a Chinese grammar format, and rule content comprises a condition part and an action part so as to describe the activity and/or the relation of the object model; the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part, and the rule guiding words comprise Chinese cyclic guiding words; the Chinese object model library comprises a plurality of object models, and each object model consists of a plurality of attributes and methods;
S200, receiving Chinese business rules written according to the Chinese business rule mode, and checking the received Chinese business rules by using a Chinese rule engine, wherein the checking comprises dividing the Chinese business rules into conditional sentences and action sentences by using preset keywords, respectively processing the conditional sentences and the action sentences to form a conditional set and an action set, and judging the legality of the conditional set and the action set; then, converting the Chinese name into English name according to the Chinese business rule after the verification is successful, splicing the converted English name into a corresponding sentence, and storing in an English form;
s300, forming a rule set by utilizing a plurality of Chinese business rules, and linking the rule set into an event so as to call a Chinese business rule engine through the event; when the event is triggered, calling the rule set to calculate so as to directly convert the rule set into a computer executable code and returning a result;
in the step S100, a dimension model library is further constructed in advance, the dimension model library includes a plurality of dimensions, and the dimensions include a plurality of units and conversion relationships therebetween; when the data type of a certain attribute of the object model is set to be a numerical value type, associating the attribute with a certain dimension in the dimension model library;
In the step S300, the calculating further includes: after the initialization processing of the input data is completed, performing classification relation processing, wherein the classification relation processing comprises the following steps: if the parent class is referenced in the rule, classification loop checking can be performed on all the child objects until all the child data checking is completed.
2. The method of claim 1, wherein,
in step S100, a model action library is further constructed in advance, where the model action library includes a plurality of first functions, and each first function is used to associate with one object model, so that the first function operates on the associated object model.
3. The method of claim 1, wherein,
in the step S100, a dictionary model library is pre-constructed, and the dictionary model library includes a plurality of dictionaries, and the dictionaries include information item keys and information item values; when the data type of a certain attribute of the object model is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model library.
4. The method of claim 1, wherein,
in the step S200, determining validity of the condition set and the action set includes performing semantic checking on the rule, and specifically includes: it is checked whether the rule-guided words are used correctly, whether object models, attributes and/or associated function models exist, whether the data types of the attributes and function models agree, whether the literal quantity assignment and the dictionary model agree, and whether the literal quantity assignment includes a dimension model.
5. The method of claim 1, wherein,
in the step S300, after linking the rule set to an event, it further includes performing conflict checking on each rule linked to the event, if there is conflict content, prompting the conflict content and prompting the user to revise the rule, and if there is no conflict content, maintaining the rule in the database in english form.
6. The method of claim 5, wherein,
the conflict check includes:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not null and the action part of the first rule and the action part of the second rule are identical, or if the conditional part of the first rule and the conditional part of the second rule are identical and the intersection of the action part of the first rule and the action part of the second rule is not null, the first rule and the second rule are in a partial inclusion relationship;
if the condition part of the first rule and the condition part of the second rule are partially or completely identical, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
Repeating the steps until the conflict check of all rules is completed.
7. The method of claim 1, wherein,
in step S300, the event includes a page being refreshed, a button being pressed, a form being submitted, a form flow being completed, or a system controlled timed start task.
8. The method of claim 1, wherein,
in the step S300, the calculating includes: firstly checking rules to ensure the correctness and the validity of the rules, initializing input data after the rules pass, transmitting the input data to a model, compiling the processed rule content into a program language or directly transmitting the compiled code as the input data, injecting the processed input data into the compiled code as input parameters, and returning the result.
9. The method of any one of claim 1 to 8, wherein,
in the step S300, the calculating further includes: after the initialization processing of the input data is completed, dimension processing is performed, the dimension processing including: and unifying all the dimensions of the variables to the standard units of the dimensions, and recording the original dimension units of the variables.
10. An implementation device of a chinese business rule engine, comprising:
the system comprises a library and rule pattern construction module, a rule guide word library and a Chinese object model library, wherein the library and rule pattern construction module is used for constructing a Chinese business rule pattern, a rule guide word library and a Chinese object model library in advance, the Chinese business rule pattern is a rule pattern conforming to a Chinese grammar format, and rule contents comprise a condition part and an action part so as to describe activities and/or relations of the object model; the rule guiding word library comprises a plurality of rule guiding words used for the condition part and/or the action part, and the rule guiding words comprise Chinese cyclic guiding words; the Chinese object model library comprises a plurality of object models, and each object model consists of a plurality of attributes and methods;
the verification and Chinese-English conversion module is used for receiving Chinese business rules written according to the Chinese business rule mode, verifying the received Chinese business rules by utilizing a Chinese rule engine, wherein the verification comprises the steps of dividing the Chinese business rules into conditional sentences and action sentences by utilizing preset keywords, respectively processing the conditional sentences and the action sentences to form a conditional set and an action set, and judging the legality of the conditional set and the action set; then, converting the Chinese name into English name according to the Chinese business rule after the verification is successful, splicing the converted English name into a corresponding sentence, and storing in an English form;
The event linking and calculating module is used for forming a rule set by utilizing a plurality of Chinese business rules, and linking the rule set into an event so as to call a Chinese business rule engine through the event; when the event is triggered, calling the rule set to calculate so as to directly convert the rule set into a computer executable code and returning a result;
the library and rule pattern construction module is also used for pre-constructing a dimension model library, wherein the dimension model library comprises a plurality of dimensions, and the dimensions comprise a plurality of units and conversion relations among the units; when the data type of a certain attribute of the object model is set to be a numerical value type, associating the attribute with a certain dimension in the dimension model library;
the event link and the calculation module further calculate in a manner that: after the initialization processing of the input data is completed, performing classification relation processing, wherein the classification relation processing comprises the following steps: if the parent class is referenced in the rule, classification loop checking can be performed on all the child objects until all the child data checking is completed.
11. The implementation apparatus according to claim 10, wherein the library and rule pattern construction module is further configured to construct in advance a model action library, the model action library including a plurality of first functions, each first function being configured to be associated with one object model so that the first function operates on its associated object model.
12. The implementation apparatus according to claim 10, wherein the library and rule pattern construction module is further configured to construct a dictionary model library in advance, the dictionary model library including a plurality of dictionaries including information item keys and information item values; when the data type of a certain attribute of the object model is set to be a text type, the data source of the attribute is associated with a certain dictionary in the dictionary model library.
13. The implementation apparatus of claim 10, wherein the checksum chinese-english conversion module, when determining validity of the condition set and the action set, includes performing a semantic check on the rule, and specifically includes: it is checked whether the rule-guided words are used correctly, whether object models, attributes and/or associated function models exist, whether the data types of the attributes and function models agree, whether the literal quantity assignment and the dictionary model agree, and whether the literal quantity assignment includes a dimension model.
14. The implementation apparatus of claim 10, wherein the event linking and calculating module, after linking the rule set to an event, further performs a conflict check on each rule linked to the event, if there is a conflict content, prompts the conflict content and prompts the user to revise the rule, and if there is no conflict content, maintains the rule in english form in the database.
15. The implementation apparatus of claim 14, wherein the collision check comprises:
any two rules are selected as the first rule and the second rule,
if the intersection of the conditional part of the first rule and the conditional part of the second rule is not null and the action part of the first rule and the action part of the second rule are identical, or if the conditional part of the first rule and the conditional part of the second rule are identical and the intersection of the action part of the first rule and the action part of the second rule is not null, the first rule and the second rule are in a partial inclusion relationship;
if the condition part of the first rule and the condition part of the second rule are partially or completely identical, and the intersection of the action part of the first rule and the action part of the second rule is empty, the first rule and the second rule are in a conflict relationship;
repeating the steps until the conflict check of all rules is completed.
16. The implementation apparatus of claim 10, wherein the event comprises a page being refreshed, a button being pressed, a form being submitted, a form flow being completed, or a system controlled timed start task.
17. The implementation apparatus according to claim 10, wherein the event linking and calculating module performs calculation in a manner including: firstly checking rules to ensure the correctness and the validity of the rules, initializing input data after the rules pass, transmitting the input data to a model, compiling the processed rule content into a program language or directly transmitting the compiled code as the input data, injecting the processed input data into the compiled code as input parameters, and returning the result.
18. The implementation device according to any of the claims 10-17, wherein,
the event link and the calculation module further calculate in a manner that: after the initialization processing of the input data is completed, dimension processing is performed, the dimension processing including: and unifying all the dimensions of the variables to the standard units of the dimensions, and recording the original dimension units of the variables.
19. A server, characterized in that:
comprising a processor and a memory, said memory having stored thereon a computer program which, when executed by said processor, is capable of implementing the method according to any of claims 1 to 9.
20. A computer readable storage medium having stored thereon a computer program for executing to perform the method of any of claims 1 to 9.
CN202210592375.6A 2022-05-27 2022-05-27 Method and device for realizing Chinese business rule engine, server side and storage medium Active CN115167826B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210592375.6A CN115167826B (en) 2022-05-27 2022-05-27 Method and device for realizing Chinese business rule engine, server side and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210592375.6A CN115167826B (en) 2022-05-27 2022-05-27 Method and device for realizing Chinese business rule engine, server side and storage medium

Publications (2)

Publication Number Publication Date
CN115167826A CN115167826A (en) 2022-10-11
CN115167826B true CN115167826B (en) 2023-05-05

Family

ID=83483811

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210592375.6A Active CN115167826B (en) 2022-05-27 2022-05-27 Method and device for realizing Chinese business rule engine, server side and storage medium

Country Status (1)

Country Link
CN (1) CN115167826B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704265A (en) * 2017-09-30 2018-02-16 电子科技大学 A kind of configurable rule generating method of service-oriented stream

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103019726B (en) * 2012-12-19 2016-08-10 中国电子科技集团公司第十五研究所 The management method of software system business rule and device
US11269889B1 (en) * 2018-05-09 2022-03-08 Christopher James Aversano Graphical user interface driven programming development environment
CN110196719B (en) * 2019-05-20 2023-08-15 中国工商银行股份有限公司 Business rule generation method and system based on natural language processing
CN110428054A (en) * 2019-08-07 2019-11-08 浪潮云信息技术有限公司 Business Rule Engine pattern matching system and implementation method based on technique of compiling

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704265A (en) * 2017-09-30 2018-02-16 电子科技大学 A kind of configurable rule generating method of service-oriented stream

Also Published As

Publication number Publication date
CN115167826A (en) 2022-10-11

Similar Documents

Publication Publication Date Title
Constantine et al. Structure and style in use cases for user interface design
Meziane et al. Generating natural language specifications from UML class diagrams
US8271870B2 (en) Document analysis, commenting, and reporting system
US8050907B2 (en) Generating software components from business rules expressed in a natural language
US9535982B2 (en) Document analysis, commenting, and reporting system
CN107644323A (en) A kind of intelligent checks system of service-oriented stream
CN106843878B (en) A kind of model generating method and system
CN111913739B (en) Service interface primitive defining method and system
CN109697050A (en) A kind of Requirements description model design method of the knowledge based map towards electric business field
CN115390821B (en) Natural language code-free programming-oriented software application construction method
US8091069B2 (en) Module specification language and meta-module
CN115167826B (en) Method and device for realizing Chinese business rule engine, server side and storage medium
Berzins et al. Innovations in natural language document processing for requirements engineering
US20220222065A1 (en) System and method of computer-assisted computer programming
Etzkorn A metrics-based approach to the automated identification of object-oriented reusable software components
Murtazina et al. The detection of conflicts in the requirements specification based on an ontological model and a production rule system
CN110928535A (en) Derivative variable deployment method, device, equipment and readable storage medium
CN115169295B (en) Interface interaction method, device, system and medium based on model
Ornaghi et al. A constructive object oriented modeling language for information systems
Ciaccia et al. Formal requirements and design specifications: The Clepsydra methodology
CN110162468B (en) Test method, test device and computer readable storage medium
Hnatkowska et al. Compatibility Checking of Compound Business Rules Expressed in Natural Language Against Domain Specification
Maletic The Software Service Bay: A knowledge-based software maintenance methodology
de Azevedo Cysneiros Filho Software traceability for multi-agent systems implemented using BDI architecture.
CN116700732A (en) Method, system, equipment and medium for realizing business rule engine

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
GR01 Patent grant
GR01 Patent grant