A method, system and device for converting domain model language and general decision table

By converting SAS Enterprise Miner software into a syntax tree structure data and generating intermediate structure data, the general decision -making form is finally generated, which solves the problem of low existing technology conversion efficiency, and realizes the creation of automated conversion and efficient decision -making trees.

CN119088822BActive Publication Date: 2025-01-28KINCHENG BANK OF TIANJIN CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411586453.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-01-28
Estimated Expiration
2044-11-08

AI Technical Summary

Technical Problem

The prior art when converting script files of SAS Enterprise Miner software into decision tables, the conversion efficiency is inefficient, the process is cumbersome and error-prone.

Method used

Based on the grammatical rules, the grammatical parser is used to convert the decision tree model file into grammatical tree structure data, and the grammatical tree data is used to generate the intermediate structure data according to the preset data conversion rules. General decision decision form.

Benefits of technology

The automation conversion process was achieved, the creation of decision trees was simplified, the conversion efficiency was improved, and the occurrence of artificial mistakes was reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119088822B_ABST
    Figure CN119088822B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of decision engines, and in particular to a method, system and device for converting a domain model language to a general decision table. The method comprises: based on a grammar rule parsing file, a grammar parser is used to convert a decision tree model file into grammar tree structure data; wherein the decision tree model file is a script file exported from a model data mining tool; the grammar rule parsing file is obtained according to the grammar rule setting of the decision tree model file; traversing the grammar tree structure data and converting the grammar tree structure data into intermediate structure data according to preset data conversion rules; generating a general decision table that conforms to the target decision engine according to the intermediate structure data, and the general decision table is used to instruct the target decision engine to generate a decision tree. In this way, the problem of low conversion efficiency when converting the script file of SAS Enterprise Miner software into a decision table can be effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of decision engines, and in particular to a method, system and device for converting a domain model language into a general decision table. Background Art

[0002] ANTLR (Another Tool for Language Recognition) is an open source grammar analyzer that can automatically generate a syntax tree based on the input and display it visually.

[0003] SAS Enterprise Miner (a model data mining tool) has outstanding power and impact due to its support for the SAS statistical module, which is enhanced by a large number of data mining algorithms. SAS uses its SEMMA methodology to provide a model data mining tool that supports a wide range of models including association, clustering, decision trees, neural networks and statistical regression.

[0004] Currently, when converting the script of SAS Enterprise Miner (model data mining tool) software into a decision table, a new decision tree is manually created in the decision engine system. The creation process is cumbersome, error-prone, and the conversion efficiency is low. Summary of the invention

[0005] In view of this, an embodiment of the present application provides a method, system and device for converting a domain model language into a general decision table, which can effectively solve the problem of low conversion efficiency when converting a script file of SAS Enterprise Miner software into a decision table.

[0006] In a first aspect, an embodiment of the present application provides a method for converting a domain model language to a general decision table, including:

[0007] Based on the grammar rule parsing file, the decision tree model file is converted into grammar tree structure data by using a grammar parser; wherein the decision tree model file is a script file exported from a model data mining tool; and the grammar rule parsing file is obtained according to the grammar rule setting of the decision tree model file;

[0008] Traversing the syntax tree structure data and converting the syntax tree structure data into intermediate structure data according to a preset data conversion rule;

[0009] A general decision table that meets the target decision engine is generated according to the intermediate structure data, and the general decision table is used to instruct the target decision engine to generate a decision tree.

[0010] In some embodiments, the intermediate structure data is data of a Java array type; wherein the Java array includes a plurality of multi-level key-value pair objects and sub-arrays mixed and nested array elements; wherein each sub-array is used as a key value of an element in a key-value pair object at a corresponding level; each sub-array includes at least one array element composed of a key-value pair object at a next level;

[0011] The traversing the syntax tree structure data and converting the syntax tree structure data into intermediate structure data according to a preset data conversion rule includes:

[0012] Traverse from the root node of the syntax tree structure data to the leaf node direction, generate multi-level key-value pair objects and sub-array mixed nested array elements according to the hierarchical relationship of the child nodes; the node information of each level is used as the key of the element in the key-value pair object, and the sub-array is used as the key value of the key-value pair object; several nodes of the next level respectively use the key-value pair object to form the elements in the sub-array of the corresponding level; wherein specifically includes: generating the terminal key-value pair object according to the child nodes connected to the leaf node; the key value of the terminal key-value pair object is the terminal array; storing the leaf node information of each child node as an element in the terminal array; if a node is connected to multiple child nodes of the same level, the corresponding level of the sub-array includes multiple corresponding key-value pair objects;

[0013] The intermediate structure data is generated according to the array elements in which multiple multi-level key-value pair objects and sub-arrays are mixed and nested.

[0014] In some embodiments, the intermediate structure data includes an input statement key-value pair object and an output statement key-value pair object; the key value of the element in the input statement key-value pair object is an input element array; the input element array includes a rule key-value pair object; the terminal array in the output statement key-value pair object includes a node identifier key-value pair object;

[0015] The step of generating a general decision table that meets the target decision engine according to the intermediate structure data includes:

[0016] Traverse the elements at all levels in the Java array to obtain the input statement key-value pair object and the output statement key-value pair object;

[0017] According to the information in the rule key-value pair object, determine to store the input statement information in the corresponding input statement key-value pair object into the input statement set;

[0018] According to the information in the node identifier key-value pair object, determine to store the output statement information in the corresponding output statement key-value pair object into the output statement set;

[0019] Converting the information in each rule key-value pair object in the input statement set into an information format that conforms to the target decision engine to obtain a rule information list set;

[0020] The general decision table is generated according to the input statement set, the output statement set and the rule information list set.

[0021] In some embodiments, generating the general decision table according to the input statement set, the output statement set and the rule information list set includes:

[0022] Generate a first decision table array according to each input statement information associated in the input statement set and the corresponding output statement information in the output statement set;

[0023] Generate a second decision table array according to the rule information list set;

[0024] Using the first decision table array and the second decision table array as key values ​​respectively, obtaining a first key-value pair object and a second key-value pair object; obtaining a decision table element according to the first key-value pair object and the second key-value pair object;

[0025] The general decision table is obtained according to each decision table element.

[0026] In some embodiments, the method further comprises:

[0027] Generating a custom variable applicable to the target decision engine according to the intermediate structure data, wherein the custom variable is used to instruct the target decision engine to generate the decision tree, specifically comprising:

[0028] Traversing the intermediate structure data to obtain each preceding assignment statement node;

[0029] Obtaining a target variable set defined in the target decision engine;

[0030] Filtering variable assignment statement nodes in each of the preceding assignment statement nodes, and acquiring corresponding target variables in the target variable set; storing the variables in the variable assignment statement and the target variables as key-value pairs into preset map data;

[0031] The map data and the target variable set are both used to instruct the target decision engine to generate the decision tree; traverse the intermediate structure data to obtain the if conditional statement, the elseif conditional statement and the else conditional statement respectively, and obtain the primary condition and the secondary condition accordingly;

[0032] Recursively perform the conditions of the child nodes corresponding to the if conditional statement, the elseif conditional statement and the else conditional statement respectively, and obtain the first-level sub-conditions, the second-level sub-conditions and the third-level sub-conditions;

[0033] A first-level combination condition is generated according to the first-level condition and the first-level sub-conditions; a second-level combination condition is generated according to the second-level condition and the second-level sub-conditions; and a third-level combination condition is generated according to the third-level sub-conditions.

[0034] In some embodiments, the if conditional statement, the elseif conditional statement, and the else conditional statement respectively recursively correspond to the conditions of the child nodes, and obtain the first-level sub-conditions, the second-level sub-conditions, and the third-level sub-conditions, respectively, including:

[0035] The if conditional statement, the elseif conditional statement and the else conditional statement respectively correspond to the conditions of the child nodes, and each of the first-level sub-conditions, each of the second-level sub-conditions and each of the third-level sub-conditions are pushed into a stack respectively; if the traversal finds that the decision object node is not empty, then the decision object node is a leaf node, then each of the first-level sub-conditions, each of the second-level sub-conditions and each of the third-level sub-conditions are popped out from the stack one by one to generate combined conditions at each level.

[0036] In some embodiments, the model data mining tool is SAS Enterprise Miner; the decision tree model file is a .sas decision tree model file; the syntax parser is ANTLR; the syntax rule parsing file is a g4 syntax rule parsing file;

[0037] The method of parsing the file based on grammar rules and converting the decision tree model file into grammar tree structure data using a grammar parser includes:

[0038] Get the .sas decision tree model file exported from SAS Enterprise Miner;

[0039] Obtain a g4 grammar rule parsing file set according to the grammar rule of the .sas decision tree model file;

[0040] Based on the g4 grammar rule parsing file, ANTLR is used to convert the .sas decision tree model file into grammar tree structure data.

[0041] In a second aspect, an embodiment of the present application provides a conversion system between a domain model language and a general decision table, including: a model data mining tool, a syntax parser, a target decision engine, and a controller;

[0042] The controller is used to generate a general decision table according to a method for converting a domain model language and a general decision table provided in the first aspect of the present application;

[0043] The model data mining tool is used to construct a decision tree model file;

[0044] The target decision engine is used to generate a decision tree by executing the general decision table based on the syntax parser.

[0045] In some embodiments, the intermediate structure data is data of a Java array type; wherein the Java array includes a plurality of multi-level key-value pair objects and sub-arrays mixed and nested array elements; wherein each sub-array is used as a key value of an element in a key-value pair object at a corresponding level; each sub-array includes at least one array element composed of a key-value pair object at a next level;

[0046] The controller is specifically used for:

