CN114780107B - Grammar analysis method and device of rule running file and decision engine - Google Patents

Grammar analysis method and device of rule running file and decision engine Download PDF

Info

Publication number
CN114780107B
CN114780107B CN202210714784.9A CN202210714784A CN114780107B CN 114780107 B CN114780107 B CN 114780107B CN 202210714784 A CN202210714784 A CN 202210714784A CN 114780107 B CN114780107 B CN 114780107B
Authority
CN
China
Prior art keywords
rule
java
file
expression
pseudo code
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
CN202210714784.9A
Other languages
Chinese (zh)
Other versions
CN114780107A (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.)
Beijing Yusys Technologies Group Co ltd
Original Assignee
Beijing Yusys Technologies Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yusys Technologies Group Co ltd filed Critical Beijing Yusys Technologies Group Co ltd
Priority to CN202210714784.9A priority Critical patent/CN114780107B/en
Publication of CN114780107A publication Critical patent/CN114780107A/en
Application granted granted Critical
Publication of CN114780107B publication Critical patent/CN114780107B/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/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • 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/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45504Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators

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)
  • Stored Programmes (AREA)

Abstract

The embodiment of the invention provides a grammar analysis method, a grammar analysis device and a decision engine of a rule running file, wherein the method comprises the following steps: step S1: reading a rule running file; step S2: analyzing the rule running file to obtain a rule type in the rule running file, and converting the rule content in the rule running file into a pseudo code expression according to the rule type; and step S3: converting the pseudo code expression into a Java language expression; and step S4: and assembling the Java language expression to obtain a Java language code. The embodiment of the invention can convert the rule content according to the rule type and can perform rule customization processing aiming at different service requirements, specific scenes and the like.

Description

