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,23 @@
|
|
|
1
|
+
from .util import *
|
|
2
|
+
from .milp import *
|
|
3
|
+
from .degree import *
|
|
4
|
+
from .concept import *
|
|
5
|
+
from .assertion import *
|
|
6
|
+
from .concept_equivalence import ConceptEquivalence
|
|
7
|
+
from .concrete_feature import ConcreteFeature
|
|
8
|
+
from .domain_axiom import DomainAxiom
|
|
9
|
+
from .exception import *
|
|
10
|
+
from .feature_function import FeatureFunction
|
|
11
|
+
from .general_concept_inclusion import GeneralConceptInclusion
|
|
12
|
+
from .individual import *
|
|
13
|
+
from .knowledge_base import KnowledgeBase
|
|
14
|
+
from .label import Label
|
|
15
|
+
from .modifier import *
|
|
16
|
+
from .parser import *
|
|
17
|
+
from .primitive_concept_definition import PrimitiveConceptDefinition
|
|
18
|
+
from .query import *
|
|
19
|
+
from .range_axiom import RangeAxiom
|
|
20
|
+
from .relation import Relation
|
|
21
|
+
from .restriction import *
|
|
22
|
+
from .role_parent_with_degree import RoleParentWithDegree
|
|
23
|
+
from .fuzzydl_to_owl2 import FuzzydlToOwl2
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
if typing.TYPE_CHECKING:
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
|
|
7
|
+
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree_numeric import DegreeNumeric
|
|
11
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Assertion:
|
|
15
|
+
|
|
16
|
+
def __init__(self, ind: Individual, c: Concept, d: Degree) -> None:
|
|
17
|
+
self.individual: Individual = ind
|
|
18
|
+
self.concept: Concept = c
|
|
19
|
+
self.degree: Degree = d
|
|
20
|
+
|
|
21
|
+
def clone(self) -> typing.Self:
|
|
22
|
+
return Assertion(self.individual, self.concept, self.degree)
|
|
23
|
+
|
|
24
|
+
def get_type(self) -> ConceptType:
|
|
25
|
+
return self.concept.type
|
|
26
|
+
|
|
27
|
+
def get_lower_limit(self) -> Degree:
|
|
28
|
+
return self.degree
|
|
29
|
+
|
|
30
|
+
def get_concept(self) -> Concept:
|
|
31
|
+
return self.concept
|
|
32
|
+
|
|
33
|
+
def get_individual(self) -> Individual:
|
|
34
|
+
return self.individual
|
|
35
|
+
|
|
36
|
+
def set_individual(self, ind: Individual) -> None:
|
|
37
|
+
self.individual = ind
|
|
38
|
+
|
|
39
|
+
def set_lower_limit(self, deg: Degree) -> None:
|
|
40
|
+
self.degree = deg
|
|
41
|
+
|
|
42
|
+
def get_name_without_degree(self) -> str:
|
|
43
|
+
return f"{self.individual}:{self.concept}"
|
|
44
|
+
|
|
45
|
+
def equals(self, ass: typing.Self) -> bool:
|
|
46
|
+
return self == ass
|
|
47
|
+
|
|
48
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
49
|
+
if not isinstance(value, Assertion):
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
same: bool = False
|
|
53
|
+
if str(self) == str(value):
|
|
54
|
+
same = True
|
|
55
|
+
elif (
|
|
56
|
+
self.get_name_without_degree() == value.get_name_without_degree()
|
|
57
|
+
and isinstance(self.get_lower_limit(), DegreeNumeric)
|
|
58
|
+
and isinstance(value.get_lower_limit(), DegreeNumeric)
|
|
59
|
+
and typing.cast(DegreeNumeric, self.get_lower_limit()).get_numerical_value()
|
|
60
|
+
< typing.cast(DegreeNumeric, value.get_lower_limit()).get_numerical_value()
|
|
61
|
+
):
|
|
62
|
+
same = True
|
|
63
|
+
return same
|
|
64
|
+
|
|
65
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
66
|
+
return not (self == value)
|
|
67
|
+
|
|
68
|
+
def __repr__(self) -> str:
|
|
69
|
+
return str(self)
|
|
70
|
+
|
|
71
|
+
def __str__(self) -> str:
|
|
72
|
+
return f"{self.get_name_without_degree()} >= {self.degree}"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class AtomicAssertion:
|
|
8
|
+
def __init__(self, c: Concept, degree: Degree) -> None:
|
|
9
|
+
self.c: Concept = c
|
|
10
|
+
self.degree: Degree = degree
|
|
11
|
+
|
|
12
|
+
def get_concept_name(self) -> str:
|
|
13
|
+
return str(self.c)
|
|
14
|
+
|
|
15
|
+
def get_degree(self) -> Degree:
|
|
16
|
+
return self.degree
|
|
17
|
+
|
|
18
|
+
def __str__(self) -> str:
|
|
19
|
+
return f"< {self.c} {self.degree} >"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .concept import Concept
|
|
2
|
+
from .choquet_integral import ChoquetIntegral
|
|
3
|
+
from .concrete import *
|
|
4
|
+
from .modified import *
|
|
5
|
+
from .negated_nominal import NegatedNominal
|
|
6
|
+
from .owa_concept import OwaConcept
|
|
7
|
+
from .qowa_concept import QowaConcept
|
|
8
|
+
from .sugeno_integral import SugenoIntegral
|
|
9
|
+
from .quasi_sugeno_integral import QsugenoIntegral
|
|
10
|
+
from .weighted_max_concept import WeightedMaxConcept
|
|
11
|
+
from .weighted_min_concept import WeightedMinConcept
|
|
12
|
+
from .weighted_sum_concept import WeightedSumConcept
|
|
13
|
+
from .weighted_sum_zero_concept import WeightedSumZeroConcept
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_concept_interface import (
|
|
5
|
+
HasRoleConceptInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.truth_concept import TruthConcept
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AllSomeConcept(Concept, HasRoleConceptInterface):
|
|
13
|
+
|
|
14
|
+
def __init__(self, role: str, c: Concept, c_type: ConceptType) -> None:
|
|
15
|
+
Concept.__init__(self, c_type)
|
|
16
|
+
HasRoleConceptInterface.__init__(self, role, c)
|
|
17
|
+
|
|
18
|
+
assert c_type in (ConceptType.ALL, ConceptType.SOME)
|
|
19
|
+
self._name: str = self.compute_name()
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def new(c_type: ConceptType, role: str, concept: Concept) -> typing.Self:
|
|
23
|
+
if c_type == ConceptType.SOME:
|
|
24
|
+
if ConfigReader.OPTIMIZATIONS != 0 and concept.type == ConceptType.BOTTOM:
|
|
25
|
+
return TruthConcept.get_bottom()
|
|
26
|
+
else:
|
|
27
|
+
if ConfigReader.OPTIMIZATIONS != 0 and concept.type == ConceptType.TOP:
|
|
28
|
+
return TruthConcept.get_top()
|
|
29
|
+
return AllSomeConcept(role, concept, c_type)
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def all(role: str, concept: Concept) -> typing.Self:
|
|
33
|
+
return AllSomeConcept.new(ConceptType.ALL, role, concept)
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def some(role: str, concept: Concept) -> typing.Self:
|
|
37
|
+
return AllSomeConcept.new(ConceptType.SOME, role, concept)
|
|
38
|
+
|
|
39
|
+
def clone(self) -> typing.Self:
|
|
40
|
+
return AllSomeConcept.new(self.type, self.role, self.curr_concept)
|
|
41
|
+
|
|
42
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
43
|
+
return AllSomeConcept.new(self.type, self.role, self.curr_concept.replace(a, c))
|
|
44
|
+
|
|
45
|
+
def get_atoms(self) -> list[typing.Self]:
|
|
46
|
+
return self.curr_concept.get_atoms()
|
|
47
|
+
|
|
48
|
+
def is_complemented_atomic(self) -> bool:
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
def compute_name(self) -> str:
|
|
52
|
+
if self.type == ConceptType.ALL:
|
|
53
|
+
return f"(all {self.role} {self.curr_concept})"
|
|
54
|
+
else:
|
|
55
|
+
return f"(some {self.role} {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 set([self.role]) | self.curr_concept.get_roles()
|
|
62
|
+
|
|
63
|
+
def __neg__(self) -> Concept:
|
|
64
|
+
return AllSomeConcept.new(
|
|
65
|
+
ConceptType.ALL if self.type == ConceptType.SOME else ConceptType.SOME,
|
|
66
|
+
self.role,
|
|
67
|
+
-self.curr_concept,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def __hash__(self) -> int:
|
|
71
|
+
return hash(str(self))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# class AllConcept(AllSomeConcept):
|
|
75
|
+
# def __call__(self, *args) -> typing.Self:
|
|
76
|
+
# return AllSomeConcept.all(args)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# class SomeConcept(AllSomeConcept):
|
|
80
|
+
# def __call__(self, *args) -> typing.Self:
|
|
81
|
+
# return AllSomeConcept.some(args)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
All = AllSomeConcept.all
|
|
85
|
+
Some = AllSomeConcept.some
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
3
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
4
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_concept_interface import (
|
|
5
|
+
HasRoleConceptInterface,
|
|
6
|
+
)
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ApproximationConcept(Concept, HasRoleConceptInterface):
|
|
12
|
+
|
|
13
|
+
INVERSE_APPROXIMATION: dict[ConceptType, ConceptType] = {
|
|
14
|
+
k: v
|
|
15
|
+
for k, v in zip(
|
|
16
|
+
[
|
|
17
|
+
ConceptType.LOWER_APPROX,
|
|
18
|
+
ConceptType.TIGHT_LOWER_APPROX,
|
|
19
|
+
ConceptType.LOOSE_LOWER_APPROX,
|
|
20
|
+
ConceptType.UPPER_APPROX,
|
|
21
|
+
ConceptType.TIGHT_UPPER_APPROX,
|
|
22
|
+
ConceptType.LOOSE_UPPER_APPROX,
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
ConceptType.UPPER_APPROX,
|
|
26
|
+
ConceptType.TIGHT_UPPER_APPROX,
|
|
27
|
+
ConceptType.LOOSE_UPPER_APPROX,
|
|
28
|
+
ConceptType.LOWER_APPROX,
|
|
29
|
+
ConceptType.TIGHT_LOWER_APPROX,
|
|
30
|
+
ConceptType.LOOSE_LOWER_APPROX,
|
|
31
|
+
],
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
def __init__(self, c_type: ConceptType, role: str, c: Concept) -> None:
|
|
36
|
+
Concept.__init__(self, c_type)
|
|
37
|
+
HasRoleConceptInterface.__init__(self, role, c)
|
|
38
|
+
|
|
39
|
+
assert c_type in (
|
|
40
|
+
ConceptType.LOWER_APPROX,
|
|
41
|
+
ConceptType.TIGHT_LOWER_APPROX,
|
|
42
|
+
ConceptType.LOOSE_LOWER_APPROX,
|
|
43
|
+
ConceptType.UPPER_APPROX,
|
|
44
|
+
ConceptType.TIGHT_UPPER_APPROX,
|
|
45
|
+
ConceptType.LOOSE_UPPER_APPROX,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
self.name = self.compute_name()
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def lower_approx(role: str, c: Concept) -> Concept:
|
|
52
|
+
return ApproximationConcept(ConceptType.LOWER_APPROX, role, c)
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def loose_lower_approx(role: str, c: Concept) -> Concept:
|
|
56
|
+
return ApproximationConcept(ConceptType.LOOSE_LOWER_APPROX, role, c)
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def tight_lower_approx(role: str, c: Concept) -> Concept:
|
|
60
|
+
return ApproximationConcept(ConceptType.TIGHT_LOWER_APPROX, role, c)
|
|
61
|
+
|
|
62
|
+
@staticmethod
|
|
63
|
+
def upper_approx(role: str, c: Concept) -> Concept:
|
|
64
|
+
return ApproximationConcept(ConceptType.UPPER_APPROX, role, c)
|
|
65
|
+
|
|
66
|
+
@staticmethod
|
|
67
|
+
def loose_upper_approx(role: str, c: Concept) -> Concept:
|
|
68
|
+
return ApproximationConcept(ConceptType.LOOSE_UPPER_APPROX, role, c)
|
|
69
|
+
|
|
70
|
+
@staticmethod
|
|
71
|
+
def tight_upper_approx(role: str, c: Concept) -> Concept:
|
|
72
|
+
return ApproximationConcept(ConceptType.TIGHT_UPPER_APPROX, role, c)
|
|
73
|
+
|
|
74
|
+
def clone(self) -> typing.Self:
|
|
75
|
+
return ApproximationConcept(self.type, self.role, self.curr_concept)
|
|
76
|
+
|
|
77
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
78
|
+
if isinstance(c, ApproximationConcept):
|
|
79
|
+
c_type: ConceptType = c.type
|
|
80
|
+
if c_type == ConceptType.LOWER_APPROX:
|
|
81
|
+
return ApproximationConcept.lower_approx(
|
|
82
|
+
self.role, self.curr_concept.replace(a, c)
|
|
83
|
+
)
|
|
84
|
+
elif c_type == ConceptType.LOOSE_LOWER_APPROX:
|
|
85
|
+
return ApproximationConcept.loose_lower_approx(
|
|
86
|
+
self.role, self.curr_concept.replace(a, c)
|
|
87
|
+
)
|
|
88
|
+
elif c_type == ConceptType.TIGHT_LOWER_APPROX:
|
|
89
|
+
return ApproximationConcept.tight_lower_approx(
|
|
90
|
+
self.role, self.curr_concept.replace(a, c)
|
|
91
|
+
)
|
|
92
|
+
elif c_type == ConceptType.UPPER_APPROX:
|
|
93
|
+
return ApproximationConcept.upper_approx(
|
|
94
|
+
self.role, self.curr_concept.replace(a, c)
|
|
95
|
+
)
|
|
96
|
+
elif c_type == ConceptType.LOOSE_UPPER_APPROX:
|
|
97
|
+
return ApproximationConcept.loose_upper_approx(
|
|
98
|
+
self.role, self.curr_concept.replace(a, c)
|
|
99
|
+
)
|
|
100
|
+
elif c_type == ConceptType.TIGHT_UPPER_APPROX:
|
|
101
|
+
return ApproximationConcept.tight_upper_approx(
|
|
102
|
+
self.role, self.curr_concept.replace(a, c)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def compute_name(self) -> typing.Optional[str]:
|
|
106
|
+
if self.type == ConceptType.LOWER_APPROX:
|
|
107
|
+
return f"(la {self.role} {self.curr_concept})"
|
|
108
|
+
elif self.type == ConceptType.LOOSE_UPPER_APPROX:
|
|
109
|
+
return f"(lua {self.role} {self.curr_concept})"
|
|
110
|
+
elif self.type == ConceptType.LOOSE_LOWER_APPROX:
|
|
111
|
+
return f"(lla {self.role} {self.curr_concept})"
|
|
112
|
+
elif self.type == ConceptType.UPPER_APPROX:
|
|
113
|
+
return f"(ua {self.role} {self.curr_concept})"
|
|
114
|
+
elif self.type == ConceptType.LOWER_APPROX:
|
|
115
|
+
return f"(la {self.role} {self.curr_concept})"
|
|
116
|
+
elif self.type == ConceptType.LOOSE_UPPER_APPROX:
|
|
117
|
+
return f"(lua {self.role} {self.curr_concept})"
|
|
118
|
+
|
|
119
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
120
|
+
return self.curr_concept.compute_atomic_concepts()
|
|
121
|
+
|
|
122
|
+
def get_roles(self) -> set[str]:
|
|
123
|
+
return set([self.role]) | self.curr_concept.get_roles()
|
|
124
|
+
|
|
125
|
+
def __neg__(self) -> Concept:
|
|
126
|
+
return ApproximationConcept(
|
|
127
|
+
ApproximationConcept.INVERSE_APPROXIMATION[self.type],
|
|
128
|
+
self.role,
|
|
129
|
+
-self.curr_concept,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
133
|
+
return OperatorConcept.and_(self, value)
|
|
134
|
+
|
|
135
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
136
|
+
return OperatorConcept.or_(self, value)
|
|
137
|
+
|
|
138
|
+
def __hash__(self) -> int:
|
|
139
|
+
return hash(str(self))
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
LowerApprox = ApproximationConcept.lower_approx
|
|
143
|
+
LooseLowerApprox = ApproximationConcept.loose_lower_approx
|
|
144
|
+
TightLowerApprox = ApproximationConcept.tight_lower_approx
|
|
145
|
+
UpperApprox = ApproximationConcept.upper_approx
|
|
146
|
+
LooseUpperApprox = ApproximationConcept.loose_upper_approx
|
|
147
|
+
TightUpperApprox = ApproximationConcept.tight_upper_approx
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AtomicConcept(Concept):
|
|
12
|
+
def __init__(self, name: str) -> None:
|
|
13
|
+
super().__init__(c_type=ConceptType.ATOMIC, name=name)
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def new_atomic_concept() -> typing.Self:
|
|
17
|
+
Concept.num_new_concepts += 1
|
|
18
|
+
return AtomicConcept(
|
|
19
|
+
f"NewConcept{Concept.SPECIAL_STRING}{Concept.num_new_concepts}"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def is_concrete(self) -> bool:
|
|
23
|
+
return False
|
|
24
|
+
|
|
25
|
+
def is_atomic(self) -> bool:
|
|
26
|
+
return True
|
|
27
|
+
|
|
28
|
+
def is_complemented_atomic(self) -> bool:
|
|
29
|
+
return False
|
|
30
|
+
|
|
31
|
+
def get_atomic_concepts(self) -> set[typing.Self]:
|
|
32
|
+
return self.compute_atomic_concepts()
|
|
33
|
+
|
|
34
|
+
def compute_name(self) -> str:
|
|
35
|
+
return self.name
|
|
36
|
+
|
|
37
|
+
def get_atoms(self) -> list[typing.Self]:
|
|
38
|
+
return [self]
|
|
39
|
+
|
|
40
|
+
def get_clauses(self, is_type: typing.Callable) -> set[typing.Self]:
|
|
41
|
+
return set([self])
|
|
42
|
+
|
|
43
|
+
def clone(self) -> typing.Self:
|
|
44
|
+
return AtomicConcept(self.name)
|
|
45
|
+
|
|
46
|
+
def compute_atomic_concepts(self) -> set[typing.Self]:
|
|
47
|
+
return [self]
|
|
48
|
+
|
|
49
|
+
def get_roles(self) -> set[str]:
|
|
50
|
+
return set()
|
|
51
|
+
|
|
52
|
+
def replace(self, a: typing.Self, c: typing.Self) -> typing.Optional[typing.Self]:
|
|
53
|
+
if c.type == ConceptType.ATOMIC:
|
|
54
|
+
if self == a:
|
|
55
|
+
return c
|
|
56
|
+
return self
|
|
57
|
+
Util.error(f"Error replacing in concept {self}")
|
|
58
|
+
|
|
59
|
+
def reduce_idempotency(self, is_type: typing.Callable) -> typing.Self:
|
|
60
|
+
return self
|
|
61
|
+
|
|
62
|
+
def __invert__(self) -> typing.Self:
|
|
63
|
+
return -self
|
|
64
|
+
|
|
65
|
+
def __neg__(self) -> typing.Self:
|
|
66
|
+
return OperatorConcept.not_(self)
|
|
67
|
+
|
|
68
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
69
|
+
return OperatorConcept.and_(self, value)
|
|
70
|
+
|
|
71
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
72
|
+
return OperatorConcept.or_(self, value)
|
|
73
|
+
|
|
74
|
+
def __rshift__(self, value: typing.Self) -> typing.Self:
|
|
75
|
+
# return ImpliesConcept([self, value], ConceptType.GOEDEL_IMPLIES)
|
|
76
|
+
pass
|
|
77
|
+
|
|
78
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
79
|
+
return isinstance(value, AtomicConcept) and str(self) == str(value)
|
|
80
|
+
|
|
81
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
82
|
+
return not (self == value)
|
|
83
|
+
|
|
84
|
+
def __hash__(self) -> int:
|
|
85
|
+
return hash(self.name)
|
|
86
|
+
|
|
87
|
+
def __repr__(self) -> str:
|
|
88
|
+
return str(self)
|
|
89
|
+
|
|
90
|
+
# def __str__(self) -> str:
|
|
91
|
+
# return self.compute_name()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_weighted_concepts_interface import (
|
|
7
|
+
HasWeightedConceptsInterface,
|
|
8
|
+
)
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType
|
|
11
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ChoquetIntegral(Concept, HasWeightedConceptsInterface):
|
|
15
|
+
def __init__(self, weights: list[float], concepts: list[Concept]) -> None:
|
|
16
|
+
Concept.__init__(self, ConceptType.CHOQUET_INTEGRAL)
|
|
17
|
+
HasWeightedConceptsInterface.__init__(self, weights, concepts)
|
|
18
|
+
|
|
19
|
+
if weights is not None:
|
|
20
|
+
if len(weights) != len(concepts):
|
|
21
|
+
Util.error(
|
|
22
|
+
"Error: The number of weights and the number of concepts should be the same"
|
|
23
|
+
)
|
|
24
|
+
self.name: str = str(self)
|
|
25
|
+
|
|
26
|
+
def clone(self) -> typing.Self:
|
|
27
|
+
return ChoquetIntegral(self.weights[:], [c for c in self.concepts])
|
|
28
|
+
|
|
29
|
+
def compute_atomic_concepts(self) -> set[Concept]:
|
|
30
|
+
concept_list = set()
|
|
31
|
+
for c in self.concepts:
|
|
32
|
+
concept_list.update(c.compute_atomic_concepts())
|
|
33
|
+
return concept_list
|
|
34
|
+
|
|
35
|
+
def get_roles(self) -> set[str]:
|
|
36
|
+
role_list = set()
|
|
37
|
+
for c in self.concepts:
|
|
38
|
+
role_list.update(c.get_roles())
|
|
39
|
+
return role_list
|
|
40
|
+
|
|
41
|
+
def replace(self, a: Concept, c: Concept) -> Concept:
|
|
42
|
+
return -ChoquetIntegral(
|
|
43
|
+
self.weights, [ci.replace(a, c) for ci in self.concepts]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def compute_name(self) -> str:
|
|
47
|
+
str_weights: str = ""
|
|
48
|
+
if self.weights is not None:
|
|
49
|
+
str_weights = " ".join(list(str, self.weights))
|
|
50
|
+
str_concepts: str = " ".join(list(str, self.concepts))
|
|
51
|
+
name = f"(choquet ({str_weights}) ({str_concepts}))"
|
|
52
|
+
return name
|
|
53
|
+
|
|
54
|
+
def __neg__(self) -> Concept:
|
|
55
|
+
return OperatorConcept.not_(self)
|
|
56
|
+
|
|
57
|
+
def __and__(self, value: typing.Self) -> typing.Self:
|
|
58
|
+
return OperatorConcept.and_(self, value)
|
|
59
|
+
|
|
60
|
+
def __or__(self, value: typing.Self) -> typing.Self:
|
|
61
|
+
return OperatorConcept.or_(self, value)
|
|
62
|
+
|
|
63
|
+
def __hash__(self) -> int:
|
|
64
|
+
return hash(str(self))
|