[0047] Traverse from the root node of the syntax tree structure data to the leaf node direction, generate a multi-level key-value pair object and a sub-array mixed nested array element according to the hierarchical relationship of the child nodes; the node information of each level is used as the key of the element in the key-value pair object, and the sub-array is used as the key value of the key-value pair object; several nodes of the next level respectively use the key-value pair object to form the elements in the sub-array of the corresponding level; wherein specifically include: the key value of the value pair object is the terminal array; the leaf node information of each child node is stored as an element in the terminal array; if a node is connected to multiple child nodes of the same level, the corresponding level of the sub-array includes multiple corresponding key-value pair objects;

[0048] The intermediate structure data is generated according to the array elements in which multiple multi-level key-value pair objects and sub-arrays are mixed and nested.

[0049] In a third aspect, an embodiment of the present application provides a terminal device, comprising a processor and a memory, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement a method for converting a domain model language and a general decision table provided in the first aspect of the present application.

[0050] The embodiments of the present application have the following beneficial effects:

[0051] The present application utilizes a syntax parser and a syntax rule parsing file to convert a decision tree model file into syntax tree structure data; wherein the decision tree model file is a script file exported from a model data mining tool; the syntax rule parsing file is obtained according to the syntax rule settings of the decision tree model file; the syntax tree structure data is traversed and converted into intermediate structure data according to preset data conversion rules; a general decision table that conforms to the target decision engine is generated according to the intermediate structure data, and the general decision table is used to instruct the target decision engine to generate a decision tree. In the present application, there is no need to manually create a new decision tree in the decision engine system. The present application can automatically generate a general decision table, and the creation process is simple, error-prone, and has high conversion efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0053] Figure 1 A structural block diagram of a conversion system between a domain model language and a general decision table in an embodiment of the present application is shown;

[0054] Figure 2 A flow chart showing a method for converting a domain model language and a general decision table according to an embodiment of the present application;

[0055] Figure 3 A structural schematic diagram of a device for converting a domain model language and a general decision table according to an embodiment of the present application is shown.

[0056] Description of main component symbols:

[0057] 100 - controller; 200 - model data mining tool; 300 - syntax parser; 400 - target decision engine; 1110 - syntax tree generation module; 1120 - intermediate structure data generation module; 1130 - decision table generation module. DETAILED DESCRIPTION

[0058] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0059] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0060] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.

[0061] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.

[0062] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0063] After business personnel create a decision table visually through a third-party modeling software, they need to manually convert it into the decision table format in the target decision engine before importing it into the target decision engine. This conversion process is cumbersome and time-consuming, and there is an urgent need for a tool to automatically convert the decision table script of the modeling software into a general decision table in a recognizable format. Therefore, the present application provides a method, system and device for converting a domain model language and a general decision table to improve conversion efficiency, etc.

[0064] The present application provides a conversion system between a domain model language and a general decision table. For example, Figure 1 As shown, the system includes: a controller 100 , a model data mining tool 200 , a syntax parser 300 and a target decision engine 400 .

[0065] The model data mining tool 200 is used to construct a decision tree model file.

[0066] The syntax parser 300 is used to parse the file based on the syntax rules and convert the decision tree model file into syntax tree structure data.

[0067] The controller 100 is used to generate a general decision table according to a conversion method between a domain model language and a general decision table provided in the present application.

[0068] The target decision engine 400 is used to generate a decision tree according to the general decision table.

[0069] The following describes the conversion method between the domain model language and the general decision table in conjunction with some specific embodiments.

[0070] Figure 2 A flow chart of a method for converting a domain model language to a general decision table according to an embodiment of the present application is shown. Exemplarily, the method for converting a domain model language to a general decision table includes the following steps:

[0071] S100, based on the grammar rule parsing file, the grammar parser 300 is used to convert the decision tree model file into grammar tree structure data; wherein the decision tree model file is a script file exported from the model data mining tool 200; the grammar rule parsing file is obtained according to the grammar rule setting of the decision tree model file. The grammar rule parsing file is used to describe the structure and grammar of the decision tree model file.

[0072] Further, exemplarily, the model data mining tool 200 is SAS Enterprise Miner; the decision tree model file is a .sas decision tree model file; the syntax parser 300 is ANTLR; and the syntax rule parsing file is a g4 syntax rule parsing file (referred to as g4 file, .g4 file).

[0073] Among them, the g4 grammar rule parsing file includes a grammar rule definition part, a statement definition part, a grammar analysis part and a lexical analysis part; the lexical analysis part defines values, quotation marks, keywords, etc. Exemplarily, the lexical analysis part defines what is a value, what is a quotation mark, what is a keyword (such as IF, DO, NOT, TRUE), etc. The grammar analysis part defines integers, decimals, strings, constants, etc. The grammar analysis part defines what is an integer, what is a decimal, what is a string, what is a constant, etc. The statement definition part specifically defines what is a method function statement, what is an assignment statement, etc. The grammar rule definition part defines the grammar rules of the .sas decision tree model file (referred to as sas script file). The keywords, grammar rules, statements, etc. defined in the g4 file are all used to identify the content in the sas script file. Each line of definition in the g4 file will be automatically generated by ANTLR (such as antlr4) A callback method, this application can overload the callback method to implement the business logic of this application.

