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,230 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import typing
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Thing(ABC):
|
|
11
|
+
|
|
12
|
+
def is_simplified(self) -> bool:
|
|
13
|
+
"""
|
|
14
|
+
This function check if current formula is simplified, i.e., if:
|
|
15
|
+
- The only negated elements are literal of kind (~ A), where A is an AtomicProposition
|
|
16
|
+
- The OR operator is between:
|
|
17
|
+
- Two literals => A | B
|
|
18
|
+
- One literal and a AND => A | (B & C) - (A & B) | C
|
|
19
|
+
- Two (or more) OR => (A & B) | (C & D) | (E & F)
|
|
20
|
+
- The AND operator is between:
|
|
21
|
+
- Two literals => A & B
|
|
22
|
+
- One literal and a OR => A & (B | C) - (A | B) & C
|
|
23
|
+
- Two (or more) AND => (A | B) & (C | D) & (E | F)
|
|
24
|
+
- The only operators are AND, OR and NOT
|
|
25
|
+
"""
|
|
26
|
+
return True
|
|
27
|
+
|
|
28
|
+
def reduce_truth_values(self) -> typing.Self:
|
|
29
|
+
return self
|
|
30
|
+
|
|
31
|
+
def reduce_idempotency(self, is_type: typing.Callable) -> typing.Self:
|
|
32
|
+
return self
|
|
33
|
+
|
|
34
|
+
def reduce_double_negation(self) -> typing.Self:
|
|
35
|
+
return self
|
|
36
|
+
|
|
37
|
+
def distribute(self, c_type: ConceptType) -> typing.Self:
|
|
38
|
+
return self
|
|
39
|
+
|
|
40
|
+
def de_morgan(self) -> typing.Self:
|
|
41
|
+
return self
|
|
42
|
+
|
|
43
|
+
def reduce_quantifiers(self) -> typing.Self:
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def normal_form(self, is_type: typing.Callable) -> typing.Self:
|
|
47
|
+
return self
|
|
48
|
+
|
|
49
|
+
def classic_cnf(self) -> typing.Self:
|
|
50
|
+
return self.normal_form(
|
|
51
|
+
lambda x: isinstance(x, ConceptType) and x == ConceptType.OR
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
def classic_dnf(self) -> typing.Self:
|
|
55
|
+
return self.normal_form(
|
|
56
|
+
lambda x: isinstance(x, ConceptType) and x == ConceptType.AND
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
def goedel_cnf(self) -> typing.Self:
|
|
60
|
+
return self.normal_form(
|
|
61
|
+
lambda x: isinstance(x, ConceptType) and x == ConceptType.GOEDEL_OR
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
def goedel_dnf(self) -> typing.Self:
|
|
65
|
+
return self.normal_form(
|
|
66
|
+
lambda x: isinstance(x, ConceptType) and x == ConceptType.GOEDEL_AND
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def lukasiewicz_cnf(self) -> typing.Self:
|
|
70
|
+
return self.normal_form(
|
|
71
|
+
lambda x: isinstance(x, ConceptType) and x == ConceptType.LUKASIEWICZ_OR
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
def lukasiewicz_dnf(self) -> typing.Self:
|
|
75
|
+
return self.normal_form(
|
|
76
|
+
lambda x: isinstance(x, ConceptType) and x == ConceptType.LUKASIEWICZ_AND
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
@staticmethod
|
|
80
|
+
def contains_negated_subconcept(v: list[typing.Self], cj: typing.Self) -> int:
|
|
81
|
+
try:
|
|
82
|
+
return v.index(-cj)
|
|
83
|
+
except ValueError:
|
|
84
|
+
return -1
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def contains_subconcept(v: list[typing.Self], cj: typing.Self) -> bool:
|
|
88
|
+
return cj in v
|
|
89
|
+
|
|
90
|
+
@staticmethod
|
|
91
|
+
def remove_element(v: list[typing.Self], i: int) -> None:
|
|
92
|
+
if len(v) > i:
|
|
93
|
+
v.pop(i)
|
|
94
|
+
|
|
95
|
+
def is_concrete(self) -> bool:
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
@abstractmethod
|
|
99
|
+
def compute_name(self) -> typing.Optional[str]:
|
|
100
|
+
pass
|
|
101
|
+
|
|
102
|
+
def get_atoms(self) -> list[typing.Self]:
|
|
103
|
+
return list()
|
|
104
|
+
|
|
105
|
+
def get_clauses(self, is_type: typing.Callable) -> list[typing.Self]:
|
|
106
|
+
return list()
|
|
107
|
+
|
|
108
|
+
@abstractmethod
|
|
109
|
+
def clone(self) -> typing.Self:
|
|
110
|
+
pass
|
|
111
|
+
|
|
112
|
+
@abstractmethod
|
|
113
|
+
def compute_atomic_concepts(self) -> set[typing.Self]:
|
|
114
|
+
pass
|
|
115
|
+
|
|
116
|
+
def get_atomic_concepts(self) -> set[typing.Self]:
|
|
117
|
+
return self.compute_atomic_concepts()
|
|
118
|
+
|
|
119
|
+
@abstractmethod
|
|
120
|
+
def get_roles(self) -> set[str]:
|
|
121
|
+
pass
|
|
122
|
+
|
|
123
|
+
@abstractmethod
|
|
124
|
+
def replace(self, a: typing.Self, c: typing.Self) -> typing.Optional[typing.Self]:
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
def has_nominals(self) -> bool:
|
|
128
|
+
return "(b-some " in str(self)
|
|
129
|
+
|
|
130
|
+
def __invert__(self) -> typing.Self:
|
|
131
|
+
return -self
|
|
132
|
+
|
|
133
|
+
@abstractmethod
|
|
134
|
+
def __neg__(self) -> typing.Self:
|
|
135
|
+
pass
|
|
136
|
+
|
|
137
|
+
def __lt__(self, value: typing.Self) -> typing.Self:
|
|
138
|
+
a, b = re.sub(r"[\(\)]+", "", str(self)), re.sub(r"[\(\)]+", "", str(value))
|
|
139
|
+
return a < b
|
|
140
|
+
|
|
141
|
+
def __le__(self, value: typing.Self) -> typing.Self:
|
|
142
|
+
return not (self > value)
|
|
143
|
+
|
|
144
|
+
def __gt__(self, value: typing.Self) -> typing.Self:
|
|
145
|
+
a, b = re.sub(r"[\(\)]+", "", str(self)), re.sub(r"[\(\)]+", "", str(value))
|
|
146
|
+
return a > b
|
|
147
|
+
|
|
148
|
+
def __ge__(self, value: typing.Self) -> typing.Self:
|
|
149
|
+
return not (self < value)
|
|
150
|
+
|
|
151
|
+
@abstractmethod
|
|
152
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
153
|
+
pass
|
|
154
|
+
|
|
155
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
156
|
+
return not (self == value)
|
|
157
|
+
|
|
158
|
+
def __repr__(self) -> str:
|
|
159
|
+
return str(self)
|
|
160
|
+
|
|
161
|
+
# def __str__(self) -> str:
|
|
162
|
+
# return self.compute_name()
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class Concept(Thing):
|
|
166
|
+
SPECIAL_STRING = "@"
|
|
167
|
+
DEFAULT_NAME = f"Concept{SPECIAL_STRING}"
|
|
168
|
+
num_new_concepts = 1
|
|
169
|
+
|
|
170
|
+
def __init__(
|
|
171
|
+
self, c_type: ConceptType = ConceptType.ATOMIC, name: str = ""
|
|
172
|
+
) -> None:
|
|
173
|
+
self._type: ConceptType = c_type
|
|
174
|
+
self._name: str = name
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def type(self) -> ConceptType:
|
|
178
|
+
return self._type
|
|
179
|
+
|
|
180
|
+
@type.setter
|
|
181
|
+
def type(self, new_type: ConceptType) -> None:
|
|
182
|
+
self._type = new_type
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def name(self) -> str:
|
|
186
|
+
return self._name
|
|
187
|
+
|
|
188
|
+
@name.setter
|
|
189
|
+
def name(self, value: str) -> None:
|
|
190
|
+
self._name = value
|
|
191
|
+
|
|
192
|
+
def is_atomic(self) -> bool:
|
|
193
|
+
return self.type == ConceptType.ATOMIC
|
|
194
|
+
|
|
195
|
+
def is_complemented_atomic(self) -> bool:
|
|
196
|
+
return False
|
|
197
|
+
|
|
198
|
+
# @abstractmethod
|
|
199
|
+
def __iand__(self, value: typing.Self) -> typing.Self:
|
|
200
|
+
pass
|
|
201
|
+
|
|
202
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
203
|
+
pass
|
|
204
|
+
|
|
205
|
+
# @abstractmethod
|
|
206
|
+
def __ior__(self, value: typing.Self) -> typing.Self:
|
|
207
|
+
pass
|
|
208
|
+
|
|
209
|
+
# @abstractmethod
|
|
210
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
211
|
+
pass
|
|
212
|
+
|
|
213
|
+
# @abstractmethod
|
|
214
|
+
def __irshift__(self, value: typing.Self) -> typing.Self:
|
|
215
|
+
pass
|
|
216
|
+
|
|
217
|
+
# @abstractmethod
|
|
218
|
+
def __rshift__(self, value: typing.Self) -> typing.Self:
|
|
219
|
+
pass
|
|
220
|
+
|
|
221
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
222
|
+
return str(self) == str(value)
|
|
223
|
+
|
|
224
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
225
|
+
return not (self == value)
|
|
226
|
+
|
|
227
|
+
def __str__(self) -> str:
|
|
228
|
+
if self.name is None:
|
|
229
|
+
self.name = self.compute_name()
|
|
230
|
+
return self.name
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from .fuzzy_concrete_concept import FuzzyConcreteConcept
|
|
2
|
+
from .crisp_concrete_concept import CrispConcreteConcept
|
|
3
|
+
from .left_concrete_concept import LeftConcreteConcept
|
|
4
|
+
from .right_concrete_concept import RightConcreteConcept
|
|
5
|
+
from .linear_concrete_concept import LinearConcreteConcept
|
|
6
|
+
from .modified_concrete_concept import ModifiedConcreteConcept
|
|
7
|
+
from .trapezoidal_concrete_concept import TrapezoidalConcreteConcept
|
|
8
|
+
from .triangular_concrete_concept import TriangularConcreteConcept
|
|
9
|
+
|
|
10
|
+
from .fuzzy_number import TriangularFuzzyNumber
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
|
|
10
|
+
|
|
11
|
+
class CrispConcreteConcept(FuzzyConcreteConcept):
|
|
12
|
+
|
|
13
|
+
def __init__(self, name: str, k1: float, k2: float, a: float, b: float) -> None:
|
|
14
|
+
super().__init__(name)
|
|
15
|
+
self.k1: float = float(k1)
|
|
16
|
+
self.k2: float = float(k2)
|
|
17
|
+
self._a: float = float(a)
|
|
18
|
+
self._b: float = float(b)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def a(self) -> float:
|
|
22
|
+
return self._a
|
|
23
|
+
|
|
24
|
+
@a.setter
|
|
25
|
+
def a(self, value: float) -> None:
|
|
26
|
+
self._a = value
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def b(self) -> float:
|
|
30
|
+
return self._b
|
|
31
|
+
|
|
32
|
+
@b.setter
|
|
33
|
+
def b(self, value: float) -> None:
|
|
34
|
+
self._b = value
|
|
35
|
+
|
|
36
|
+
def clone(self) -> typing.Self:
|
|
37
|
+
return CrispConcreteConcept(self.name, self.k1, self.k2, self.a, self.b)
|
|
38
|
+
|
|
39
|
+
def get_membership_degree(self, x: float) -> float:
|
|
40
|
+
if self.a <= x <= self.b:
|
|
41
|
+
return 1.0
|
|
42
|
+
return 0.0
|
|
43
|
+
|
|
44
|
+
def compute_name(self) -> str:
|
|
45
|
+
return f"crisp({self.k1}, {self.k2}, {self.a}, {self.b})"
|
|
46
|
+
|
|
47
|
+
def __neg__(self) -> FuzzyConcreteConcept:
|
|
48
|
+
return OperatorConcept.not_(self)
|
|
49
|
+
|
|
50
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
51
|
+
return OperatorConcept.and_(self, value)
|
|
52
|
+
|
|
53
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
54
|
+
return OperatorConcept.or_(self, value)
|
|
55
|
+
|
|
56
|
+
def __hash__(self) -> int:
|
|
57
|
+
return hash(str(self))
|
|
58
|
+
|
|
59
|
+
# def __str__(self) -> str:
|
|
60
|
+
# return self.get_name()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.exception.fuzzy_ontology_exception import (
|
|
8
|
+
FuzzyOntologyException,
|
|
9
|
+
)
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
11
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class FuzzyConcreteConcept(Concept, ABC):
|
|
15
|
+
|
|
16
|
+
def __init__(self, name: str) -> None:
|
|
17
|
+
super().__init__(ConceptType.CONCRETE, name)
|
|
18
|
+
self.name: str = name
|
|
19
|
+
self._k1: float = 0.0
|
|
20
|
+
self._k2: float = 0.0
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def k1(self) -> float:
|
|
24
|
+
return self._k1
|
|
25
|
+
|
|
26
|
+
@k1.setter
|
|
27
|
+
def k1(self, value: float) -> None:
|
|
28
|
+
self._k1 = float(value)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def k2(self) -> float:
|
|
32
|
+
return self._k2
|
|
33
|
+
|
|
34
|
+
@k2.setter
|
|
35
|
+
def k2(self, value: float) -> None:
|
|
36
|
+
self._k2 = float(value)
|
|
37
|
+
|
|
38
|
+
def compute_name(self) -> str:
|
|
39
|
+
return self.name
|
|
40
|
+
|
|
41
|
+
def is_concrete(self) -> bool:
|
|
42
|
+
return True
|
|
43
|
+
|
|
44
|
+
def compute_atomic_concepts(self) -> set[typing.Self]:
|
|
45
|
+
return set()
|
|
46
|
+
|
|
47
|
+
def get_roles(self) -> set[str]:
|
|
48
|
+
return set()
|
|
49
|
+
|
|
50
|
+
def replace(self, concept1: Concept, concept2: Concept) -> Concept:
|
|
51
|
+
try:
|
|
52
|
+
Util.error(f"Error replacing in concept {self}")
|
|
53
|
+
except FuzzyOntologyException:
|
|
54
|
+
pass
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
@abstractmethod
|
|
58
|
+
def get_membership_degree(self, value: float) -> float:
|
|
59
|
+
"""Get membership degree for a value"""
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
# def __str__(self) -> str:
|
|
63
|
+
# return self.get_name() or self.name
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .triangular_fuzzy_number import TriangularFuzzyNumber
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.triangular_concrete_concept import (
|
|
6
|
+
TriangularConcreteConcept,
|
|
7
|
+
)
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util import constants
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
11
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TriangularFuzzyNumber(TriangularConcreteConcept):
|
|
15
|
+
K1: float = float("-inf")
|
|
16
|
+
K2: float = float("inf")
|
|
17
|
+
|
|
18
|
+
@typing.overload
|
|
19
|
+
def __init__(self, name: str, a: float, b: float, c: float) -> None: ...
|
|
20
|
+
|
|
21
|
+
@typing.overload
|
|
22
|
+
def __init__(self, a: float, b: float, c: float) -> None: ...
|
|
23
|
+
|
|
24
|
+
def __init__(self, *args) -> None:
|
|
25
|
+
assert len(args) in [3, 4]
|
|
26
|
+
if len(args) == 3:
|
|
27
|
+
assert all(isinstance(a, constants.NUMBER) for a in args)
|
|
28
|
+
self.__tringular_fn_init_2(*args)
|
|
29
|
+
else:
|
|
30
|
+
assert isinstance(args[0], str)
|
|
31
|
+
assert all(isinstance(a, constants.NUMBER) for a in args[1:])
|
|
32
|
+
self.__tringular_fn_init_1(*args)
|
|
33
|
+
|
|
34
|
+
def __tringular_fn_init_1(self, name: str, a: float, b: float, c: float) -> None:
|
|
35
|
+
super().__init__(name, self.K1, self.K2, a, b, c)
|
|
36
|
+
self.type = ConceptType.FUZZY_NUMBER
|
|
37
|
+
|
|
38
|
+
def __tringular_fn_init_2(self, a: float, b: float, c: float) -> None:
|
|
39
|
+
self.__init__(f"({a}, {b}, {c})", a, b, c)
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def add(t1: typing.Self, t2: typing.Self) -> typing.Self:
|
|
43
|
+
return t1 + t2
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def minus(t1: typing.Self, t2: typing.Self) -> typing.Self:
|
|
47
|
+
return t1 - t2
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def times(t1: typing.Self, t2: typing.Self) -> typing.Self:
|
|
51
|
+
return t1 * t2
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def divided_by(t1: typing.Self, t2: typing.Self) -> typing.Self:
|
|
55
|
+
return t1 / t2
|
|
56
|
+
|
|
57
|
+
@staticmethod
|
|
58
|
+
def set_range(min_range: float, max_range: float) -> None:
|
|
59
|
+
TriangularFuzzyNumber.K1 = min_range
|
|
60
|
+
TriangularFuzzyNumber.K2 = max_range
|
|
61
|
+
|
|
62
|
+
@staticmethod
|
|
63
|
+
def has_defined_range() -> bool:
|
|
64
|
+
return TriangularFuzzyNumber.K1 != float("-inf")
|
|
65
|
+
|
|
66
|
+
def clone(self) -> typing.Self:
|
|
67
|
+
return TriangularFuzzyNumber(self.name, self.a, self.b, self.c)
|
|
68
|
+
|
|
69
|
+
def is_concrete(self) -> bool:
|
|
70
|
+
return True
|
|
71
|
+
|
|
72
|
+
def get_best_non_fuzzy_performance(self) -> float:
|
|
73
|
+
return Util.round((self.a + self.b + self.c) / 3.0)
|
|
74
|
+
|
|
75
|
+
def is_number(self) -> bool:
|
|
76
|
+
return self.a == self.b == self.c
|
|
77
|
+
|
|
78
|
+
def compute_name(self) -> str:
|
|
79
|
+
return f"({self.k1}, {self.k2}, {self.a}, {self.b}, {self.c})"
|
|
80
|
+
|
|
81
|
+
def __add__(self, other: typing.Self) -> typing.Self:
|
|
82
|
+
return TriangularFuzzyNumber(
|
|
83
|
+
self.a + other.a, self.b + other.b, self.c + other.c
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
def __sub__(self, other: typing.Self) -> typing.Self:
|
|
87
|
+
return TriangularFuzzyNumber(
|
|
88
|
+
self.a - other.c, self.b - other.b, self.c - other.a
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def __mul__(self, other: typing.Self) -> typing.Self:
|
|
92
|
+
return TriangularFuzzyNumber(
|
|
93
|
+
self.a * other.a, self.b * other.b, self.c * other.c
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def __truediv__(self, other: typing.Self) -> typing.Self:
|
|
97
|
+
if 0.0 in (other.a, other.b, other.c):
|
|
98
|
+
Util.error(
|
|
99
|
+
f"Error: Cannot divide by zero in fuzzy number ({other.a}, {other.b}, {other.c})."
|
|
100
|
+
)
|
|
101
|
+
return None
|
|
102
|
+
return TriangularFuzzyNumber(
|
|
103
|
+
self.a / other.c, self.b / other.b, self.c / other.a
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def __neg__(self) -> TriangularFuzzyNumber:
|
|
107
|
+
return OperatorConcept.not_(self)
|
|
108
|
+
|
|
109
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
110
|
+
return OperatorConcept.and_(self, value)
|
|
111
|
+
|
|
112
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
113
|
+
return OperatorConcept.or_(self, value)
|
|
114
|
+
|
|
115
|
+
def __hash__(self) -> int:
|
|
116
|
+
return hash(str(self))
|
|
117
|
+
|
|
118
|
+
def __eq__(self, other: typing.Self) -> bool:
|
|
119
|
+
return (
|
|
120
|
+
type(self) == type(other)
|
|
121
|
+
and self.a == other.a
|
|
122
|
+
and self.b == other.b
|
|
123
|
+
and self.c == other.c
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def __ne__(self, other: typing.Self) -> bool:
|
|
127
|
+
return not (self == other)
|
|
@@ -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 LeftConcreteConcept(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: Left functions require {a} <= {b}")
|
|
18
|
+
if k1 > a:
|
|
19
|
+
Util.error(f"Error: Left functions require {k1} <= {a}")
|
|
20
|
+
if k2 < b:
|
|
21
|
+
Util.error(f"Error: Left functions require {k2} >= {b}")
|
|
22
|
+
|
|
23
|
+
self.k1: float = float(k1)
|
|
24
|
+
self.k2: float = 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 LeftConcreteConcept(self.name, self.k1, self.k2, self.a, self.b)
|
|
46
|
+
|
|
47
|
+
def get_membership_degree(self, value: float) -> float:
|
|
48
|
+
if value <= self.a:
|
|
49
|
+
return 0.0
|
|
50
|
+
if value >= self.b:
|
|
51
|
+
return 1.0
|
|
52
|
+
return (self.b - value) / (self.b - self.a)
|
|
53
|
+
|
|
54
|
+
def compute_name(self) -> str:
|
|
55
|
+
return f"left-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.name
|
|
@@ -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 LinearConcreteConcept(FuzzyConcreteConcept):
|
|
13
|
+
|
|
14
|
+
def __init__(self, name: str, k1: float, k2: float, a: float, b: float) -> None:
|
|
15
|
+
super().__init__(name)
|
|
16
|
+
if k1 > a:
|
|
17
|
+
Util.error(f"Error: Left functions require {k1} <= {a}")
|
|
18
|
+
if b < 1.0:
|
|
19
|
+
Util.error(f"Error: Left functions require {b} <= 1.0")
|
|
20
|
+
|
|
21
|
+
self.k1: float = float(k1)
|
|
22
|
+
self.k2: float = float(k2)
|
|
23
|
+
self._a: float = float(a)
|
|
24
|
+
self._b: float = float(b)
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def a(self) -> float:
|
|
28
|
+
return self._a
|
|
29
|
+
|
|
30
|
+
@a.setter
|
|
31
|
+
def a(self, value: float) -> None:
|
|
32
|
+
self._a = float(value)
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def b(self) -> float:
|
|
36
|
+
return self._b
|
|
37
|
+
|
|
38
|
+
@b.setter
|
|
39
|
+
def b(self, value: float) -> None:
|
|
40
|
+
self._b = float(value)
|
|
41
|
+
|
|
42
|
+
def clone(self) -> typing.Self:
|
|
43
|
+
return LinearConcreteConcept(self.name, self.k1, self.k2, self.a, self.b)
|
|
44
|
+
|
|
45
|
+
def get_membership_degree(self, value: float) -> float:
|
|
46
|
+
if value <= 0:
|
|
47
|
+
return 0.0
|
|
48
|
+
if value >= 1.0:
|
|
49
|
+
return 1.0
|
|
50
|
+
if value <= self.a:
|
|
51
|
+
return self.b / self.a * value
|
|
52
|
+
return (value * (1.0 - self.b) + (self.b - self.a)) / (1.0 - self.a)
|
|
53
|
+
|
|
54
|
+
def compute_name(self) -> str:
|
|
55
|
+
return f"linear({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,66 @@
|
|
|
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.modifier.modifier import Modifier
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ModifiedConcreteConcept(FuzzyConcreteConcept):
|
|
13
|
+
def __init__(self, name: str, modifier: Modifier, f: FuzzyConcreteConcept) -> None:
|
|
14
|
+
super().__init__(name)
|
|
15
|
+
self.k1: float = 0.0
|
|
16
|
+
self.k2: float = 1.0
|
|
17
|
+
self._modifier: Modifier = modifier
|
|
18
|
+
self._modified: FuzzyConcreteConcept = f
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def modifier(self) -> Modifier:
|
|
22
|
+
return self._modifier
|
|
23
|
+
|
|
24
|
+
@modifier.setter
|
|
25
|
+
def modifier(self, value: Modifier) -> None:
|
|
26
|
+
self._modifier = value
|
|
27
|
+
|
|
28
|
+
@property
|
|
29
|
+
def modified(self) -> FuzzyConcreteConcept:
|
|
30
|
+
return self._modified
|
|
31
|
+
|
|
32
|
+
@modified.setter
|
|
33
|
+
def modified(self, value: FuzzyConcreteConcept) -> None:
|
|
34
|
+
self._modified = value
|
|
35
|
+
|
|
36
|
+
def clone(self) -> typing.Self:
|
|
37
|
+
return ModifiedConcreteConcept(self.name, self.modifier, self.modified)
|
|
38
|
+
|
|
39
|
+
# def solve_assertion(
|
|
40
|
+
# self, ind: Individual, lower_limit: Degree, kb: KnowledgeBase
|
|
41
|
+
# ) -> None:
|
|
42
|
+
# self.modifier.solve_assertion(ind, self, lower_limit, kb)
|
|
43
|
+
|
|
44
|
+
def get_membership_degree(self, x: float) -> float:
|
|
45
|
+
if x <= 0.0 or x > 1.0:
|
|
46
|
+
return 0.0
|
|
47
|
+
y: float = self.modified.get_membership_degree(x)
|
|
48
|
+
return self.modifier.get_membership_degree(y)
|
|
49
|
+
|
|
50
|
+
def compute_name(self) -> str:
|
|
51
|
+
return f"modified({self.modifier} {self.modified})"
|
|
52
|
+
|
|
53
|
+
def __neg__(self) -> FuzzyConcreteConcept:
|
|
54
|
+
return OperatorConcept.not_(self)
|
|
55
|
+
|
|
56
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
57
|
+
return OperatorConcept.and_(self, value)
|
|
58
|
+
|
|
59
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
60
|
+
return OperatorConcept.or_(self, value)
|
|
61
|
+
|
|
62
|
+
def __hash__(self) -> int:
|
|
63
|
+
return hash(str(self))
|
|
64
|
+
|
|
65
|
+
# def __str__(self) -> str:
|
|
66
|
+
# return self.get_name()
|