Grammar analysis method, device and decision engine for rule running file
Technical Field
The invention relates to the technical field of information, in particular to a grammar analysis method and a grammar analysis device of a rule running file and a decision engine.
Background
The decision engine is a business rule operation management product, is developed by an inference engine, and realizes the separation of business rules from application program codes so as to meet the requirement of frequently changing business rules.
In the prior art, grammar analysis of a rule running file is single, rule contents cannot be analyzed according to rule types, and further rule customization processing cannot be performed according to business requirements, specific scenes and the like, namely different grammar analysis processing is performed on rules with different scenes and different requirements.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method, an apparatus, and a decision engine for parsing a rule run file, so as to solve the technical problem in the prior art that rule contents cannot be parsed according to rule types.
In order to achieve the above object, in a first aspect, the present invention provides a method for parsing a rule run file, where the method includes:
step S1: reading a rule running file;
step S2: analyzing the rule running file to obtain a rule type in the rule running file, and converting the rule content in the rule running file into a pseudo code expression according to the rule type;
and step S3: converting the pseudo code expression into a Java language expression;
and step S4: and assembling the Java language expression to obtain a Java language code.
In some possible embodiments, the step S2 includes:
step S21: after the rule running file is read, analyzing the rule running file to obtain configuration information related to a rule set in the rule running file; the configuration information comprises configuration field information;
step S22: determining the rule type in the rule running file according to the configuration information;
step S23: calling a corresponding grammar parser according to the rule type to process the rule content in the rule running file so as to convert the rule content into a pseudo code expression;
step S24: and assigning the pseudo code expression to a Java string variable so as to store the pseudo code expression to a memory of a Java virtual machine in the form of the first string variable of the Java.
In some possible embodiments, after step S21, step S2 may further include:
step S25: and analyzing the rule set in the rule running file according to the configuration field information related to the rule set to obtain rule parameter information related to the rule in the rule set.
In some possible embodiments, the step S3 includes:
step S31: acquiring a pseudo code expression stored in the first Java character string variable from a memory of the Java virtual machine, and converting the pseudo code expression into a Java language expression;
step S32: and assigning the Java language expression to a second Java character string variable so as to store the Java language expression in the memory of the Java virtual machine in the form of the second Java character string variable.
In some possible embodiments, the step S4 comprises:
step S41: taking a rule id in the rule parameter information as a method name, taking an input parameter or a derivative index parameter in the rule parameter information as an input parameter of a method, taking a rule output parameter in the rule parameter information as an output parameter of the method, and splicing the Java language expression to obtain a rule Java method;
step S42: taking a rule set id in configuration field information related to the rule set as a Java class name, and adding the rule Java method in the Java class name to obtain a rule set Java class;
step S43: and assigning the rule set Java class to a second Java character string variable to obtain a Java language code and loading the Java language code to a memory of a Java virtual machine.
In some possible embodiments, the step S42 further includes: adding Java exception processing codes and Java log processing codes in the rule set Java class.
In a second aspect, the present invention provides a syntax parsing apparatus for a rule run file, the apparatus comprising:
the rule running file reading module is used for reading the rule running file;
the rule syntax analyzer is used for analyzing the rule operation file to obtain a rule type in the rule operation file and converting the rule content in the rule operation file into a pseudo code expression according to the rule type;
the rule logic processor is used for converting the pseudo code expression into a Java language expression;
and the assembling module is used for assembling the Java language expression to obtain a Java language code.
In a third aspect, the present invention provides a decision engine comprising:
the decision engine definition module is used for newly adding, modifying or storing a rule definition file, issuing and deploying the rule definition file and then generating a rule running file;
the decision engine operation module is used for reading, loading, syntax parsing and compiling operation of the rule operation file, and comprises the syntax analysis device.
In a fourth aspect, the present invention provides an electronic device, comprising:
at least one processing device; and the number of the first and second groups,
a memory communicatively coupled to the at least one processing device; wherein, the first and the second end of the pipe are connected with each other,
the storage device stores instructions executable by the at least one processing device to enable the at least one processing device to perform a method of parsing a rule run file according to any one of the preceding claims.
In a fifth aspect, the present invention provides a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform a method of parsing a rule run file according to any one of the preceding claims.
In a sixth aspect, the invention provides a computer program product comprising a computer program stored on a non-transitory computer readable storage medium.
The technical scheme has the following beneficial effects:
the invention provides a grammar analysis method, a grammar analysis device and a decision engine of a rule running file, wherein the method comprises the following steps: step S1: reading a rule running file; step S2: analyzing the rule running file to obtain a rule type in the rule running file, and converting the rule content in the rule running file into a pseudo code expression according to the rule type; and step S3: converting the pseudo code expression into a Java language expression; and step S4: and assembling the Java language expression to obtain a Java language code. The embodiment of the invention can convert the rule content according to the rule type and can perform rule customization processing aiming at different service requirements, specific scenes and the like.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of a method of parsing a rule run file according to an embodiment of the present invention;
FIG. 2 is a schematic illustration of a rule of freedom of an embodiment of the present invention;
FIG. 3 is a schematic view of a scorecard according to an embodiment of the invention;
FIG. 4 is a schematic diagram of a decision table according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a decision tree according to an embodiment of the present invention;
FIG. 6 is a schematic illustration of a rule flow of an embodiment of the present invention;
FIG. 7 is a flow diagram of converting a pseudocode expression to a pseudocode expression in the Java language according to an embodiment of the present invention;
FIG. 8 is a flow diagram of converting a pseudo code expression to a Java language expression according to an embodiment of the present invention;
FIG. 9 is a diagram illustrating an embodiment of the present invention for converting a keyword of pseudo code of Java language into a Java language keyword;
FIG. 10 is a flowchart of a method for assembling Java language expressions into rule set Java classes according to an embodiment of the present invention;
FIG. 11 is a schematic diagram of a spelling rule Java method according to the embodiment of the invention;
FIG. 12 is a diagram of a set of assembly rules, java classes, according to an embodiment of the present invention;
FIG. 13 is a block diagram of a syntax parser for a rule run file according to an embodiment of the present invention;
FIG. 14 is a block diagram of a rule parser in accordance with an embodiment of the present invention;
FIG. 15 is a block diagram of a rule logic processor, according to an embodiment of the present invention;
FIG. 16 is a block diagram of an assembly module according to an embodiment of the present invention
FIG. 17 is a functional block diagram of a decision engine of an embodiment of the present invention;
fig. 18 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
Example one
Fig. 1 is a flowchart of a syntax analysis method for a rule running file according to an embodiment of the present invention, and as shown in fig. 1, the method includes:
step S1: and reading the rule running file.
In this embodiment, the rule run file may be read by a Java I/O input/output stream.
Step S2: and analyzing the rule running file to obtain the rule type in the rule running file, and converting the rule content in the rule running file into a pseudo code expression according to the rule type.
In this embodiment, after the rule running file is read, the rule running file is analyzed, and a rule type in the rule running file is analyzed, where the rule type may include: the method comprises the steps of selecting basic types such as free rules, expression rules, score cards, decision tables, decision trees and rule streams, and converting the rule content of each rule type into a pseudo code expression of' if. It can be seen that the embodiment of the invention can support various rule types such as free rules, expression rules, score cards, decision tables, decision trees, rule streams and the like, and call corresponding syntax parsers according to different rule types to parse rule contents, wherein each rule type has one corresponding syntax parser.
Fig. 2 is a schematic diagram of a free rule according to an embodiment of the present invention, and as shown IN fig. 2, the free rule is a pseudo-code rule, and the free rule includes a rule ID (e.g., freerule), and the expression of the rule method IN the rule content (e.g., $ IN _ diameter > =15, $ OUT _ watermelon level: = 'good', $ OUT _ watermelon level = 'good') is expressed IN the form of pseudo-code of the keywords "if", "then", "else", and the like IN the rule content.
Fig. 3 is a schematic diagram of a scorecard according to an embodiment of the present invention, as shown in fig. 3, the scorecard has regular IDs (ruletable), indicators, weights, options, scores, and the like, and the scorecard is a rule supporting weight setting and supporting accumulation and summation; in addition, a rating and scoring card is also arranged, and similar to the rating card, the grading operation is carried out after the accumulation summation is expanded on the basis of the rating card.
FIG. 4 is a schematic diagram of a decision table according to an embodiment of the present invention, as shown IN FIG. 4, the decision table has a rule ID (decision sheet), and the decision table is a graphically configurable rule, such as IN _ diameter, IN _ sweetness, IN _ color, result, etc., and is easy to fill; in addition, the judgment decision table is added with judgment processing of output results on the basis of the decision table; the evaluation decision table is a judgment process which is expanded and supports multiple input and multiple output on the basis of the decision table.
Fig. 5 is a schematic diagram of a decision tree according to an embodiment of the present invention, and as shown in fig. 5, the decision tree also includes a rule ID (e.g., decision tree), and the decision tree is a rule supporting a flow, and is similar to a multi-branch tree, and can perform serial processing on a plurality of rules, and a function node expands the processing of flow judgment or complex logic, for example, when a rule call is started, different rule criteria can be obtained at the same time corresponding to different scores.
Fig. 6 is a schematic diagram of a rule flow according to an embodiment of the present invention, and as shown in fig. 6, the rule flow is also a rule supporting a flow. Unlike decision trees, the rule flow supports champion nodes through which different rules can be invoked based on weight. For example: the champion node is configured with rule 1 (the ratio parameter value is 1) and rule 2 (the ratio parameter value is 2), and when the champion node is called 3 times, rule 2,1 is triggered 2 times and rule 1 is triggered 5363 times.
And step S3: and converting the pseudo code expression into a Java language expression.
Specifically, after the rule content of each rule type is converted into a form of a pseudo code expression such as' if.
And step S4: and assembling the Java language expression to obtain a Java language code.
In this embodiment, the identified Java language expression and the expression of the rule content are assembled into a method by the Java assembly module, and then assembled into a process of the rule Java method.
The embodiment of the invention can convert the rule content according to the rule type and can perform rule customization processing aiming at different service requirements, specific scenes and the like.
Fig. 7 is a flowchart of an embodiment of the present invention for converting a pseudo code expression into a pseudo code expression in Java language, where as shown in fig. 7, in some embodiments, step S2 includes:
step S21: after the rule running file is read, analyzing the rule running file to obtain configuration information related to the rule set in the rule running file; the configuration information includes configuration field information;
step S22: determining the rule type in the rule running file according to the relevant configuration information;
step S23: calling a corresponding grammar parser according to the rule type to process rule contents in the rule running file so as to convert the rule contents into a pseudo code expression;
step S24: and assigning the pseudo code expression to the first Java string variable so as to store the pseudo code expression into the memory of the Java virtual machine in the form of the first Java string variable.
Specifically, analyzing the rule running file to obtain configuration field information related to the rule set in the rule running file; for example, field information such as rule set id, rule set name, rule set priority (configuration information for setting different rule execution orders), rule set expiration time (by setting the expiration time, a rule set can only make a rule call within a specified time), and the like. In addition, a rule set refers to a set of rules consisting of a plurality of rules. A rule run file is a set of rules. Each rule type corresponds to a grammar parser, after the rule type is determined according to the configuration information of the rule operation file, the grammar parser corresponding to the rule type is called to parse the rule content, keywords and rule method expressions in the rule content are converted into a form of pseudo code expressions, the pseudo code expressions are assigned to Java character string variables, and the pseudo code expressions are stored in a Java virtual machine memory in the form of the Java character string variables so as to facilitate subsequent data processing.
In addition, in this embodiment, step S2 may further include:
step S25: and analyzing the rule set in the rule running file according to the configuration field information to obtain rule parameter information related to the rule in the rule set. Specifically, after obtaining the configuration information related to the rule set in the rule running file in step S21, the rule set in the rule running file is parsed according to the configuration field information related to the rule set, so as to obtain the rule parameter information related to the rule in the rule set, where the rule parameter information may include: rule id, rule name, rule input parameters, rule output parameters, derivative index parameters (new parameter variables generated by the input parameters through operations such as addition, subtraction, multiplication, division and the like) and the like; in addition, in some rule sets, besides rule parameter information related to the rules in the rule set, rule constant information related to the rules in the rule set can be obtained; the rule constant information refers to constant field information defined in the rule set, such as c constant defined: the sex is a fixed value of male and female.
According to the embodiment of the invention, the rule running file is analyzed to obtain the configuration field information related to the rule set in the rule running file, and the rule set in the rule running file is analyzed according to the configuration field information related to the rule set to obtain the rule parameter information and the rule constant information related to the rule in the rule set, so that information such as input parameters and output parameters is provided for a subsequent Java assembly method.
Fig. 8 is a flowchart of converting a pseudo code expression into a Java language expression according to an embodiment of the present invention, where, as shown in fig. 8, step S3 includes:
step S31: acquiring a pseudo code expression stored in a first Java character string variable from a memory of a Java virtual machine, and converting the pseudo code expression into a Java language expression;
step S32: and assigning the Java language expression to a second Java string variable so as to store the Java language expression in the memory of the Java virtual machine in the form of the second Java string variable.
The embodiment of the invention can be designed by Java language and realizes the function of regular grammar parsing, namely, if. Fig. 9 is a schematic diagram of converting a keyword of a pseudo code of a Java language into a Java language keyword according to an embodiment of the present invention, and as shown in fig. 9, in this embodiment, the keyword of the pseudo code of the Java language is identified by a Java regular expression, for example, characters such as "if", "then", "otherwise", ";", "{" } "," # "," when satisfied "," loop ","/"," and the like are converted into the Java code. For example, this step processes the "if" character as a Java language keyword if; processing the 'else' character into a Java language keyword else; processing the "#" into comments in the Java language and the like, then assigning Java language keywords to Java string variables to obtain Java language expressions, and loading the Java language expressions to a memory of a Java virtual machine for subsequent assembly modules to assemble.
Fig. 10 is a flowchart of a method for assembling Java language expressions into rule set Java classes according to an embodiment of the present invention, where, as shown in fig. 10, step S4 includes:
step S41: and (3) assembling the Java language expression by taking the rule id in the rule parameter information as a method name, taking the input parameter or the derived index parameter in the rule parameter information as an input parameter of the method and taking the rule output parameter in the rule parameter information as an output parameter of the method to obtain the rule Java method.
Fig. 11 is a schematic diagram of a Java method according to an embodiment of the present invention, and as shown IN fig. 11, IN this step, a rule id is used as a method name (e.g., private), a rule input parameter or a derivative index parameter is used as an input parameter of the method (e.g., xpwpfk (int $ IN _ diameter)), and a rule output parameter is used as an output parameter of the method (return $ OUT _ watermelon rating), so as to perform assembly processing on Java language expressions (e.g., if ($ IN _ diameter = 15), $ OUT _ watermelon flat = 'excellent', eles $ watermelon flat = 'excellent'), thereby obtaining a regular Java method. The rule Java method is the most important step in the syntax parsing method, and the rule pseudo code in the rule running file is converted into the Java method, and the method is called as the rule Java method.
Step S42: taking a rule set id in configuration field information related to a rule set as a Java class name, and adding a rule Java method in the Java class name to obtain a rule set Java class;
fig. 12 is a schematic diagram of a rule set Java Class in the assembly of the embodiment of the present invention, and as shown in fig. 12, in this step, a rule set id is used as a Java Class name (for example, public Class IDX _ grad _01 \\/v 2), and the obtained rule Java method is subjected to assembly processing.
Step S43: and assigning the rule set Java class to a second Java character string variable to obtain a Java language code and loading the Java language code to a memory of the Java virtual machine.
The grammar analysis method provided by the embodiment of the invention has the following beneficial effects:
the embodiment of the invention can support various rule types such as free rules, expression rules, score cards, decision tables, decision trees, rule streams and the like, and call corresponding syntax analyzers to analyze the rule contents according to different rule types;
the embodiment of the invention designs and realizes the grammar parsing function of the rule through the Java language, namely, the' if.
The embodiment of the invention can perform rule customization processing according to business requirements, specific scenes and the like, and perform grammar parsing processing on rules with different scenes and different requirements.
Example two
Fig. 13 is a block diagram of a syntax parsing apparatus for a rule running file according to an embodiment of the present invention, and as shown in fig. 13, the syntax parsing apparatus 100 includes:
a rule running file reading module 10, configured to read a rule running file;
the rule syntax analyzer 20 is configured to analyze the rule running file to obtain a rule type in the rule running file, and convert the rule content in the rule running file into a pseudo code expression according to the rule type;
a rule logic processor 30 for converting the pseudo code expression into a Java language expression;
and the assembling module 40 is used for assembling the Java language expression to obtain a Java language code.
For details, please refer to the embodiment of the method shown in fig. 1.
Fig. 14 is a block diagram showing a structure of a rule parser according to an embodiment of the present invention, and as shown in fig. 14, the rule parser 20 includes:
the rule parsing processing sub-module 201 is configured to parse the rule running file after the rule running file is read, and obtain configuration information related to the rule set in the rule running file; the configuration information includes configuration field information.
The rule type determining submodule 202 is configured to determine a rule type in the rule running file according to the relevant configuration information;
the rule content conversion submodule 203 is used for calling a corresponding grammar parser according to the rule type to process the rule content in the rule operation file so as to convert the rule content into a pseudo code expression;
the first assignment and loading sub-module 204 is configured to assign the pseudo code expression to a first Java string variable, so as to store the pseudo code expression in a form of the first Java string variable in a memory of the Java virtual machine.
For details, please refer to the embodiment of the method shown in fig. 7.
Fig. 15 is a block diagram of a rule logic processor according to an embodiment of the present invention, and as shown in fig. 15, the rule logic processor 30 includes:
an obtaining and transforming module 301, configured to obtain a pseudo code expression stored in a first Java string variable from a memory of the Java virtual machine, and transform the pseudo code expression into a Java language expression;
and the second assignment and loading sub-module 302 is configured to assign the Java language expression to a second Java string variable, so that the Java language expression is stored in the memory of the Java virtual machine in the form of the second Java string variable.
For details, please refer to the method embodiment shown in fig. 8.
Fig. 16 is a block diagram of a construction of a splicing module according to an embodiment of the present invention, and as shown in fig. 16, the splicing module 40 includes:
the Java method assembling submodule 401 is configured to assemble a Java language expression by using a rule id in the rule parameter information as a method name, using an input parameter or a derivative index parameter in the rule parameter information as an input parameter of a method, and using a rule output parameter in the rule parameter information as an output parameter of the method, so as to obtain a rule Java method;
the Java class assembling submodule 402 is configured to add a rule Java method to a Java class name by using a rule set id in the rule set information as the Java class name to obtain a rule set Java class;
and a third assignment and loading submodule 403, configured to assign a rule set Java class to a second Java string variable, convert the second Java string variable into a Java language code, and load the Java language code into a memory of the Java virtual machine.
For details, please refer to the embodiment of the method shown in fig. 9.
The grammar analysis device provided by the embodiment of the invention has the following beneficial effects:
the embodiment of the invention can support various rule types such as free rules, expression rules, score cards, decision tables, decision trees, rule streams and the like, and call corresponding syntax analyzers to analyze the rule contents according to different rule types;
the embodiment of the invention designs and realizes the grammar parsing function of the rule through the Java language, namely, the' if.
The embodiment of the invention can perform rule customization processing according to business requirements, specific scenes and the like, and perform grammar parsing processing on rules with different scenes and different requirements.
EXAMPLE III
Fig. 17 is a functional block diagram of a decision engine according to an embodiment of the present invention, and as shown in fig. 17, the decision engine 500 includes:
a decision engine definition module 501, configured to add, modify, or store a rule definition file, and generate a rule running file after the rule definition file is released and deployed;
specifically, the decision engine definition module 501 has a regular adding and deleting function, a regular issuing and deploying function, a regular monitoring function, a regular model library management function, a regular index library management function, and the like, and the decision engine definition module 501 may generate a new file by issuing and deploying an edited rule definition file (suffix: rule/version) through an interfacing operation, and thus the rule running file is a new file generated by the rule definition file after passing through the issuing and deploying function, and the file suffix is rule or round.
A decision engine running module 502, configured to read, load, parse and compile and calculate the rule running file, where the decision engine running module 502 includes the syntax analysis apparatus 100.
Specifically, the decision engine running module 502 performs syntax analysis on the read rule running file through the syntax analysis device 100, converts the rule pseudo code into a Java language executable method, and performs a process of obtaining a calculation result by method call.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present invention. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
Example four
Fig. 18 is a block diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 18, an embodiment of the present application further provides an electronic device 600, where the electronic device includes:
at least one processing device 601; and the number of the first and second groups,
a memory 602 communicatively coupled to the at least one processing device 601; wherein the memory storage 602 has instructions executable by the at least one processing device 601, the instructions being executable by the at least one processing device 601 to enable the at least one processing device 601 to perform a method of parsing a rule run file in the method embodiments described above.
The present application also provides a non-transitory computer readable storage medium storing computer instructions for causing the computer to execute a method for parsing a rule run file in the foregoing method embodiment.
Embodiments of the present application also provide a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, cause the computer to perform a method of parsing a rule run file in one of the aforementioned method embodiments.
Referring now to FIG. 18, shown is a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present application. The electronic device 600 in the embodiment of the present application may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle-mounted terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device 600 shown in fig. 18 is only an example, and should not bring any limitation to the functions and the use range of the embodiment of the present application.
As shown in fig. 18, the electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM602, and the RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keys, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While the figures illustrate an electronic device 600 having various means, it is understood that not all illustrated means are required to be implemented or provided. More or fewer devices may be alternatively implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer-readable medium, the computer program comprising program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present application.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing. The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The above description is only for the specific embodiments of the present disclosure, but the scope of the present disclosure is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present disclosure should be covered within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (7)

1. A method for parsing a rule run file, the method comprising:
step S1: reading a rule running file;
step S2: analyzing the rule running file to obtain a rule type in the rule running file, and converting the rule content in the rule running file into a pseudo code expression according to the rule type;
and step S3: converting the pseudo code expression into a Java language expression;
and step S4: assembling the Java language expression to obtain a Java language code;
the step S2 includes:
step S21: analyzing the rule running file to obtain configuration information related to a rule set in the rule running file; the configuration information comprises configuration field information;
step S22: determining the rule type in the rule running file according to the configuration information;
step S23: calling a corresponding grammar parser according to the rule type, and processing rule contents in the rule running file through the grammar parser so as to convert the rule contents into a pseudo code expression;
step S24: assigning the pseudo code expression to a first Java string variable so as to store the pseudo code expression to a memory of a Java virtual machine in the form of the first Java string variable;
step S25: analyzing a rule set in the rule running file according to the configuration field information to obtain rule parameter information related to the rule in the rule set;
the step S3 includes:
step S31: acquiring a pseudo code expression stored in the first Java character string variable from a memory of the Java virtual machine, and converting the pseudo code expression into a Java language expression;
step S32: assigning the Java language expression to a second Java string variable so as to store the Java language expression in the memory of the Java virtual machine in the form of the second Java string variable;
the step S4 includes:
step S41: taking a rule id in the rule parameter information as a method name, taking an input parameter or a derivative index parameter in the rule parameter information as an input parameter of a rule Java method, taking a rule output parameter in the rule parameter information as an output parameter of the rule Java method, and splicing the Java language expression to obtain the rule Java method;
step S42: taking a rule set id in configuration field information related to the rule set as a Java class name, and adding the rule Java method in the Java class name to obtain a rule set Java class;
step S43: and assigning the rule set Java class to the second Java character string variable to obtain a Java language code and loading the Java language code to a memory of a Java virtual machine.
2. The syntax analysis method according to claim 1, wherein said step S42 further comprises: adding Java exception processing codes and Java log processing codes in the rule set Java class.
3. An apparatus for parsing a regular running file, the apparatus comprising:
the rule running file reading module is used for reading the rule running file;
the rule syntax analyzer is used for analyzing the rule operation file to obtain a rule type in the rule operation file and converting the rule content in the rule operation file into a pseudo code expression according to the rule type;
the rule logic processor is used for converting the pseudo code expression into a Java language expression;
the assembling module is used for assembling the Java language expression to obtain a Java language code;
the rule parser comprises:
the rule analysis processing submodule is used for analyzing the rule operation file to obtain configuration information related to a rule set in the rule operation file; the configuration information comprises configuration field information;
the rule type determining submodule is used for determining the rule type in the rule running file according to the configuration information;
the rule content conversion sub-module is used for calling a corresponding grammar parser according to the rule type, processing the rule content in the rule operating file through the grammar parser and converting the rule content into a pseudo code expression;
the first assignment and loading submodule is used for assigning the pseudo code expression to a first Java string variable so as to store the pseudo code expression to a memory of a Java virtual machine in the form of the first Java string variable; and the number of the first and second groups,
a submodule for analyzing the rule set in the rule running file according to the configuration field information to obtain rule parameter information related to the rule in the rule set;
the rule logic processor includes:
the obtaining and transforming module is used for obtaining a pseudo code expression stored in the first Java character string variable from a memory of the Java virtual machine and transforming the pseudo code expression into a Java language expression;
the second assignment and loading submodule is used for assigning the Java language expression to a second Java string variable so as to store the Java language expression in the memory of the Java virtual machine in the form of the second Java string variable;
the assembly module comprises:
the Java method assembling submodule is used for assembling the Java language expression by taking the rule id in the rule parameter information as a method name, taking the input parameter or the derived index parameter in the rule parameter information as the input parameter of the rule Java method and taking the rule output parameter in the rule parameter information as the output parameter of the rule Java method to obtain the rule Java method;
the Java class assembly submodule is used for taking a rule set id in the configuration field information related to the rule set as a Java class name, and adding the rule Java method into the Java class name to obtain a rule set Java class;
and the third assignment and loading submodule is used for assigning the rule set Java class to the second Java character string variable, obtaining a Java language code and loading the Java language code to a memory of a Java virtual machine.
4. The syntax analysis device according to claim 3, wherein the Java class assembling submodule is further configured to add Java exception handling codes and Java log handling codes to the rule set Java class.
5. A decision engine apparatus, comprising:
the decision engine definition module is used for newly adding, modifying or storing a rule definition file, issuing and deploying the rule definition file and then generating a rule running file;
the decision engine operation module is used for reading, loading, parsing and compiling the rule operation file, wherein the decision engine operation module comprises a syntax analysis device of the rule operation file according to claim 3 or 4.
6. An electronic device, characterized in that the electronic device comprises:
at least one processing device; and the number of the first and second groups,
a memory communicatively coupled to the at least one processing device; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processing device to enable the at least one processing device to perform a method of parsing a rule run file according to claim 1 or 2.
7. A non-transitory computer readable storage medium storing computer instructions for causing a computer to perform a method of parsing a rule run file according to claim 1 or 2.
CN202210714784.9A 2022-06-23 2022-06-23 Grammar analysis method and device of rule running file and decision engine Active CN114780107B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210714784.9A CN114780107B (en) 2022-06-23 2022-06-23 Grammar analysis method and device of rule running file and decision engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210714784.9A CN114780107B (en) 2022-06-23 2022-06-23 Grammar analysis method and device of rule running file and decision engine