[0074] In step S100, the grammar rule-based parsing file, using the grammar parser 300 to convert the decision tree model file into grammar tree structure data, includes:

[0075] S110, obtaining a .sas decision tree model file exported from SAS Enterprise Miner.

[0076] SAS Enterprise Miner is a powerful data analysis and model mining tool. It provides a complete data science workflow including data preprocessing, modeling, evaluation, and deployment. After the user completes model building in SAS Enterprise Miner, it can be exported as a SAS data set (.sas file, file with sas suffix). The exported SAS file structure usually includes the following parts:

[0077] (1) Dataset definition section: The dataset definition section contains the basic information of the dataset, such as the name of the dataset, data type, number and name of variables. Among them, `project` represents the library name where the dataset is located, and `DatasetName` represents the specific dataset name.

[0078] (2) Variable definition: The variable definition section describes each variable in the data set in detail. Each variable usually starts with the variable name, data type, length, and possible default value, for example: VariableName TYPE=NumericLENGTH=8 DEFAULT=0. VariableName is the variable name, TYPE specifies the variable type (such as `Numeric`, `Char`, etc.), `LENGTH` specifies the length of character variables, and `DEFAULT` specifies the default value for missing values.

[0079] (3) Record data. Record data is the main part of the data set, which contains all the observation records. Each row represents an observation and each column represents a variable. For example:

[0080] ```sas

[0081] 123.45"Sample Text"2023Q190

[0082] 56.78"Another Text"2023Q275

[0083] ```

[0084] Each field is usually separated by spaces, tabs, or commas.

[0085] (4) End marker: There is usually an end marker at the end of the data set, indicating the end of the data set: ```sasRUN;```.

[0086] S120, obtaining a g4 grammar rule parsing file set according to the grammar rule of the .sas decision tree model file.

[0087] S130, based on the g4 grammar rule parsing file, using ANTLR to convert the .sas decision tree model file into grammar tree structure data. The grammar tree structure data is an abstract syntax tree AST.

[0088] Specifically, firstly, a g4 grammar rule parsing file is written according to the grammar rules of the .sas decision tree model file (sas script file), and the idea plug-in is used (installing the ANTLR plug-in in idea can more conveniently configure, generate code and test the grammar file, thereby accelerating the development process), to parse the g4 grammar rule parsing file, and automatically generate several java code classes for the g4 grammar rule parsing file. For example, the key interface SasGrammarVisitor.class and the key class SasCustomVisitor.class. The java code class will generate a traversal callback method for each node defined in the g4 grammar rule parsing file. When actually parsing the sas script file, the sas script file is traversed, and the callback method corresponding to the node is called when the node is hit. Then the actual content of the script can be obtained in the callback method, and the parsed data is filled into the corresponding fields in the intermediate structure data defined in java.

[0089] S200, traversing the syntax tree structure data and converting the syntax tree structure data into intermediate structure data according to a preset data conversion rule.

[0090] Exemplarily, the intermediate structure data is data of a Java array type; wherein the Java array includes array elements that are mixed and nested with multiple multi-level key-value pair objects and sub-arrays; wherein each level of sub-array serves as the key value of the element in the key-value pair object of the corresponding level; and each level of sub-array includes at least one array element composed of the key-value pair object of the next level.

[0091] For example, the Java array is {"item":{"decisionItems": [{"identifier": "_NODE_","operator": "=","originText": "_NODE_=33","decision item type": "assign","assignment value": "33"}]}},{"ifComb":{"condition":{"operator": "AND","rules":[{"arguments":["'325FD0C2D2BBA1A11A'x"],"identifier": "_ARBFMT_12","operator":"IN","originText": "_ARBFMT_12IN('325FD0C2D2BBA1A11A'x)"}]}}}}。

[0092] S300, generating a general decision table that meets the target decision engine 400 according to the intermediate structure data, wherein the general decision table is used to instruct the target decision engine 400 to generate a decision tree.

[0093] Furthermore, the intermediate structure data is data of Java array type; wherein the Java array includes array elements of multiple multi-level key-value pair objects and sub-arrays mixed and nested; wherein each level of sub-array serves as the key value of the element in the key-value pair object of the corresponding level; each level of sub-array includes at least one array element composed of the key-value pair object of the next level.

[0094] In step S200, traversing the syntax tree structure data and converting the syntax tree structure data into intermediate structure data according to a preset data conversion rule includes:

[0095] Traverse from the root node of the syntax tree structure data to the leaf node direction, generate multi-level key-value pair objects and sub-array mixed nested array elements according to the hierarchical relationship of the child nodes; the node information at each level is used as the key of the element in the key-value pair object, and the sub-array is used as the key value of the key-value pair object; several nodes at the next level respectively use the key-value pair object to form the elements in the sub-array of the corresponding level; wherein specifically includes: generating the terminal key-value pair object according to the child nodes connected to the leaf node; the key value of the terminal key-value pair object is the terminal array; storing the leaf node information of each child node as an element in the terminal array; if a node is connected to multiple child nodes of the same level, the corresponding level of the sub-array includes multiple corresponding key-value pair objects;

[0096] The intermediate structure data is generated according to the array elements in which multiple multi-level key-value pair objects and sub-arrays are mixed and nested.

[0097] Taking elseIfComb as an example, when traversing the IfStatement in the callback abstract syntax tree AST, determine whether there are elseIfItems in ifStatement; if so, traverse elseIfItems and place the corresponding information of elseIfItems into elseIfComb of the intermediate structure data. Each attribute is assigned to the key-value pair corresponding to elseIfComb in the callback function. Among them, if it is determined that decisionItem is not empty, then the node is already a leaf node.

[0098] Furthermore, the intermediate structure data includes an input statement key-value pair object and an output statement key-value pair object; the key value of the element in the input statement key-value pair object is an input element array; the input element array includes a rule key-value pair object. The terminal array in the output statement key-value pair object includes a node identifier key-value pair object.

[0099] In step S300, generating a general decision table that meets the target decision engine 400 according to the intermediate structure data includes:

[0100] S310, traverse the elements at each level in the Java array to obtain the input statement key-value pair object and the output statement key-value pair object.

[0101] S320, based on the information in the rule key-value pair object, determine to store the input statement information in the corresponding input statement key-value pair object into the input statement set. For example, traverse one by one, and determine which type of rule is satisfied according to the rules in the node identifier key-value pair object, such as comparison rules, in conditional rules and function rules, and then place them into the input statement set InputVars. The element "operator": "IN" in the key value corresponding to the "rules" key in the intermediate structure data indicates that the rule is an in conditional rule. When used to construct a decision table, the way the conditions are written, different rule types, and the way they are finally converted into the decision engine are different.

[0102] S330, according to the information in the node identifier key-value pair object, determine to store the output statement information in the corresponding output statement key-value pair object into the output statement set. For example, extract the statement whose key is identifier and whose key value is the keyword "_NODE_", and then place it into the output statement set outputVars.

[0103] S340, converting the information in each rule key-value pair object in the input statement set into an information format that conforms to the target decision engine 400, and obtaining a rule information list set.

[0104] For example, the conversion rule is a specific data row. For example, the comparison symbols in the code are mathematical symbols, such as >, <, ≥ and ≤, etc., which are converted into corresponding greater than, less than, greater than or equal to, and less than or equal to, etc. in the target decision engine 400.

[0105] S350, generating the general decision table according to the input statement set, the output statement set and the rule information list set.

[0106] Finally, it is converted into the data structure of the decision table in the decision engine system, such as a two-dimensional array, that is, List <List <string>>rows = new ArrayList<>().

[0107] Exemplarily, the general decision table of the final target decision engine 400 is:

[0108] {"headers":["input:null","input:earliestRecordCredi","output:_NODE_"],"rows":[["","","33"],["IN\"'325FD0C2D2BBA1A11A'x\"","","22"],["IN\"'325FD0C2D2BBA1A11A'x\"","less than 64.5","11"]]}. Preferably, the general decision table is Excel data. Each element in "headers" is the table header. "rows" is a two-dimensional array, and each record in the first dimension is a row. The data in the second dimension corresponds to each column of each row.

[0109] The intermediate structure data is converted into Excel, or imported into the target decision engine 400 to automatically generate a decision tree.

[0110] Furthermore, in step S350, generating the general decision table according to the input statement set, the output statement set and the rule information list set includes:

[0111] S351, generating a first decision table array according to each input statement information associated in the input statement set and the corresponding output statement information in the output statement set.

[0112] S352: Generate a second decision table array according to the rule information list set.

[0113] S353: Use the first decision table array and the second decision table array as key values ​​respectively to obtain a first key-value pair object and a second key-value pair object; and obtain a decision table element according to the first key-value pair object and the second key-value pair object.

[0114] S354: Obtain the general decision table according to the elements of each decision table.

[0115] In one embodiment, the method further comprises:

[0116] S500, generating a custom variable suitable for the target decision engine 400 according to the intermediate structure data, wherein the custom variable is used to instruct the target decision engine 400 to generate the decision tree.

[0117] That is, the intermediate structure data is traversed to convert both the condition variables and the result variables into the customized variables inside the target decision engine 400, specifically including:

[0118] S510, traverse the intermediate structure data to obtain each preceding assignment statement node.

[0119] S520, obtaining a target variable set defined in the target decision engine 400. S530, screening variable assignment statement nodes in each of the preceding assignment statement nodes, and obtaining corresponding target variables in the target variable set; storing the variables in the variable assignment statement and the target variables as key-value pairs in the preset map data.

