JSON Logic ASP Evaluator
Evaluate JSON Logic rules against data using Clingo.
Usage
Documentation
evaluate_multiple_json_logic_rules_against_single_data(json_logic_rules, json_logic_data, simplify=False, custom_nodes=None)
Given a multiple JSON Logic rules and data, evaluate it using Clingo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_logic_rules |
List[RuleInput]
|
list of rule input with JSON Logic definitions |
required |
json_logic_data |
DataInput
|
data input object |
required |
simplify |
bool
|
if True, simplifies the JSON Logic definition |
False
|
custom_nodes |
Optional[Dict[str, Type]]
|
optional dictionary of custom nodes to parse |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
list of rule ids matching the data |
Source code in json_logic_asp/evaluator.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
evaluate_pregenerated_json_logic_rules_against_single_data(json_logic_rules_in_asp_definition, json_logic_data, rule_id_mapping=None)
Given some rules in ASP definition and a data object, return the matching rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_logic_rules_in_asp_definition |
str
|
JSON Logic rules in ASP definition |
required |
json_logic_data |
DataInput
|
data object to check against |
required |
rule_id_mapping |
Optional[Dict[str, str]]
|
optional mapping of rule ids |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
list of matching rules |
Source code in json_logic_asp/evaluator.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
evaluate_single_json_logic_rule_against_single_data(json_logic_rule, json_logic_data, simplify=False, custom_nodes=None)
Given a single JSON Logic rule and data, evaluate it using Clingo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_logic_rule |
RuleInput
|
single rule input with JSON Logic definition |
required |
json_logic_data |
DataInput
|
data input object |
required |
simplify |
bool
|
if True, simplifies the JSON Logic definition |
False
|
custom_nodes |
Optional[Dict[str, Type]]
|
optional dictionary of custom nodes to parse |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
whether the rule matches or not the data |
Source code in json_logic_asp/evaluator.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |