parser_classification_rule
Module for ParserClassificationRule class
!!! classes ParserClassificationRule
ParserClassificationRule (IParserRuleBase)
Class for creating a ClassificationRuleData
Source code in parsers/parser_classification_rule.py
class ParserClassificationRule(IParserRuleBase):
"""Class for creating a ClassificationRuleData"""
@property
def rule_type_name(self) -> str:
"""Type name for the rule"""
return "classification_rule"
def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData:
"""Parses the provided dictionary to a IRuleData
Args:
dictionary (Dict[str, Any]): Dictionary holding the values
for making the rule
Returns:
RuleBase: Rule based on the provided data
"""
name: str = get_dict_element("name", dictionary)
input_variable_names: List[str] = get_dict_element(
"input_variables", dictionary
)
criteria_table_list: List[Any] = get_dict_element("criteria_table", dictionary)
criteria_table = convert_table_element(criteria_table_list)
validate_table_with_input(criteria_table, input_variable_names)
validate_table_coverage(criteria_table, logger)
output_variable_name: str = get_dict_element("output_variable", dictionary)
description: str = get_dict_element("description", dictionary)
rule_data = ClassificationRuleData(name, input_variable_names, criteria_table)
rule_data.description = description
rule_data.output_variable = output_variable_name
return rule_data
rule_type_name: str
property
readonly
Type name for the rule
parse_dict(self, dictionary, logger)
Parses the provided dictionary to a IRuleData
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dictionary |
Dict[str, Any] |
Dictionary holding the values for making the rule |
required |
Returns:
Type | Description |
---|---|
RuleBase |
Rule based on the provided data |
Source code in parsers/parser_classification_rule.py
def parse_dict(self, dictionary: Dict[str, Any], logger: ILogger) -> IRuleData:
"""Parses the provided dictionary to a IRuleData
Args:
dictionary (Dict[str, Any]): Dictionary holding the values
for making the rule
Returns:
RuleBase: Rule based on the provided data
"""
name: str = get_dict_element("name", dictionary)
input_variable_names: List[str] = get_dict_element(
"input_variables", dictionary
)
criteria_table_list: List[Any] = get_dict_element("criteria_table", dictionary)
criteria_table = convert_table_element(criteria_table_list)
validate_table_with_input(criteria_table, input_variable_names)
validate_table_coverage(criteria_table, logger)
output_variable_name: str = get_dict_element("output_variable", dictionary)
description: str = get_dict_element("description", dictionary)
rule_data = ClassificationRuleData(name, input_variable_names, criteria_table)
rule_data.description = description
rule_data.output_variable = output_variable_name
return rule_data