[0120] For example, for the assignment statement: _ARBFMT_12 = PUT( city_level , $12.); the intermediate data structure

[0121] In the structure, "_ARBFMT_12" is used. This application maps it to ("_ARBFMT_12", "city_level") and then places it in the Map object. Later, the target decision engine 400 replaces "_ARBFMT_12" with "city_level". "City_level" has been defined in the target decision engine 400 in advance for use when it is finally converted into a decision tree. Among them, the business personnel define the city_level field in the decision engine in advance. Then when defining it in the sas software, a city_level will be defined according to the name. Then, in the sas file conversion process, the city_level defined in the decision engine is matched.

[0122] S540, the map data and the target variable set are used to instruct the target decision engine 400 to generate the decision tree; traverse the intermediate structure data, respectively obtain the if conditional statement, the elseif conditional statement and the else conditional statement, and obtain the primary condition and the secondary condition accordingly;

[0123] S550, recursively perform the conditions of the child nodes corresponding to the if conditional statement, the elseif conditional statement, and the else conditional statement, respectively, level by level, to obtain first-level sub-conditions, second-level sub-conditions, and third-level sub-conditions;

[0124] S560, generating a first-level combination condition according to the first-level condition and the first-level sub-conditions; generating a second-level combination condition according to the second-level condition and the second-level sub-conditions; generating a third-level combination condition according to the third-level sub-conditions.

[0125] Specifically, traverse the intermediate structure data, obtain the if conditional statement, and obtain the first-level condition;

[0126] The conditions of the child nodes corresponding to the if conditional statement are recursively calculated level by level to obtain first-level sub-conditions; and a first-level combined condition is generated according to the first-level condition and the first-level sub-conditions.

[0127] The intermediate structure data is traversed to obtain the elseif conditional statement to obtain the secondary condition; the conditions of the child nodes corresponding to the elseif conditional statement are recursively performed level by level to obtain each secondary sub-condition; and a secondary combination condition is generated according to the secondary condition and each secondary sub-condition.

[0128] The intermediate structure data is traversed to obtain the else conditional statement, and the conditions of the child nodes corresponding to the elseif conditional statement are recursively performed level by level to obtain each secondary sub-condition; and a secondary combination condition is generated according to each secondary sub-condition.

[0129] Furthermore, the if conditional statement, the elseif conditional statement and the else conditional statement are respectively recursively performed level by level to respectively correspond to the conditions of the child nodes, and the first-level sub-conditions, the second-level sub-conditions and the third-level sub-conditions are respectively obtained, including:

[0130] Recursively perform the conditions of the child nodes corresponding to the if conditional statement, the elseif conditional statement and the else conditional statement respectively, and push each of the first-level sub-conditions, each of the second-level sub-conditions and each of the third-level sub-conditions into a stack respectively; if the decision object decisionItem node is not empty when traversing, the decision object decisionItem node is a leaf node, then each of the first-level sub-conditions, each of the second-level sub-conditions and each of the third-level sub-conditions are popped out from the stack one by one to generate combined conditions at each level.

[0131] For example, the dependent if conditions in the intermediate structure data are pushed into the temporary stack one by one, for example, a is greater than or equal to 0 is pushed first, and then the condition of the next node of the recursive if condition variable, such as b is less than 10, and the relationship is "and", the two conditions are pushed into the stack.

[0132] The termination condition of the recursive traversal is that if the decision object node decisionItem of the intermediate structure data is not empty, the node is already a leaf node, and the traversed conditions are popped out from the stack one by one to form a combined condition, for example: a is greater than or equal to 20 and b is less than 10. In this application, the if condition and the else if condition are traversed in sequence, and finally the else condition is recursively traversed.

[0133] The present application automatically builds a decision tree in a target decision engine 400 by parsing a script exported from SAS software. Specifically, antlr4 is used to parse the abstract syntax tree AST of the sas script; the abstract syntax tree AST is used to convert the variable part, condition part, branch part and action part of the decision tree model exported from SAS software respectively, and convert them into a specific data structure (intermediate structure data), and then the specific data structure is converted into excel, and then the excel is imported into the decision engine system to generate a decision tree.

[0134] After parsing the sas file, you can get the custom variables used in the sas file, and then query the database for parameters with the same variable name through the variable name. Parameters have the concept of grouping. According to different categories, the fixed format of string splicing, input: group name. parameter name (input: SAS_TEST.city_level) format is spliced ​​into a string and exported to excel.

[0135] By parsing the sas file, the assignment statement and conditional statement are matched (matched by the grammar rules defined in G4). The condition is input. As for SAS_TEST, when the business defines variables in the sas software, it can be directly defined as SAS_TEST.city_level. Then when the target decision engine matches the variable, it can be forced to match according to SAS_TEST.city_level.

