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,57 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_weighted_concepts_interface import (
|
|
5
|
+
HasWeightedConceptsInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WeightedMinConcept(Concept, HasWeightedConceptsInterface):
|
|
13
|
+
def __init__(self, weights: list[float], concepts: list[Concept]) -> None:
|
|
14
|
+
Concept.__init__(self, ConceptType.W_MIN)
|
|
15
|
+
HasWeightedConceptsInterface.__init__(self, weights, concepts)
|
|
16
|
+
|
|
17
|
+
if len(weights) != len(concepts):
|
|
18
|
+
Util.error("Error: The number of weights and concepts should be the same")
|
|
19
|
+
if 1.0 not in weights:
|
|
20
|
+
Util.error("Error: Some weights must be 1.0")
|
|
21
|
+
|
|
22
|
+
self.name = self.compute_name()
|
|
23
|
+
|
|
24
|
+
def clone(self) -> typing.Self:
|
|
25
|
+
return WeightedMinConcept(self.weights[:], [c for c in self.concepts])
|
|
26
|
+
|
|
27
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
28
|
+
concept_list: set[Concept] = set()
|
|
29
|
+
for c in self.concepts:
|
|
30
|
+
concept_list.update(c.compute_atomic_concepts())
|
|
31
|
+
return concept_list
|
|
32
|
+
|
|
33
|
+
def get_roles(self) -> set[str]:
|
|
34
|
+
role_list: set[str] = set()
|
|
35
|
+
for c in self.concepts:
|
|
36
|
+
role_list.update(c.get_roles())
|
|
37
|
+
return role_list
|
|
38
|
+
|
|
39
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
40
|
+
return -WeightedMinConcept(
|
|
41
|
+
self.weights, [ci.replace(a, c) for ci in self.concepts]
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def compute_name(self) -> str:
|
|
45
|
+
return f"(w-min {' '.join([f'({concept} {weight})' for concept, weight in zip(self.concepts, self.weights)])})"
|
|
46
|
+
|
|
47
|
+
def __neg__(self) -> Concept:
|
|
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))
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_weighted_concepts_interface import (
|
|
5
|
+
HasWeightedConceptsInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WeightedSumConcept(Concept, HasWeightedConceptsInterface):
|
|
13
|
+
|
|
14
|
+
def __init__(self, weights: list[float], concepts: list[Concept]) -> None:
|
|
15
|
+
Concept.__init__(self, ConceptType.W_SUM)
|
|
16
|
+
HasWeightedConceptsInterface.__init__(self, weights, concepts)
|
|
17
|
+
|
|
18
|
+
if len(weights) != len(concepts):
|
|
19
|
+
Util.error(
|
|
20
|
+
"Error: The number of weights and the number of concepts should be the same."
|
|
21
|
+
)
|
|
22
|
+
if sum(weights) > 1.0:
|
|
23
|
+
Util.error(
|
|
24
|
+
"Error: The sum of the weights of the weighted sum concept cannot be greater than 1.0."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
self.name = self.compute_name()
|
|
28
|
+
|
|
29
|
+
def clone(self) -> typing.Self:
|
|
30
|
+
return WeightedSumConcept(self.weights[:], [c for c in self.concepts])
|
|
31
|
+
|
|
32
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
33
|
+
concept_list: set[Concept] = set()
|
|
34
|
+
for c in self.concepts:
|
|
35
|
+
concept_list.update(c.compute_atomic_concepts())
|
|
36
|
+
return concept_list
|
|
37
|
+
|
|
38
|
+
def get_roles(self) -> set[str]:
|
|
39
|
+
role_list: set[str] = set()
|
|
40
|
+
for c in self.concepts:
|
|
41
|
+
role_list.update(c.get_roles())
|
|
42
|
+
return role_list
|
|
43
|
+
|
|
44
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
45
|
+
return -WeightedSumConcept(
|
|
46
|
+
self.weights, [ci.replace(a, c) for ci in self.concepts]
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def compute_name(self) -> str:
|
|
50
|
+
return f"(w-sum {' '.join([f'({weight} {concept})' for concept, weight in zip(self.concepts, self.weights)])})"
|
|
51
|
+
|
|
52
|
+
def __neg__(self) -> Concept:
|
|
53
|
+
return OperatorConcept.not_(self)
|
|
54
|
+
|
|
55
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
56
|
+
return OperatorConcept.and_(self, value)
|
|
57
|
+
|
|
58
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
59
|
+
return OperatorConcept.or_(self, value)
|
|
60
|
+
|
|
61
|
+
def __hash__(self) -> int:
|
|
62
|
+
return hash(str(self))
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_weighted_concepts_interface import (
|
|
5
|
+
HasWeightedConceptsInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class WeightedSumZeroConcept(Concept, HasWeightedConceptsInterface):
|
|
13
|
+
|
|
14
|
+
def __init__(self, weights: list[float], concepts: list[Concept]) -> None:
|
|
15
|
+
Concept.__init__(self, ConceptType.W_SUM_ZERO)
|
|
16
|
+
HasWeightedConceptsInterface.__init__(self, weights, concepts)
|
|
17
|
+
|
|
18
|
+
if len(weights) != len(concepts):
|
|
19
|
+
Util.error(
|
|
20
|
+
"Error: The number of weights and the number of concepts should be the same"
|
|
21
|
+
)
|
|
22
|
+
if sum(weights) > 1.0:
|
|
23
|
+
Util.error(
|
|
24
|
+
"Error: The sum of the weights of the weighted sum concept cannot be greater than 1.0."
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
self.name = self.compute_name()
|
|
28
|
+
|
|
29
|
+
def clone(self) -> typing.Self:
|
|
30
|
+
return WeightedSumZeroConcept(self.weights[:], [c for c in self.concepts])
|
|
31
|
+
|
|
32
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
33
|
+
concept_list: set[Concept] = set()
|
|
34
|
+
for c in self.concepts:
|
|
35
|
+
concept_list.update(c.compute_atomic_concepts())
|
|
36
|
+
return concept_list
|
|
37
|
+
|
|
38
|
+
def get_roles(self) -> set[str]:
|
|
39
|
+
role_list: set[str] = set()
|
|
40
|
+
for c in self.concepts:
|
|
41
|
+
role_list.update(c.get_roles())
|
|
42
|
+
return role_list
|
|
43
|
+
|
|
44
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
45
|
+
return -WeightedSumZeroConcept(
|
|
46
|
+
self.weights, [ci.replace(a, c) for ci in self.concepts]
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def compute_name(self) -> str:
|
|
50
|
+
return f"(w-sum-zero {' '.join([f'({weight} {concept})' for concept, weight in zip(self.concepts, self.weights)])})"
|
|
51
|
+
|
|
52
|
+
def __neg__(self) -> Concept:
|
|
53
|
+
return OperatorConcept.not_(self)
|
|
54
|
+
|
|
55
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
56
|
+
return OperatorConcept.and_(self, value)
|
|
57
|
+
|
|
58
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
59
|
+
return OperatorConcept.or_(self, value)
|
|
60
|
+
|
|
61
|
+
def __hash__(self) -> int:
|
|
62
|
+
return hash(str(self))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ConceptEquivalence:
|
|
9
|
+
def __init__(self, c1: Concept, c2: Concept) -> None:
|
|
10
|
+
self.c1: Concept = c1
|
|
11
|
+
self.c2: Concept = c2
|
|
12
|
+
|
|
13
|
+
def clone(self) -> typing.Self:
|
|
14
|
+
return ConceptEquivalence(self.c1, self.c2)
|
|
15
|
+
|
|
16
|
+
def get_c1(self) -> Concept:
|
|
17
|
+
return self.c1
|
|
18
|
+
|
|
19
|
+
def get_c2(self) -> Concept:
|
|
20
|
+
return self.c2
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConcreteFeatureType
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ConcreteFeature:
|
|
7
|
+
|
|
8
|
+
@typing.overload
|
|
9
|
+
def __init__(self, name: str) -> None: ...
|
|
10
|
+
|
|
11
|
+
@typing.overload
|
|
12
|
+
def __init__(self, name: str, is_boolean: bool) -> None: ...
|
|
13
|
+
|
|
14
|
+
@typing.overload
|
|
15
|
+
def __init__(self, name: str, k1: int, k2: int) -> None: ...
|
|
16
|
+
|
|
17
|
+
@typing.overload
|
|
18
|
+
def __init__(self, name: str, k1: float, k2: float) -> None: ...
|
|
19
|
+
|
|
20
|
+
def __init__(self, *args) -> None:
|
|
21
|
+
assert len(args) in [1, 2, 3]
|
|
22
|
+
|
|
23
|
+
assert isinstance(args[0], str)
|
|
24
|
+
if len(args) == 1:
|
|
25
|
+
self.__concrete_feature_init_1(*args)
|
|
26
|
+
elif len(args) == 2:
|
|
27
|
+
assert isinstance(args[1], bool)
|
|
28
|
+
self.__concrete_feature_init_2(*args)
|
|
29
|
+
elif len(args) == 3:
|
|
30
|
+
if isinstance(args[1], int) and isinstance(args[2], int):
|
|
31
|
+
self.__concrete_feature_init_3(*args)
|
|
32
|
+
elif isinstance(args[1], float) and isinstance(args[2], float):
|
|
33
|
+
self.__concrete_feature_init_4(*args)
|
|
34
|
+
else:
|
|
35
|
+
raise ValueError
|
|
36
|
+
else:
|
|
37
|
+
raise ValueError
|
|
38
|
+
|
|
39
|
+
def __concrete_feature_init_1(self, name: str) -> None:
|
|
40
|
+
self.name: str = name
|
|
41
|
+
self.k1: typing.Optional[typing.Union[float, int]] = None
|
|
42
|
+
self.k2: typing.Optional[typing.Union[float, int]] = None
|
|
43
|
+
self.type: ConcreteFeatureType = ConcreteFeatureType.STRING
|
|
44
|
+
|
|
45
|
+
def __concrete_feature_init_2(self, name: str, is_boolean: bool) -> None:
|
|
46
|
+
self.__concrete_feature_init_1(name)
|
|
47
|
+
if is_boolean:
|
|
48
|
+
self.type: ConcreteFeatureType = ConcreteFeatureType.BOOLEAN
|
|
49
|
+
|
|
50
|
+
def __concrete_feature_init_3(self, name: str, k1: int, k2: int) -> None:
|
|
51
|
+
self.__concrete_feature_init_1(name)
|
|
52
|
+
self.k1: typing.Optional[typing.Union[float, int]] = k1
|
|
53
|
+
self.k2: typing.Optional[typing.Union[float, int]] = k2
|
|
54
|
+
self.type: ConcreteFeatureType = ConcreteFeatureType.INTEGER
|
|
55
|
+
|
|
56
|
+
def __concrete_feature_init_4(self, name: str, k1: float, k2: float) -> None:
|
|
57
|
+
self.__concrete_feature_init_1(name)
|
|
58
|
+
self.k1: typing.Optional[typing.Union[float, int]] = k1
|
|
59
|
+
self.k2: typing.Optional[typing.Union[float, int]] = k2
|
|
60
|
+
self.type: ConcreteFeatureType = ConcreteFeatureType.REAL
|
|
61
|
+
|
|
62
|
+
def clone(self) -> typing.Self:
|
|
63
|
+
if self.type == ConcreteFeatureType.BOOLEAN:
|
|
64
|
+
return ConcreteFeature(self.name, is_boolean=True)
|
|
65
|
+
elif self.type == ConcreteFeatureType.STRING:
|
|
66
|
+
return ConcreteFeature(self.name)
|
|
67
|
+
|
|
68
|
+
return ConcreteFeature(self.name, self.k1, self.k2)
|
|
69
|
+
|
|
70
|
+
def get_type(self) -> ConcreteFeatureType:
|
|
71
|
+
return self.type
|
|
72
|
+
|
|
73
|
+
def set_type(self, new_type: ConcreteFeatureType) -> None:
|
|
74
|
+
self.type = new_type
|
|
75
|
+
|
|
76
|
+
def get_k1(self) -> typing.Optional[typing.Union[float, int]]:
|
|
77
|
+
return self.k1
|
|
78
|
+
|
|
79
|
+
def get_k2(self) -> typing.Optional[typing.Union[float, int]]:
|
|
80
|
+
return self.k2
|
|
81
|
+
|
|
82
|
+
def set_range(
|
|
83
|
+
self,
|
|
84
|
+
k1: typing.Optional[typing.Union[float, int]],
|
|
85
|
+
k2: typing.Optional[typing.Union[float, int]],
|
|
86
|
+
) -> None:
|
|
87
|
+
self.k1 = k1
|
|
88
|
+
self.k2 = k2
|
|
89
|
+
|
|
90
|
+
def get_name(self) -> str:
|
|
91
|
+
return self.name
|
|
92
|
+
|
|
93
|
+
def __str__(self) -> str:
|
|
94
|
+
return self.get_name()
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
2
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree_expression import DegreeExpression
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree_numeric import DegreeNumeric
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree_variable import DegreeVariable
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.milp.inequation import Inequation
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import InequalityType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Degree(ABC):
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
@abstractmethod
|
|
13
|
+
def get_degree(value) -> typing.Self:
|
|
14
|
+
raise NotImplementedError
|
|
15
|
+
|
|
16
|
+
# @typing.overload
|
|
17
|
+
# @staticmethod
|
|
18
|
+
# def get_degree(value: float) -> typing.Self:
|
|
19
|
+
# return DegreeNumeric(value)
|
|
20
|
+
|
|
21
|
+
# @typing.overload
|
|
22
|
+
# @staticmethod
|
|
23
|
+
# def get_degree(value: Variable) -> typing.Self:
|
|
24
|
+
# return DegreeVariable(value)
|
|
25
|
+
|
|
26
|
+
# @typing.overload
|
|
27
|
+
# @staticmethod
|
|
28
|
+
# def get_degree(value: Expression) -> typing.Self:
|
|
29
|
+
# return DegreeExpression(value)
|
|
30
|
+
|
|
31
|
+
@abstractmethod
|
|
32
|
+
def clone(self) -> typing.Self:
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def is_numeric(self) -> bool:
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def create_inequality_with_degree_rhs(
|
|
41
|
+
self,
|
|
42
|
+
expression: Expression,
|
|
43
|
+
inequation_type: InequalityType,
|
|
44
|
+
) -> Inequation:
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
@abstractmethod
|
|
48
|
+
def add_to_expression(self, expression: Expression) -> Expression:
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
@abstractmethod
|
|
52
|
+
def subtract_from_expression(self, expression: Expression) -> Expression:
|
|
53
|
+
pass
|
|
54
|
+
|
|
55
|
+
@abstractmethod
|
|
56
|
+
def multiply_constant(self, double: float) -> Expression:
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
@abstractmethod
|
|
60
|
+
def __str__(self) -> str:
|
|
61
|
+
pass
|
|
62
|
+
|
|
63
|
+
@abstractmethod
|
|
64
|
+
def __eq__(self, degree: typing.Self) -> bool:
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
68
|
+
return not (self == value)
|
|
69
|
+
|
|
70
|
+
@abstractmethod
|
|
71
|
+
def is_number_not_one(self) -> bool:
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
@abstractmethod
|
|
75
|
+
def is_number_zero(self) -> bool:
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
def __repr__(self) -> str:
|
|
79
|
+
return str(self)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.milp.inequation import Inequation
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import InequalityType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DegreeExpression(Degree):
|
|
10
|
+
def __init__(self, expr: Expression) -> None:
|
|
11
|
+
self.expr: Expression = expr
|
|
12
|
+
|
|
13
|
+
def get_expression(self) -> Expression:
|
|
14
|
+
return self.expr
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def get_degree(value: Expression) -> typing.Self:
|
|
18
|
+
return DegreeExpression(value)
|
|
19
|
+
|
|
20
|
+
def clone(self) -> typing.Self:
|
|
21
|
+
return DegreeExpression.get_degree(self.expr)
|
|
22
|
+
|
|
23
|
+
def create_inequality_with_degree_rhs(
|
|
24
|
+
self,
|
|
25
|
+
expr: Expression,
|
|
26
|
+
inequality_type: InequalityType,
|
|
27
|
+
) -> Inequation:
|
|
28
|
+
return Inequation(
|
|
29
|
+
expr - self.expr,
|
|
30
|
+
inequality_type,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def is_numeric(self) -> bool:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
def add_to_expression(self, expr: Expression) -> Expression:
|
|
37
|
+
return expr + self.expr
|
|
38
|
+
|
|
39
|
+
def subtract_from_expression(self, expr: Expression) -> Expression:
|
|
40
|
+
return expr - self.expr
|
|
41
|
+
|
|
42
|
+
def multiply_constant(self, constant: float) -> Expression:
|
|
43
|
+
return self.expr * constant
|
|
44
|
+
|
|
45
|
+
def is_number_not_one(self) -> bool:
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
def is_number_zero(self) -> bool:
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
def __eq__(self, d: Degree) -> bool:
|
|
52
|
+
if isinstance(d, DegreeExpression):
|
|
53
|
+
return d == self.get_expression()
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
def __str__(self) -> str:
|
|
57
|
+
return f"Degree({self.expr})"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.milp.inequation import Inequation
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import InequalityType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DegreeNumeric(Degree):
|
|
10
|
+
|
|
11
|
+
def __init__(self, numeric: float) -> None:
|
|
12
|
+
self.value: float = float(numeric)
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def get_one() -> typing.Self:
|
|
16
|
+
return DegreeNumeric(1.0)
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def get_degree(value: float) -> typing.Self:
|
|
20
|
+
return DegreeNumeric(value)
|
|
21
|
+
|
|
22
|
+
def clone(self) -> typing.Self:
|
|
23
|
+
return DegreeNumeric.get_degree(self.value)
|
|
24
|
+
|
|
25
|
+
def get_numerical_value(self) -> float:
|
|
26
|
+
return self.value
|
|
27
|
+
|
|
28
|
+
def create_inequality_with_degree_rhs(
|
|
29
|
+
self, expr: Expression, inequation_type: InequalityType
|
|
30
|
+
) -> Inequation:
|
|
31
|
+
return Inequation(expr - 1.0 * self.value, inequation_type)
|
|
32
|
+
|
|
33
|
+
def is_numeric(self) -> bool:
|
|
34
|
+
return True
|
|
35
|
+
|
|
36
|
+
def add_to_expression(self, expr: Expression) -> Expression:
|
|
37
|
+
return expr + self.value
|
|
38
|
+
|
|
39
|
+
def subtract_from_expression(self, expr: Expression) -> Expression:
|
|
40
|
+
return expr - self.value
|
|
41
|
+
|
|
42
|
+
def multiply_constant(self, constant: float) -> Expression:
|
|
43
|
+
return Expression(self.value * constant)
|
|
44
|
+
|
|
45
|
+
def is_number_not_one(self) -> bool:
|
|
46
|
+
return self.value != 1.0
|
|
47
|
+
|
|
48
|
+
def is_number_zero(self) -> bool:
|
|
49
|
+
return self.value == 0.0
|
|
50
|
+
|
|
51
|
+
def __eq__(self, d: Degree) -> bool:
|
|
52
|
+
if isinstance(d, DegreeNumeric):
|
|
53
|
+
return self.value == d.get_numerical_value()
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
def __str__(self) -> str:
|
|
57
|
+
return f"Degree({self.value})"
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.milp.inequation import Inequation
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.milp.term import Term
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.milp.variable import Variable
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import InequalityType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DegreeVariable(Degree):
|
|
12
|
+
def __init__(self, variable: Variable) -> None:
|
|
13
|
+
self.variable: Variable = variable
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def get_degree(value: Variable) -> typing.Self:
|
|
17
|
+
return DegreeVariable(value)
|
|
18
|
+
|
|
19
|
+
def get_variable(self) -> Variable:
|
|
20
|
+
return self.variable
|
|
21
|
+
|
|
22
|
+
def clone(self) -> typing.Self:
|
|
23
|
+
return DegreeVariable.get_degree(self.variable)
|
|
24
|
+
|
|
25
|
+
def create_inequality_with_degree_rhs(
|
|
26
|
+
self, expr: Expression, inequality_type: InequalityType
|
|
27
|
+
) -> Inequation:
|
|
28
|
+
return Inequation(expr + Term(-1.0, self.variable), inequality_type)
|
|
29
|
+
|
|
30
|
+
def is_numeric(self) -> bool:
|
|
31
|
+
return False
|
|
32
|
+
|
|
33
|
+
def add_to_expression(self, expr: Expression) -> Expression:
|
|
34
|
+
return expr + Term(1.0, self.variable)
|
|
35
|
+
|
|
36
|
+
def subtract_from_expression(self, expr: Expression) -> Expression:
|
|
37
|
+
return expr + Term(-1.0, self.variable)
|
|
38
|
+
|
|
39
|
+
def multiply_constant(self, constant: float) -> Expression:
|
|
40
|
+
return Expression(Term(constant, self.variable))
|
|
41
|
+
|
|
42
|
+
def is_number_not_one(self) -> bool:
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
def is_number_zero(self) -> bool:
|
|
46
|
+
return False
|
|
47
|
+
|
|
48
|
+
def __eq__(self, degree: Degree) -> bool:
|
|
49
|
+
if isinstance(degree, DegreeVariable):
|
|
50
|
+
return degree.get_variable() == self.get_variable()
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
def __str__(self) -> str:
|
|
54
|
+
return f"Degree({self.variable})"
|