fuzzy-dl-owl2 1.0.0__py3-none-any.whl
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.
- fuzzy_dl_owl2/__init__.py +2 -0
- fuzzy_dl_owl2/fuzzydl/__init__.py +23 -0
- fuzzy_dl_owl2/fuzzydl/assertion/__init__.py +2 -0
- fuzzy_dl_owl2/fuzzydl/assertion/assertion.py +72 -0
- fuzzy_dl_owl2/fuzzydl/assertion/atomic_assertion.py +19 -0
- fuzzy_dl_owl2/fuzzydl/concept/__init__.py +13 -0
- fuzzy_dl_owl2/fuzzydl/concept/all_some_concept.py +85 -0
- fuzzy_dl_owl2/fuzzydl/concept/approximation_concept.py +147 -0
- fuzzy_dl_owl2/fuzzydl/concept/atomic_concept.py +91 -0
- fuzzy_dl_owl2/fuzzydl/concept/choquet_integral.py +64 -0
- fuzzy_dl_owl2/fuzzydl/concept/concept.py +230 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/__init__.py +10 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/crisp_concrete_concept.py +60 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_concrete_concept.py +63 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_number/__init__.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_number/triangular_fuzzy_number.py +127 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/left_concrete_concept.py +70 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/linear_concrete_concept.py +70 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/modified_concrete_concept.py +66 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/right_concrete_concept.py +70 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/trapezoidal_concrete_concept.py +96 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/triangular_concrete_concept.py +89 -0
- fuzzy_dl_owl2/fuzzydl/concept/ext_threshold_concept.py +77 -0
- fuzzy_dl_owl2/fuzzydl/concept/has_value_concept.py +51 -0
- fuzzy_dl_owl2/fuzzydl/concept/implies_concept.py +144 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/__init__.py +6 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/has_concept_interface.py +17 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/has_concepts_interface.py +18 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/has_role_concept_interface.py +14 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/has_role_interface.py +15 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/has_value_interface.py +21 -0
- fuzzy_dl_owl2/fuzzydl/concept/interface/has_weighted_concepts_interface.py +29 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/__init__.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/linearly_modified_concept.py +32 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/modified_concept.py +59 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/triangularly_modified_concept.py +33 -0
- fuzzy_dl_owl2/fuzzydl/concept/negated_nominal.py +42 -0
- fuzzy_dl_owl2/fuzzydl/concept/operator_concept.py +707 -0
- fuzzy_dl_owl2/fuzzydl/concept/owa_concept.py +57 -0
- fuzzy_dl_owl2/fuzzydl/concept/qowa_concept.py +62 -0
- fuzzy_dl_owl2/fuzzydl/concept/quasi_sugeno_integral.py +46 -0
- fuzzy_dl_owl2/fuzzydl/concept/self_concept.py +45 -0
- fuzzy_dl_owl2/fuzzydl/concept/string_concept.py +35 -0
- fuzzy_dl_owl2/fuzzydl/concept/sugeno_integral.py +83 -0
- fuzzy_dl_owl2/fuzzydl/concept/threshold_concept.py +81 -0
- fuzzy_dl_owl2/fuzzydl/concept/truth_concept.py +83 -0
- fuzzy_dl_owl2/fuzzydl/concept/value_concept.py +67 -0
- fuzzy_dl_owl2/fuzzydl/concept/weighted_concept.py +55 -0
- fuzzy_dl_owl2/fuzzydl/concept/weighted_max_concept.py +63 -0
- fuzzy_dl_owl2/fuzzydl/concept/weighted_min_concept.py +57 -0
- fuzzy_dl_owl2/fuzzydl/concept/weighted_sum_concept.py +62 -0
- fuzzy_dl_owl2/fuzzydl/concept/weighted_sum_zero_concept.py +62 -0
- fuzzy_dl_owl2/fuzzydl/concept_equivalence.py +20 -0
- fuzzy_dl_owl2/fuzzydl/concrete_feature.py +94 -0
- fuzzy_dl_owl2/fuzzydl/degree/__init__.py +4 -0
- fuzzy_dl_owl2/fuzzydl/degree/degree.py +79 -0
- fuzzy_dl_owl2/fuzzydl/degree/degree_expression.py +57 -0
- fuzzy_dl_owl2/fuzzydl/degree/degree_numeric.py +57 -0
- fuzzy_dl_owl2/fuzzydl/degree/degree_variable.py +54 -0
- fuzzy_dl_owl2/fuzzydl/domain_axiom.py +8 -0
- fuzzy_dl_owl2/fuzzydl/exception/__init__.py +2 -0
- fuzzy_dl_owl2/fuzzydl/exception/fuzzy_ontology_exception.py +4 -0
- fuzzy_dl_owl2/fuzzydl/exception/inconsistent_ontology_exception.py +4 -0
- fuzzy_dl_owl2/fuzzydl/feature_function.py +148 -0
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2.py +920 -0
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2_java.py +953 -0
- fuzzy_dl_owl2/fuzzydl/general_concept_inclusion.py +82 -0
- fuzzy_dl_owl2/fuzzydl/individual/__init__.py +3 -0
- fuzzy_dl_owl2/fuzzydl/individual/created_individual.py +219 -0
- fuzzy_dl_owl2/fuzzydl/individual/individual.py +113 -0
- fuzzy_dl_owl2/fuzzydl/individual/representative_individual.py +37 -0
- fuzzy_dl_owl2/fuzzydl/knowledge_base.py +9037 -0
- fuzzy_dl_owl2/fuzzydl/label.py +32 -0
- fuzzy_dl_owl2/fuzzydl/milp/__init__.py +7 -0
- fuzzy_dl_owl2/fuzzydl/milp/expression.py +186 -0
- fuzzy_dl_owl2/fuzzydl/milp/inequation.py +55 -0
- fuzzy_dl_owl2/fuzzydl/milp/milp_helper.py +787 -0
- fuzzy_dl_owl2/fuzzydl/milp/show_variables_helper.py +151 -0
- fuzzy_dl_owl2/fuzzydl/milp/solution.py +45 -0
- fuzzy_dl_owl2/fuzzydl/milp/term.py +76 -0
- fuzzy_dl_owl2/fuzzydl/milp/variable.py +89 -0
- fuzzy_dl_owl2/fuzzydl/modifier/__init__.py +3 -0
- fuzzy_dl_owl2/fuzzydl/modifier/linear_modifier.py +76 -0
- fuzzy_dl_owl2/fuzzydl/modifier/modifier.py +39 -0
- fuzzy_dl_owl2/fuzzydl/modifier/triangular_modifier.py +76 -0
- fuzzy_dl_owl2/fuzzydl/parser/ParserConstants.py +406 -0
- fuzzy_dl_owl2/fuzzydl/parser/__init__.py +1 -0
- fuzzy_dl_owl2/fuzzydl/parser/dl_parser.py +2029 -0
- fuzzy_dl_owl2/fuzzydl/parser/ebnf.lark +290 -0
- fuzzy_dl_owl2/fuzzydl/parser/larkx.py +70 -0
- fuzzy_dl_owl2/fuzzydl/primitive_concept_definition.py +81 -0
- fuzzy_dl_owl2/fuzzydl/query/__init__.py +14 -0
- fuzzy_dl_owl2/fuzzydl/query/all_instances_query.py +50 -0
- fuzzy_dl_owl2/fuzzydl/query/bnp_query.py +22 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/__init__.py +4 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/defuzzify_query.py +76 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/lom_defuzzify_query.py +19 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/mom_defuzzify_query.py +88 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/som_defuzzify_query.py +20 -0
- fuzzy_dl_owl2/fuzzydl/query/instance_query.py +19 -0
- fuzzy_dl_owl2/fuzzydl/query/kb_satisfiable_query.py +32 -0
- fuzzy_dl_owl2/fuzzydl/query/max/__init__.py +5 -0
- fuzzy_dl_owl2/fuzzydl/query/max/max_instance_query.py +45 -0
- fuzzy_dl_owl2/fuzzydl/query/max/max_query.py +31 -0
- fuzzy_dl_owl2/fuzzydl/query/max/max_related_query.py +45 -0
- fuzzy_dl_owl2/fuzzydl/query/max/max_satisfiable_query.py +73 -0
- fuzzy_dl_owl2/fuzzydl/query/max/max_subsumes_query.py +64 -0
- fuzzy_dl_owl2/fuzzydl/query/min/__init__.py +5 -0
- fuzzy_dl_owl2/fuzzydl/query/min/min_instance_query.py +50 -0
- fuzzy_dl_owl2/fuzzydl/query/min/min_query.py +31 -0
- fuzzy_dl_owl2/fuzzydl/query/min/min_related_query.py +57 -0
- fuzzy_dl_owl2/fuzzydl/query/min/min_satisfiable_query.py +80 -0
- fuzzy_dl_owl2/fuzzydl/query/min/min_subsumes_query.py +65 -0
- fuzzy_dl_owl2/fuzzydl/query/query.py +38 -0
- fuzzy_dl_owl2/fuzzydl/query/related_query.py +15 -0
- fuzzy_dl_owl2/fuzzydl/query/satisfiable_query.py +37 -0
- fuzzy_dl_owl2/fuzzydl/query/subsumption_query.py +20 -0
- fuzzy_dl_owl2/fuzzydl/range_axiom.py +7 -0
- fuzzy_dl_owl2/fuzzydl/relation.py +47 -0
- fuzzy_dl_owl2/fuzzydl/restriction/__init__.py +2 -0
- fuzzy_dl_owl2/fuzzydl/restriction/has_value_restriction.py +16 -0
- fuzzy_dl_owl2/fuzzydl/restriction/restriction.py +34 -0
- fuzzy_dl_owl2/fuzzydl/role_parent_with_degree.py +10 -0
- fuzzy_dl_owl2/fuzzydl/util/__init__.py +3 -0
- fuzzy_dl_owl2/fuzzydl/util/config_reader.py +56 -0
- fuzzy_dl_owl2/fuzzydl/util/constants.py +424 -0
- fuzzy_dl_owl2/fuzzydl/util/util.py +73 -0
- fuzzy_dl_owl2/fuzzyowl2/__init__.py +5 -0
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2.py +1513 -0
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2_java.py +1409 -0
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2_to_fuzzydl.py +917 -0
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2_to_fuzzydl_java.py +956 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/__init__.py +0 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/choquet_concept.py +19 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/concept_definition.py +14 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/fuzzy_datatype.py +22 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/fuzzy_modifier.py +4 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/fuzzy_nominal_concept.py +19 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/fuzzy_property.py +5 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/left_shoulder_function.py +17 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/linear_function.py +17 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/linear_modifier.py +13 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/modified_concept.py +19 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/modified_function.py +17 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/modified_property.py +15 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/owa_concept.py +19 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/property_definition.py +10 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/qowa_concept.py +19 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/quasi_sugeno_concept.py +21 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/right_shoulder_function.py +17 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/sugeno_concept.py +21 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/trapezoidal_function.py +25 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/triangular_function.py +21 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/triangular_modifer.py +21 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_concept.py +19 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_max_concept.py +15 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_min_concept.py +15 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_sum_concept.py +15 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_sum_zero_concept.py +15 -0
- fuzzy_dl_owl2/fuzzyowl2/parser/__init__.py +1 -0
- fuzzy_dl_owl2/fuzzyowl2/parser/owl2_parser.py +491 -0
- fuzzy_dl_owl2/fuzzyowl2/util/__init__.py +1 -0
- fuzzy_dl_owl2/fuzzyowl2/util/constants.py +112 -0
- fuzzy_dl_owl2-1.0.0.dist-info/LICENSE +427 -0
- fuzzy_dl_owl2-1.0.0.dist-info/METADATA +299 -0
- fuzzy_dl_owl2-1.0.0.dist-info/RECORD +167 -0
- fuzzy_dl_owl2-1.0.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept import (
|
|
6
|
+
FuzzyConcreteConcept,
|
|
7
|
+
)
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class RightConcreteConcept(FuzzyConcreteConcept):
|
|
13
|
+
|
|
14
|
+
def __init__(self, name: str, k1: float, k2: float, a: float, b: float) -> None:
|
|
15
|
+
super().__init__(name)
|
|
16
|
+
if a > b:
|
|
17
|
+
Util.error(f"Error: Right functions require {a} <= {b}")
|
|
18
|
+
if k1 > a:
|
|
19
|
+
Util.error(f"Error: Right functions require {k1} <= {a}")
|
|
20
|
+
if k2 < b:
|
|
21
|
+
Util.error(f"Error: Right functions require {k2} >= {b}")
|
|
22
|
+
|
|
23
|
+
self.k1: float = k1
|
|
24
|
+
self.k2: float = k2
|
|
25
|
+
self._a: float = float(a)
|
|
26
|
+
self._b: float = float(b)
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def a(self) -> float:
|
|
30
|
+
return self._a
|
|
31
|
+
|
|
32
|
+
@a.setter
|
|
33
|
+
def a(self, value: float) -> None:
|
|
34
|
+
self._a = float(value)
|
|
35
|
+
|
|
36
|
+
@property
|
|
37
|
+
def b(self) -> float:
|
|
38
|
+
return self._b
|
|
39
|
+
|
|
40
|
+
@b.setter
|
|
41
|
+
def b(self, value: float) -> None:
|
|
42
|
+
self._b = float(value)
|
|
43
|
+
|
|
44
|
+
def clone(self) -> typing.Self:
|
|
45
|
+
return RightConcreteConcept(self.name, self.k1, self.k2, self.a, self.b)
|
|
46
|
+
|
|
47
|
+
def get_membership_degree(self, x: float) -> float:
|
|
48
|
+
if x <= self.a:
|
|
49
|
+
return 0.0
|
|
50
|
+
if x >= self.b:
|
|
51
|
+
return 1.0
|
|
52
|
+
return (x - self.a) / (self.b - self.a)
|
|
53
|
+
|
|
54
|
+
def compute_name(self) -> str:
|
|
55
|
+
return f"right-shoulder({self.k1}, {self.k2}, {self.a}, {self.b})"
|
|
56
|
+
|
|
57
|
+
def __neg__(self) -> FuzzyConcreteConcept:
|
|
58
|
+
return OperatorConcept.not_(self)
|
|
59
|
+
|
|
60
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
61
|
+
return OperatorConcept.and_(self, value)
|
|
62
|
+
|
|
63
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
64
|
+
return OperatorConcept.or_(self, value)
|
|
65
|
+
|
|
66
|
+
def __hash__(self) -> int:
|
|
67
|
+
return hash(str(self))
|
|
68
|
+
|
|
69
|
+
# def __str__(self) -> str:
|
|
70
|
+
# return self.get_name()
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept import (
|
|
6
|
+
FuzzyConcreteConcept,
|
|
7
|
+
)
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TrapezoidalConcreteConcept(FuzzyConcreteConcept):
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self, name: str, k1: float, k2: float, a: float, b: float, c: float, d: float
|
|
16
|
+
) -> None:
|
|
17
|
+
if a > b or b > c or c > d:
|
|
18
|
+
Util.error(f"Error: Trapezoidal functions require {a} <= {b} <= {c} <= {d}")
|
|
19
|
+
if k1 > a:
|
|
20
|
+
Util.error(f"Error: Trapezoidal functions require {k1} <= {a}")
|
|
21
|
+
if k2 < b:
|
|
22
|
+
Util.error(f"Error: Trapezoidal functions require {k2} >= {b}")
|
|
23
|
+
|
|
24
|
+
self.name: str = name
|
|
25
|
+
self.k1: float = k1
|
|
26
|
+
self.k2: float = k2
|
|
27
|
+
self._a: float = float(a)
|
|
28
|
+
self._b: float = float(b)
|
|
29
|
+
self._c: float = float(c)
|
|
30
|
+
self._d: float = float(d)
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def a(self) -> float:
|
|
34
|
+
return self._a
|
|
35
|
+
|
|
36
|
+
@a.setter
|
|
37
|
+
def a(self, value: float) -> None:
|
|
38
|
+
self._a = float(value)
|
|
39
|
+
|
|
40
|
+
@property
|
|
41
|
+
def b(self) -> float:
|
|
42
|
+
return self._b
|
|
43
|
+
|
|
44
|
+
@b.setter
|
|
45
|
+
def b(self, value: float) -> None:
|
|
46
|
+
self._b = float(value)
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def c(self) -> float:
|
|
50
|
+
return self._c
|
|
51
|
+
|
|
52
|
+
@c.setter
|
|
53
|
+
def c(self, value: float) -> None:
|
|
54
|
+
self._c = float(value)
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def d(self) -> float:
|
|
58
|
+
return self._d
|
|
59
|
+
|
|
60
|
+
@d.setter
|
|
61
|
+
def d(self, value: float) -> None:
|
|
62
|
+
self._d = float(value)
|
|
63
|
+
|
|
64
|
+
def clone(self) -> typing.Self:
|
|
65
|
+
return TrapezoidalConcreteConcept(
|
|
66
|
+
self.name, self.k1, self.k2, self.a, self.b, self.c, self.d
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def get_membership_degree(self, x: float) -> float:
|
|
70
|
+
if x <= self.a or x >= self.d:
|
|
71
|
+
return 0.0
|
|
72
|
+
if self.b <= x <= self.c:
|
|
73
|
+
return 1.0
|
|
74
|
+
if x >= self.a:
|
|
75
|
+
return (x - self.a) / (self.b - self.a)
|
|
76
|
+
return (self.d - x) / (self.d - self.c)
|
|
77
|
+
|
|
78
|
+
def compute_name(self) -> str:
|
|
79
|
+
return (
|
|
80
|
+
f"trapezoidal({self.k1}, {self.k2}, {self.a}, {self.b}, {self.c}, {self.d})"
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
def __neg__(self) -> FuzzyConcreteConcept:
|
|
84
|
+
return OperatorConcept.not_(self)
|
|
85
|
+
|
|
86
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
87
|
+
return OperatorConcept.and_(self, value)
|
|
88
|
+
|
|
89
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
90
|
+
return OperatorConcept.or_(self, value)
|
|
91
|
+
|
|
92
|
+
def __hash__(self) -> int:
|
|
93
|
+
return hash(str(self))
|
|
94
|
+
|
|
95
|
+
# def __str__(self) -> str:
|
|
96
|
+
# return self.get_name()
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept import (
|
|
6
|
+
FuzzyConcreteConcept,
|
|
7
|
+
)
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.exception.fuzzy_ontology_exception import (
|
|
10
|
+
FuzzyOntologyException,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TriangularConcreteConcept(FuzzyConcreteConcept):
|
|
15
|
+
def __init__(
|
|
16
|
+
self, name: str, k1: float, k2: float, a: float, b: float, c: float
|
|
17
|
+
) -> None:
|
|
18
|
+
super().__init__(name)
|
|
19
|
+
if a > b or b > c:
|
|
20
|
+
raise FuzzyOntologyException(
|
|
21
|
+
f"Error: Triangular functions require {a} <= {b} <= {c}"
|
|
22
|
+
)
|
|
23
|
+
if k1 > a:
|
|
24
|
+
raise FuzzyOntologyException(
|
|
25
|
+
f"Error: Triangular functions require {k1} <= {a}"
|
|
26
|
+
)
|
|
27
|
+
if k2 < b:
|
|
28
|
+
raise FuzzyOntologyException(
|
|
29
|
+
f"Error: Triangular functions require {k2} >= {b}"
|
|
30
|
+
)
|
|
31
|
+
self.k1: float = k1
|
|
32
|
+
self.k2: float = k2
|
|
33
|
+
self._a: float = float(a)
|
|
34
|
+
self._b: float = float(b)
|
|
35
|
+
self._c: float = float(c)
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def a(self) -> float:
|
|
39
|
+
return self._a
|
|
40
|
+
|
|
41
|
+
@a.setter
|
|
42
|
+
def a(self, value: float) -> None:
|
|
43
|
+
self._a = float(value)
|
|
44
|
+
|
|
45
|
+
@property
|
|
46
|
+
def b(self) -> float:
|
|
47
|
+
return self._b
|
|
48
|
+
|
|
49
|
+
@b.setter
|
|
50
|
+
def b(self, value: float) -> None:
|
|
51
|
+
self._b = float(value)
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def c(self) -> float:
|
|
55
|
+
return self._c
|
|
56
|
+
|
|
57
|
+
@c.setter
|
|
58
|
+
def c(self, value: float) -> None:
|
|
59
|
+
self._c = float(value)
|
|
60
|
+
|
|
61
|
+
def clone(self) -> typing.Self:
|
|
62
|
+
return TriangularConcreteConcept(
|
|
63
|
+
self.name, self.k1, self.k2, self.a, self.b, self.c
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def get_membership_degree(self, x: float) -> float:
|
|
67
|
+
if x <= self.a or x >= self.c:
|
|
68
|
+
return 0.0
|
|
69
|
+
if x <= self.b:
|
|
70
|
+
return (x - self.a) / (self.b - self.a)
|
|
71
|
+
return (self.c - x) / (self.c - self.b)
|
|
72
|
+
|
|
73
|
+
def compute_name(self) -> str:
|
|
74
|
+
return f"triangular({self.k1}, {self.k2}, {self.a}, {self.b}, {self.c})"
|
|
75
|
+
|
|
76
|
+
def __neg__(self) -> FuzzyConcreteConcept:
|
|
77
|
+
return OperatorConcept.not_(self)
|
|
78
|
+
|
|
79
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
80
|
+
return OperatorConcept.and_(self, value)
|
|
81
|
+
|
|
82
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
83
|
+
return OperatorConcept.or_(self, value)
|
|
84
|
+
|
|
85
|
+
def __hash__(self) -> int:
|
|
86
|
+
return hash(str(self))
|
|
87
|
+
|
|
88
|
+
# def __str__(self) -> str:
|
|
89
|
+
# return self.get_name()
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_concept_interface import (
|
|
5
|
+
HasConceptInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.milp.variable import Variable
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ExtThresholdConcept(Concept, HasConceptInterface):
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self, c_type: ConceptType, c: Concept, weight_variable: Variable
|
|
16
|
+
) -> None:
|
|
17
|
+
Concept.__init__(self, c_type)
|
|
18
|
+
HasConceptInterface.__init__(self, c)
|
|
19
|
+
|
|
20
|
+
assert c_type in (
|
|
21
|
+
ConceptType.EXT_POS_THRESHOLD,
|
|
22
|
+
ConceptType.EXT_NEG_THRESHOLD,
|
|
23
|
+
)
|
|
24
|
+
self._weight_variable: Variable = weight_variable
|
|
25
|
+
self.name: str = self.compute_name()
|
|
26
|
+
|
|
27
|
+
@property
|
|
28
|
+
def weight_variable(self) -> Variable:
|
|
29
|
+
return self._weight_variable
|
|
30
|
+
|
|
31
|
+
@weight_variable.setter
|
|
32
|
+
def weight_variable(self, value: Variable) -> None:
|
|
33
|
+
self._weight_variable = value
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def extended_pos_threshold(v: Variable, c: typing.Self) -> typing.Self:
|
|
37
|
+
return ExtThresholdConcept(ConceptType.EXT_POS_THRESHOLD, c, v)
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def extended_neg_threshold(v: Variable, c: typing.Self) -> typing.Self:
|
|
41
|
+
return ExtThresholdConcept(ConceptType.EXT_NEG_THRESHOLD, c, v)
|
|
42
|
+
|
|
43
|
+
def clone(self):
|
|
44
|
+
return ExtThresholdConcept(self.type, self.curr_concept, self.weight_variable)
|
|
45
|
+
|
|
46
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
47
|
+
return ExtThresholdConcept(
|
|
48
|
+
self.type, self.curr_concept.replace(a, c), self.weight_variable
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def compute_name(self) -> typing.Optional[str]:
|
|
52
|
+
if self.type == ConceptType.EXT_POS_THRESHOLD:
|
|
53
|
+
return f"([>= {self.weight_variable}] {self.curr_concept})"
|
|
54
|
+
else:
|
|
55
|
+
return f"([<= {self.weight_variable}] {self.curr_concept})"
|
|
56
|
+
|
|
57
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
58
|
+
return self.curr_concept.compute_atomic_concepts()
|
|
59
|
+
|
|
60
|
+
def get_roles(self) -> set[str]:
|
|
61
|
+
return self.curr_concept.get_roles()
|
|
62
|
+
|
|
63
|
+
def __neg__(self) -> Concept:
|
|
64
|
+
return OperatorConcept.not_(self)
|
|
65
|
+
|
|
66
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
67
|
+
return OperatorConcept.and_(self, value)
|
|
68
|
+
|
|
69
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
70
|
+
return OperatorConcept.or_(self, value)
|
|
71
|
+
|
|
72
|
+
def __hash__(self) -> int:
|
|
73
|
+
return hash(str(self))
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
ExtendedPosThreshold = ExtThresholdConcept.extended_pos_threshold
|
|
77
|
+
ExtendedNegThreshold = ExtThresholdConcept.extended_neg_threshold
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_value_interface import (
|
|
6
|
+
HasValueInterface,
|
|
7
|
+
)
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class HasValueConcept(Concept, HasValueInterface):
|
|
14
|
+
|
|
15
|
+
def __init__(self, role: str, value: typing.Any) -> None:
|
|
16
|
+
Concept.__init__(self, ConceptType.HAS_VALUE)
|
|
17
|
+
HasValueInterface.__init__(self, role, value)
|
|
18
|
+
|
|
19
|
+
self.name: str = self.compute_name()
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def has_value(role: str, i: typing.Any) -> typing.Self:
|
|
23
|
+
return HasValueConcept(role, i)
|
|
24
|
+
|
|
25
|
+
def clone(self) -> typing.Self:
|
|
26
|
+
return HasValueConcept(self.role, copy.deepcopy(self.value))
|
|
27
|
+
|
|
28
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
29
|
+
Util.error(f"Error replacing in concept {self}")
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
def compute_name(self) -> typing.Optional[str]:
|
|
33
|
+
return f"(b-some {self.role} {self.value})"
|
|
34
|
+
|
|
35
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
36
|
+
return set()
|
|
37
|
+
|
|
38
|
+
def get_roles(self) -> set[str]:
|
|
39
|
+
return set()
|
|
40
|
+
|
|
41
|
+
def __neg__(self) -> Concept:
|
|
42
|
+
return OperatorConcept.not_(self)
|
|
43
|
+
|
|
44
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
45
|
+
return OperatorConcept.and_(self, value)
|
|
46
|
+
|
|
47
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
48
|
+
return OperatorConcept.or_(self, value)
|
|
49
|
+
|
|
50
|
+
def __hash__(self) -> int:
|
|
51
|
+
return hash(str(self))
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_concepts_interface import (
|
|
5
|
+
HasConceptsInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import (
|
|
8
|
+
And,
|
|
9
|
+
GoedelAnd,
|
|
10
|
+
GoedelOr,
|
|
11
|
+
LukasiewiczOr,
|
|
12
|
+
Not,
|
|
13
|
+
Or,
|
|
14
|
+
)
|
|
15
|
+
from fuzzy_dl_owl2.fuzzydl.concept.truth_concept import TruthConcept
|
|
16
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
17
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ImpliesConcept(Concept, HasConceptsInterface):
|
|
21
|
+
|
|
22
|
+
def __init__(self, c_type: ConceptType, concepts: list[Concept]) -> None:
|
|
23
|
+
Concept.__init__(self, c_type)
|
|
24
|
+
HasConceptsInterface.__init__(self, concepts)
|
|
25
|
+
|
|
26
|
+
assert c_type in (
|
|
27
|
+
ConceptType.ZADEH_IMPLIES,
|
|
28
|
+
ConceptType.GOEDEL_IMPLIES,
|
|
29
|
+
ConceptType,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
self.name: str = self.compute_name()
|
|
33
|
+
|
|
34
|
+
def clone(self) -> typing.Self:
|
|
35
|
+
return ImpliesConcept(self.type, [c for c in self.concepts])
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def lukasiewicz_implies(c1: Concept, c2: Concept) -> Concept:
|
|
39
|
+
if c1.type == ConceptType.TOP:
|
|
40
|
+
return c2
|
|
41
|
+
if c2.type == ConceptType.TOP or c1.type == ConceptType.BOTTOM:
|
|
42
|
+
return TruthConcept.get_top()
|
|
43
|
+
if c2.type == ConceptType.BOTTOM:
|
|
44
|
+
return -c1
|
|
45
|
+
# if constants.KNOWLEDGE_BASE_SEMANTICS == FuzzyLogic.CLASSICAL:
|
|
46
|
+
# return Or(-c1, c2)
|
|
47
|
+
return LukasiewiczOr(-c1, c2)
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def kleene_dienes_implies(c1: Concept, c2: Concept) -> Concept:
|
|
51
|
+
if c1.type == ConceptType.TOP:
|
|
52
|
+
return c2
|
|
53
|
+
if c2.type == ConceptType.TOP or c1.type == ConceptType.BOTTOM:
|
|
54
|
+
return TruthConcept.get_top()
|
|
55
|
+
# if constants.KNOWLEDGE_BASE_SEMANTICS == FuzzyLogic.CLASSICAL:
|
|
56
|
+
# return Or(-c1, c2)
|
|
57
|
+
return GoedelOr(-c1, c2)
|
|
58
|
+
|
|
59
|
+
@staticmethod
|
|
60
|
+
def goedel_implies(c1: Concept, c2: Concept) -> Concept:
|
|
61
|
+
if c1.type == ConceptType.TOP:
|
|
62
|
+
return c2
|
|
63
|
+
if c2.type == ConceptType.TOP or c1.type == ConceptType.BOTTOM:
|
|
64
|
+
return TruthConcept.get_top()
|
|
65
|
+
# if constants.KNOWLEDGE_BASE_SEMANTICS == FuzzyLogic.CLASSICAL:
|
|
66
|
+
# return Or(-c1, c2)
|
|
67
|
+
if c1.type == ConceptType.GOEDEL_OR:
|
|
68
|
+
return GoedelAnd([GoedelOr(ci, c2) for ci in c1.concepts])
|
|
69
|
+
return ImpliesConcept(ConceptType.GOEDEL_IMPLIES, [c1, c2])
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def zadeh_implies(c1: Concept, c2: Concept) -> Concept:
|
|
73
|
+
# if constants.KNOWLEDGE_BASE_SEMANTICS == FuzzyLogic.CLASSICAL:
|
|
74
|
+
# return Or(-c1, c2)
|
|
75
|
+
return ImpliesConcept(ConceptType.ZADEH_IMPLIES, [c1, c2])
|
|
76
|
+
|
|
77
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
78
|
+
c_type: ConceptType = c.type
|
|
79
|
+
if c_type == ConceptType.GOEDEL_IMPLIES:
|
|
80
|
+
return ImpliesConcept.goedel_implies(
|
|
81
|
+
self.concepts[0].replace(a, c), self.concepts[1].replace(a, c)
|
|
82
|
+
)
|
|
83
|
+
elif c_type == ConceptType.NOT_GOEDEL_IMPLIES:
|
|
84
|
+
return Not(
|
|
85
|
+
ImpliesConcept.goedel_implies(
|
|
86
|
+
self.concepts[0].replace(a, c), self.concepts[1].replace(a, c)
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
Util.error(f"Error replacing in concept {self}")
|
|
90
|
+
|
|
91
|
+
def compute_name(self) -> typing.Optional[str]:
|
|
92
|
+
if self.type == ConceptType.GOEDEL_IMPLIES:
|
|
93
|
+
return f"(g-implies {self.concepts[0]} {self.concepts[1]})"
|
|
94
|
+
elif self.type == ConceptType.ZADEH_IMPLIES:
|
|
95
|
+
return f"(z-implies {self.concepts[0]} {self.concepts[1]})"
|
|
96
|
+
|
|
97
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
98
|
+
result: set[Concept] = set()
|
|
99
|
+
result.update(self.concepts[0].compute_atomic_concepts())
|
|
100
|
+
result.update(self.concepts[1].compute_atomic_concepts())
|
|
101
|
+
return result
|
|
102
|
+
|
|
103
|
+
def get_roles(self) -> set[str]:
|
|
104
|
+
return self.concepts[0].get_roles() | self.concepts[1].get_roles()
|
|
105
|
+
|
|
106
|
+
def __neg__(self) -> Concept:
|
|
107
|
+
return Not(self)
|
|
108
|
+
|
|
109
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
110
|
+
return And(self, value)
|
|
111
|
+
|
|
112
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
113
|
+
return Or(self, value)
|
|
114
|
+
|
|
115
|
+
def __hash__(self) -> int:
|
|
116
|
+
return hash(str(self))
|
|
117
|
+
|
|
118
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
119
|
+
return isinstance(value, ImpliesConcept) and str(self) == str(value)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# class ZadehImplies(ImpliesConcept):
|
|
123
|
+
# def implies(self, c: Concept) -> typing.Self:
|
|
124
|
+
# return ImpliesConcept.zadeh_implies(self, c)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# class GoedelImplies(ImpliesConcept):
|
|
128
|
+
# def implies(self, c: Concept) -> typing.Self:
|
|
129
|
+
# return ImpliesConcept.goedel_implies(self, c)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# class LukasiewiczImplies(ImpliesConcept):
|
|
133
|
+
# def implies(self, c: Concept) -> typing.Self:
|
|
134
|
+
# return ImpliesConcept.lukasiewicz_implies(self, c)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# class KleeneDienesImplies(ImpliesConcept):
|
|
138
|
+
# def implies(self, c: Concept) -> typing.Self:
|
|
139
|
+
# return ImpliesConcept.kleene_dienes_implies(self, c)
|
|
140
|
+
|
|
141
|
+
ZadehImplies = ImpliesConcept.zadeh_implies
|
|
142
|
+
GoedelImplies = ImpliesConcept.goedel_implies
|
|
143
|
+
LukasiewiczImplies = ImpliesConcept.lukasiewicz_implies
|
|
144
|
+
KleeneDienesImplies = ImpliesConcept.kleene_dienes_implies
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from .has_concept_interface import HasConceptInterface
|
|
2
|
+
from .has_concepts_interface import HasConceptsInterface
|
|
3
|
+
from .has_role_interface import HasRoleInterface
|
|
4
|
+
from .has_role_concept_interface import HasRoleConceptInterface
|
|
5
|
+
from .has_value_interface import HasValueInterface
|
|
6
|
+
from .has_weighted_concepts_interface import HasWeightedConceptsInterface
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class HasConceptInterface(abc.ABC):
|
|
7
|
+
|
|
8
|
+
def __init__(self, concept: Concept) -> None:
|
|
9
|
+
self._curr_concept: Concept = concept
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def curr_concept(self) -> Concept:
|
|
13
|
+
return self._curr_concept
|
|
14
|
+
|
|
15
|
+
@curr_concept.setter
|
|
16
|
+
def curr_concept(self, value: Concept) -> None:
|
|
17
|
+
self._curr_concept = value
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class HasConceptsInterface(abc.ABC):
|
|
8
|
+
|
|
9
|
+
def __init__(self, concepts: typing.Iterable[Concept]) -> None:
|
|
10
|
+
self._concepts: list[Concept] = list(concepts)
|
|
11
|
+
|
|
12
|
+
@property
|
|
13
|
+
def concepts(self) -> list[Concept]:
|
|
14
|
+
return self._concepts
|
|
15
|
+
|
|
16
|
+
@concepts.setter
|
|
17
|
+
def concepts(self, value: typing.Iterable[Concept]) -> None:
|
|
18
|
+
self._concepts = list(value)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_concept_interface import (
|
|
5
|
+
HasConceptInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_interface import HasRoleInterface
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class HasRoleConceptInterface(HasRoleInterface, HasConceptInterface, abc.ABC):
|
|
11
|
+
|
|
12
|
+
def __init__(self, role: str, concept: Concept) -> None:
|
|
13
|
+
HasRoleInterface.__init__(self, role)
|
|
14
|
+
HasConceptInterface.__init__(self, concept)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class HasRoleInterface(abc.ABC):
|
|
5
|
+
|
|
6
|
+
def __init__(self, role: str) -> None:
|
|
7
|
+
self._role: str = role
|
|
8
|
+
|
|
9
|
+
@property
|
|
10
|
+
def role(self) -> str:
|
|
11
|
+
return self._role
|
|
12
|
+
|
|
13
|
+
@role.setter
|
|
14
|
+
def role(self, value: str) -> None:
|
|
15
|
+
self._role = value
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import copy
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_interface import HasRoleInterface
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class HasValueInterface(HasRoleInterface, abc.ABC):
|
|
9
|
+
|
|
10
|
+
def __init__(self, role: str, value: typing.Any) -> None:
|
|
11
|
+
super().__init__(role)
|
|
12
|
+
|
|
13
|
+
self._value: typing.Any = value
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def value(self) -> typing.Any:
|
|
17
|
+
return self._value
|
|
18
|
+
|
|
19
|
+
@value.setter
|
|
20
|
+
def value(self, value: typing.Any) -> None:
|
|
21
|
+
self._value = copy.deepcopy(value)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_concepts_interface import (
|
|
6
|
+
HasConceptsInterface,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class HasWeightedConceptsInterface(HasConceptsInterface, abc.ABC):
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
weights: typing.Optional[typing.Iterable[float]],
|
|
15
|
+
concepts: typing.Iterable[Concept],
|
|
16
|
+
) -> None:
|
|
17
|
+
super().__init__(concepts)
|
|
18
|
+
|
|
19
|
+
self._weights: typing.Optional[list[float]] = (
|
|
20
|
+
list(weights) if weights is not None else None
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def weights(self) -> typing.Optional[list[float]]:
|
|
25
|
+
return self._weights
|
|
26
|
+
|
|
27
|
+
@weights.setter
|
|
28
|
+
def weights(self, value: typing.Optional[typing.Iterable[float]]) -> None:
|
|
29
|
+
self._weights = list(value) if value is not None else None
|