[0136] This application opens up a one-way conversion between the SAS Enterprise Miner data mining model tool and the decision tree model inside the target decision engine 400, and can recognize the scripting language of the SAS Enterprise Miner tool. The subsequent conversion form is not limited to the decision tree model inside the decision engine, and can also be converted into Excel or SQL statements (to facilitate the business to use SQL to analyze and verify the effect of the decision tree on the big data platform), etc. In this way, the manual construction of the decision tree is transformed into a system function that automatically constructs the decision tree rules. Before the improvement, the process was cumbersome, error-prone and inefficient. After the improvement, a large amount of manual configuration is reduced, making the configuration of decision tree rules efficient.

[0137] Figure 3 A schematic diagram of a conversion device for a domain model language and a general decision table according to an embodiment of the present application is shown. Exemplarily, the conversion device for a domain model language and a general decision table includes: a syntax tree generation module 1110 , an intermediate structure data generation module 1120 and a decision table generation module 1130 .

[0138] The syntax tree generation module 1110 is used to parse the file based on the syntax rules, and convert the decision tree model file into syntax tree structure data using the syntax parser 300; wherein the decision tree model file is a script file exported from the model data mining tool 200; and the syntax rule parsing file is obtained according to the syntax rule setting of the decision tree model file;

[0139] An intermediate structure data generating module 1120, configured to traverse the syntax tree structure data and convert the syntax tree structure data into intermediate structure data according to a preset data conversion rule;

[0140] The decision table generating module 1130 is used to generate a general decision table that meets the target decision engine 400 according to the intermediate structure data, and the general decision table is used to instruct the target decision engine 400 to generate a decision tree.

[0141] It can be understood that the device of this embodiment corresponds to the method for converting the domain model language and the general decision table in the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.

[0142] The present application also provides a terminal device. Exemplarily, the terminal device includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the terminal device to execute the functions of each module in the above-mentioned method for converting a domain model language into a general decision table or the above-mentioned device for converting a domain model language into a general decision table.

[0143] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application.

[0144] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.

[0145] The present application also provides a readable storage medium for storing the computer program used in the above-mentioned terminal device.

[0146] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0147] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0148] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.

[0149] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.< / string>

Claims

1. A method for converting a domain model language to a general decision table, characterized in that: include: Based on the grammar rule parsing file, the decision tree model file is converted into grammar tree structure data by using a grammar parser; wherein the decision tree model file is a script file exported from a model data mining tool; the grammar rule parsing file is used to describe the structure and grammar of the decision tree model file; the grammar tree structure data is an abstract syntax tree AST; Traversing the syntax tree structure data and converting the syntax tree structure data into intermediate structure data according to a preset data conversion rule; Generate a general decision table that meets the target decision engine according to the intermediate structure data, wherein the general decision table is used to instruct the target decision engine to generate a decision tree; The intermediate structure data is data of Java array type; wherein the Java array includes multiple multi-level key-value pair objects and sub-arrays mixed and nested array elements; wherein each sub-array is used as the key value of the element in the key-value pair object of the corresponding level; each sub-array includes at least one array element composed of the key-value pair object of the next level; The traversing the syntax tree structure data and converting the syntax tree structure data into intermediate structure data according to a preset data conversion rule includes: Traverse from the root node of the syntax tree structure data to the leaf node direction, generate multi-level key-value pair objects and sub-array mixed nested array elements according to the hierarchical relationship of the child nodes; the node information at each level is used as the key of the element in the key-value pair object, and the sub-array is used as the key value of the key-value pair object; several nodes at the next level respectively use the key-value pair object to form the elements in the sub-array of the corresponding level; wherein specifically includes: generating a terminal key-value pair object according to the child nodes connected to the leaf node; the key value of the terminal key-value pair object is the terminal array; storing the leaf node information of each child node as an element in the terminal array; if a node is connected to multiple child nodes at the same level, the corresponding level of the sub-array includes multiple corresponding key-value pair objects; Generate the intermediate structure data according to the array elements of the mixed nesting of the plurality of multi-level key-value pair objects and sub-arrays; The intermediate structure data includes an input statement key-value pair object and an output statement key-value pair object; the key value of the element in the input statement key-value pair object is an input element array; the input element array includes a rule key-value pair object; the terminal array in the output statement key-value pair object includes a node identifier key-value pair object; The step of generating a general decision table that meets the target decision engine according to the intermediate structure data includes: Traverse the elements at all levels in the Java array to obtain the input statement key-value pair object and the output statement key-value pair object; According to the information in the rule key-value pair object, determine to store the input statement information in the corresponding input statement key-value pair object into the input statement set; According to the information in the node identifier key-value pair object, determine to store the output statement information in the corresponding output statement key-value pair object into the output statement set; Converting the information in each rule key-value pair object in the input statement set into an information format that conforms to the target decision engine to obtain a rule information list set; Generate the general decision table according to the input statement set, the output statement set and the rule information list set; The generating the general decision table according to the input statement set, the output statement set and the rule information list set comprises: Generate a first decision table array according to each input statement information associated in the input statement set and the corresponding output statement information in the output statement set; Generate a second decision table array according to the rule information list set; Using the first decision table array and the second decision table array as key values ​​respectively, obtaining a first key-value pair object and a second key-value pair object; obtaining a decision table element according to the first key-value pair object and the second key-value pair object; The general decision table is obtained according to each decision table element.

2. The method for converting a domain model language to a general decision table according to claim 1, characterized in that: The method further comprises: Generating a custom variable applicable to the target decision engine according to the intermediate structure data, wherein the custom variable is used to instruct the target decision engine to generate the decision tree, specifically comprising: Traversing the intermediate structure data to obtain each preceding assignment statement node; Obtaining a target variable set defined in the target decision engine; Filtering variable assignment statement nodes in each of the preceding assignment statement nodes, and acquiring corresponding target variables in the target variable set; storing the variables in the variable assignment statement and the target variables as key-value pairs into preset map data; The map data and the target variable set are both used to instruct the target decision engine to generate the decision tree; traverse the intermediate structure data to obtain the if conditional statement, the elseif conditional statement and the else conditional statement respectively, and obtain the primary condition and the secondary condition accordingly; Recursively perform the conditions of the child nodes corresponding to the if conditional statement, the elseif conditional statement and the else conditional statement respectively, and obtain the first-level sub-conditions, the second-level sub-conditions and the third-level sub-conditions; Generate a first-level combination condition according to the first-level condition and the first-level sub-conditions; generate a second-level combination condition according to the second-level condition and the second-level sub-conditions; generate a third-level combination condition according to the third-level sub-conditions; The if conditional statement, the elseif conditional statement and the else conditional statement are respectively recursively performed level by level to respectively correspond to the conditions of the child nodes, and the first-level sub-conditions, the second-level sub-conditions and the third-level sub-conditions are obtained accordingly, including: The if conditional statement, the elseif conditional statement and the else conditional statement respectively correspond to the conditions of the child nodes, and each of the first-level sub-conditions, each of the second-level sub-conditions and each of the third-level sub-conditions are pushed into a stack respectively; if the traversal finds that the decision object node is not empty, then the decision object node is a leaf node, then each of the first-level sub-conditions, each of the second-level sub-conditions and each of the third-level sub-conditions are popped out from the stack one by one to generate combined conditions at each level.

3. The method for converting a domain model language to a general decision table according to claim 1, characterized in that: The model data mining tool is SAS Enterprise Miner; the decision tree model file is a .sas decision tree model file; the syntax parser is ANTLR; the syntax rule parsing file is a g4 syntax rule parsing file; The method of parsing the file based on grammar rules and converting the decision tree model file into grammar tree structure data using a grammar parser includes: Get the .sas decision tree model file exported from SAS Enterprise Miner; Obtain a g4 grammar rule parsing file set according to the grammar rule of the .sas decision tree model file; Based on the g4 grammar rule parsing file, ANTLR is used to convert the .sas decision tree model file into grammar tree structure data.

4. A conversion system between a domain model language and a general decision table, characterized in that: include: Model data mining tools, syntax parsers, target decision engines and controllers; The controller is used to execute the conversion method between the domain model language and the general decision table according to any one of claims 1 to 3 based on the syntax parser to generate a general decision table; The model data mining tool is used to construct a decision tree model file; The target decision engine is used to generate a decision tree according to the general decision table.

5. The conversion system between the domain model language and the general decision table according to claim 4, characterized in that: The intermediate structure data is data of Java array type; wherein the Java array includes multiple multi-level key-value pair objects and sub-arrays mixed and nested array elements; wherein each sub-array is used as the key value of the element in the key-value pair object of the corresponding level; each sub-array includes at least one array element composed of the key-value pair object of the next level; The controller is specifically used for: Traverse from the root node of the syntax tree structure data to the leaf node direction, generate multi-level key-value pair objects and sub-array mixed nested array elements according to the hierarchical relationship of the child nodes; the node information at each level is used as the key of the element in the key-value pair object, and the sub-array is used as the key value of the key-value pair object; several nodes at the next level respectively use the key-value pair object to form the elements in the sub-array of the corresponding level; wherein specifically includes: generating a terminal key-value pair object according to the child nodes connected to the leaf node; the key value of the terminal key-value pair object is the terminal array; storing the leaf node information of each child node as an element in the terminal array; if a node is connected to multiple child nodes at the same level, the corresponding level of the sub-array includes multiple corresponding key-value pair objects; The intermediate structure data is generated according to the array elements in which multiple multi-level key-value pair objects and sub-arrays are mixed and nested.

6. A terminal device, characterized in that: The terminal device includes a processor and a memory, the memory stores a computer program, and the processor is used to execute the computer program to implement the method for converting the domain model language and the general decision table according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Metadata-based data blood relationship analysis method and system

    CN110555032A

  • Text conversion method and device, storage medium and electronic equipment

    CN112749552A