ripple-down-rules 0.0.7__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/PKG-INFO +1 -1
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/pyproject.toml +1 -1
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/rdr.py +0 -2
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/utils.py +29 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules.egg-info/PKG-INFO +1 -1
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/test/test_json_serialization.py +4 -10
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/test/test_rdr.py +0 -4
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/LICENSE +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/README.md +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/setup.cfg +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/__init__.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datasets.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/__init__.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/callable_expression.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/dataclasses.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/enums.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/table.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/experts.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/failures.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/prompt.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/rules.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules.egg-info/SOURCES.txt +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules.egg-info/dependency_links.txt +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules.egg-info/top_level.txt +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/test/test_rdr_alchemy.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/test/test_relational_rdr.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/test/test_relational_rdr_alchemy.py +0 -0
- {ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/test/test_sql_model.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ripple_down_rules
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
4
4
|
Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
|
5
5
|
Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
6
6
|
|
7
7
|
[project]
|
8
8
|
name = "ripple_down_rules"
|
9
|
-
version = "0.0.
|
9
|
+
version = "0.0.8"
|
10
10
|
description = "Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning."
|
11
11
|
readme = "README.md"
|
12
12
|
authors = [{ name = "Abdelrhman Bassiouny", email = "abassiou@uni-bremen.de" }]
|
@@ -128,8 +128,6 @@ class RippleDownRules(ABC):
|
|
128
128
|
target = target if is_iterable(target) else [target]
|
129
129
|
recall = [not yi or (yi in pred_cat) for yi in target]
|
130
130
|
target_types = [type(yi) for yi in target]
|
131
|
-
if len(pred_cat) > 1:
|
132
|
-
print(pred_cat)
|
133
131
|
precision = [(pred in target) or (type(pred) not in target_types) for pred in pred_cat]
|
134
132
|
return precision, recall
|
135
133
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import importlib
|
4
|
+
import json
|
4
5
|
import logging
|
5
6
|
from abc import abstractmethod
|
6
7
|
from collections import UserDict
|
@@ -81,6 +82,18 @@ class SubclassJSONSerializer:
|
|
81
82
|
'from_json' method.
|
82
83
|
"""
|
83
84
|
|
85
|
+
def to_json_file(self, filename: str):
|
86
|
+
"""
|
87
|
+
Save the object to a json file.
|
88
|
+
"""
|
89
|
+
data = self.to_json()
|
90
|
+
# save the json to a file
|
91
|
+
if not filename.endswith(".json"):
|
92
|
+
filename += ".json"
|
93
|
+
with open(filename, "w") as f:
|
94
|
+
json.dump(data, f, indent=4)
|
95
|
+
return data
|
96
|
+
|
84
97
|
def to_json(self) -> Dict[str, Any]:
|
85
98
|
return {"_type": get_full_class_name(self.__class__), **self._to_json()}
|
86
99
|
|
@@ -104,6 +117,19 @@ class SubclassJSONSerializer:
|
|
104
117
|
"""
|
105
118
|
raise NotImplementedError()
|
106
119
|
|
120
|
+
@classmethod
|
121
|
+
def from_json_file(cls, filename: str):
|
122
|
+
"""
|
123
|
+
Create an instance of the subclass from the data in the given json file.
|
124
|
+
|
125
|
+
:param filename: The filename of the json file.
|
126
|
+
"""
|
127
|
+
if not filename.endswith(".json"):
|
128
|
+
filename += ".json"
|
129
|
+
with open(filename, "r") as f:
|
130
|
+
scrdr_json = json.load(f)
|
131
|
+
return cls.from_json(scrdr_json)
|
132
|
+
|
107
133
|
@classmethod
|
108
134
|
def from_json(cls, data: Dict[str, Any]) -> Self:
|
109
135
|
"""
|
@@ -124,6 +150,9 @@ class SubclassJSONSerializer:
|
|
124
150
|
|
125
151
|
raise ValueError("Unknown type {}".format(data["_type"]))
|
126
152
|
|
153
|
+
save = to_json_file
|
154
|
+
load = from_json_file
|
155
|
+
|
127
156
|
|
128
157
|
def copy_case(case: Union[Case, SQLTable]) -> Union[Case, SQLTable]:
|
129
158
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ripple_down_rules
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
4
4
|
Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
|
5
5
|
Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -19,17 +19,11 @@ class TestJSONSerialization(TestCase):
|
|
19
19
|
def setUpClass(cls):
|
20
20
|
cls.all_cases, cls.targets = load_zoo_dataset(cls.cache_dir + "/zoo_dataset.pkl")
|
21
21
|
|
22
|
-
def
|
22
|
+
def test_scrdr_json_serialization(self):
|
23
23
|
scrdr = self.get_fit_scrdr()
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
json.dump(scrdr_json, f, indent=4)
|
28
|
-
|
29
|
-
# load the json from the file
|
30
|
-
with open(f"{self.cache_dir}/scrdr.json", "r") as f:
|
31
|
-
scrdr_json = json.load(f)
|
32
|
-
scrdr = SingleClassRDR.from_json(scrdr_json)
|
24
|
+
filename = f"{self.cache_dir}/scrdr.json"
|
25
|
+
scrdr.save(filename)
|
26
|
+
scrdr = SingleClassRDR.load(filename)
|
33
27
|
for case, target in zip(self.all_cases, self.targets):
|
34
28
|
cat = scrdr.classify(case)
|
35
29
|
self.assertEqual(cat, target)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/enums.py
RENAMED
File without changes
|
{ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules/datastructures/table.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules.egg-info/SOURCES.txt
RENAMED
File without changes
|
File without changes
|
{ripple_down_rules-0.0.7 → ripple_down_rules-0.0.8}/src/ripple_down_rules.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|