Publications (2)

Publication Number Publication Date
CN114780107A CN114780107A (en) 2022-07-22
CN114780107B true CN114780107B (en) 2022-10-28

Family

ID=82422529

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210714784.9A Active CN114780107B (en) 2022-06-23 2022-06-23 Grammar analysis method and device of rule running file and decision engine

Country Status (1)

Country Link
CN (1) CN114780107B (en)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7136843B2 (en) * 2002-10-23 2006-11-14 International Business Machines Corporation Object-oriented framework for reasoning having pluggable inference engines
CN108628947B (en) * 2018-04-02 2022-07-15 创新先进技术有限公司 Business rule matching processing method, device and processing equipment
CN110704037B (en) * 2019-08-28 2024-01-05 贵州医渡云技术有限公司 Rule engine implementation method and device
CN112069214A (en) * 2020-09-09 2020-12-11 北京字节跳动网络技术有限公司 Rule processing method, device, equipment and storage medium
CN113204540A (en) * 2021-05-28 2021-08-03 中国建设银行股份有限公司 Rule engine configuration method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN114780107A (en) 2022-07-22

Similar Documents

Publication Publication Date Title
CN109976793B (en) Application program running method, device, equipment and medium
CN110764748B (en) Code calling method, device, terminal and storage medium
CN111367516B (en) Application interface generation method and device and electronic equipment
CN110377289A (en) A kind of data analysis method, device, medium and electronic equipment
CN112817657B (en) Application program starting item loading method, device, system and storage medium
CN111240684A (en) Cutting method and device of JS code, medium and electronic equipment
CN114035805A (en) Code conversion method, apparatus, medium, and device for pre-compiler
CN115221191A (en) Virtual column construction method based on data lake and data query method
CN113419740A (en) Program data stream analysis method and device, electronic device and readable storage medium
CN111124541B (en) Configuration file generation method, device, equipment and medium
CN114780107B (en) Grammar analysis method and device of rule running file and decision engine
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN116860286A (en) Page dynamic update method, device, electronic equipment and computer readable medium
CN114968260A (en) Hybrid pre-compiling method and device, electronic equipment and storage medium
CN111796865B (en) Byte code file modification method, device, terminal equipment and medium
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text
CN110297639B (en) Method and apparatus for detecting code
CN111626045A (en) Character length calculation method and device and electronic equipment
CN112306584A (en) Application program operation control method, device, medium and equipment
CN111797009A (en) Method and device for detecting code compatibility and electronic equipment
CN112445820A (en) Data conversion method and device
CN109740100B (en) Webpage node sniffing method, device, equipment and storage medium
CN116467178B (en) Database detection method, apparatus, electronic device and computer readable medium
CN115563183B (en) Query method, query device and program product
CN116954618A (en) Function compiling method, device, medium and electronic equipment

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