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,82 @@
|
|
|
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.degree.degree import Degree
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import LogicOperatorType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GeneralConceptInclusion:
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
subsumer: Concept,
|
|
14
|
+
subsumed: Concept,
|
|
15
|
+
degree: Degree,
|
|
16
|
+
type_: LogicOperatorType,
|
|
17
|
+
):
|
|
18
|
+
self.subsumer: Concept = subsumer
|
|
19
|
+
self.subsumed: Concept = subsumed
|
|
20
|
+
self.degree: Degree = degree
|
|
21
|
+
self.type: LogicOperatorType = type_
|
|
22
|
+
|
|
23
|
+
def clone(self) -> typing.Self:
|
|
24
|
+
return GeneralConceptInclusion(
|
|
25
|
+
self.subsumer, self.subsumed, self.degree, self.type
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
def get_subsumer(self) -> Concept:
|
|
29
|
+
return self.subsumer
|
|
30
|
+
|
|
31
|
+
def get_subsumed(self) -> Concept:
|
|
32
|
+
return self.subsumed
|
|
33
|
+
|
|
34
|
+
def get_type(self) -> LogicOperatorType:
|
|
35
|
+
return self.type
|
|
36
|
+
|
|
37
|
+
def get_degree(self) -> Degree:
|
|
38
|
+
return self.degree
|
|
39
|
+
|
|
40
|
+
def set_degree(self, deg: Degree) -> None:
|
|
41
|
+
self.degree = deg
|
|
42
|
+
|
|
43
|
+
def set_subsumer(self, new_concept: Concept) -> None:
|
|
44
|
+
self.subsumer = new_concept
|
|
45
|
+
|
|
46
|
+
def set_subsumed(self, new_concept: Concept) -> None:
|
|
47
|
+
self.subsumed = new_concept
|
|
48
|
+
|
|
49
|
+
def __eq__(self, other: typing.Self) -> bool:
|
|
50
|
+
return (
|
|
51
|
+
isinstance(other, GeneralConceptInclusion)
|
|
52
|
+
and self.subsumed == other.subsumed
|
|
53
|
+
and self.subsumer == other.subsumer
|
|
54
|
+
and self.degree == other.degree
|
|
55
|
+
and self.type == other.type
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def __ne__(self, other: typing.Self) -> bool:
|
|
59
|
+
return not (self == other)
|
|
60
|
+
|
|
61
|
+
def __lt__(self, other: typing.Self) -> bool:
|
|
62
|
+
return isinstance(other, GeneralConceptInclusion) and hash(self) < hash(other)
|
|
63
|
+
|
|
64
|
+
def __le__(self, other: typing.Self) -> bool:
|
|
65
|
+
return not (self > other)
|
|
66
|
+
|
|
67
|
+
def __gt__(self, other: typing.Self) -> bool:
|
|
68
|
+
return isinstance(other, GeneralConceptInclusion) and hash(self) > hash(other)
|
|
69
|
+
|
|
70
|
+
def __ge__(self, other: typing.Self) -> bool:
|
|
71
|
+
return not (self < other)
|
|
72
|
+
|
|
73
|
+
def __hash__(self) -> int:
|
|
74
|
+
return hash(str(self))
|
|
75
|
+
|
|
76
|
+
def __repr__(self) -> str:
|
|
77
|
+
return str(self)
|
|
78
|
+
|
|
79
|
+
def __str__(self) -> str:
|
|
80
|
+
return (
|
|
81
|
+
f"{self.subsumed} =>_{self.type.name[0]} {self.subsumer} >= {self.degree}"
|
|
82
|
+
)
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
import typing
|
|
5
|
+
from collections import deque
|
|
6
|
+
|
|
7
|
+
from sortedcontainers import SortedSet
|
|
8
|
+
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_number.triangular_fuzzy_number import (
|
|
10
|
+
TriangularFuzzyNumber,
|
|
11
|
+
)
|
|
12
|
+
from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
|
|
13
|
+
from fuzzy_dl_owl2.fuzzydl.individual.representative_individual import (
|
|
14
|
+
RepresentativeIndividual,
|
|
15
|
+
)
|
|
16
|
+
from fuzzy_dl_owl2.fuzzydl.relation import Relation
|
|
17
|
+
from fuzzy_dl_owl2.fuzzydl.util import constants
|
|
18
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import (
|
|
19
|
+
CreatedIndividualBlockingType,
|
|
20
|
+
InequalityType,
|
|
21
|
+
)
|
|
22
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CreatedIndividual(Individual):
|
|
26
|
+
|
|
27
|
+
@typing.overload
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
name: str,
|
|
31
|
+
parent: typing.Optional[Individual] = None,
|
|
32
|
+
role_name: typing.Optional[str] = None,
|
|
33
|
+
) -> None: ...
|
|
34
|
+
|
|
35
|
+
@typing.overload
|
|
36
|
+
def __init__(self, name: str) -> None: ...
|
|
37
|
+
|
|
38
|
+
def __init__(self, *args) -> None:
|
|
39
|
+
if len(args) not in [1, 3]:
|
|
40
|
+
raise NotImplementedError
|
|
41
|
+
|
|
42
|
+
assert isinstance(args[0], str)
|
|
43
|
+
|
|
44
|
+
if len(args) == 1:
|
|
45
|
+
self.__created_ind_init_2(*args)
|
|
46
|
+
else:
|
|
47
|
+
assert args[1] is None or isinstance(args[1], Individual)
|
|
48
|
+
assert args[2] is None or isinstance(args[2], str)
|
|
49
|
+
if len(args) == 3:
|
|
50
|
+
self.__created_ind_init_1(*args)
|
|
51
|
+
|
|
52
|
+
def __created_ind_init_1(
|
|
53
|
+
self,
|
|
54
|
+
name: str,
|
|
55
|
+
parent: typing.Optional[Individual] = None,
|
|
56
|
+
role_name: typing.Optional[str] = None,
|
|
57
|
+
) -> None:
|
|
58
|
+
super().__init__(name)
|
|
59
|
+
|
|
60
|
+
self.representatives: list[RepresentativeIndividual] = list()
|
|
61
|
+
|
|
62
|
+
self.concept_list: set[int] = set()
|
|
63
|
+
self.directly_blocked: CreatedIndividualBlockingType = (
|
|
64
|
+
CreatedIndividualBlockingType.UNCHECKED
|
|
65
|
+
)
|
|
66
|
+
self.indirectly_blocked: CreatedIndividualBlockingType = (
|
|
67
|
+
CreatedIndividualBlockingType.UNCHECKED
|
|
68
|
+
)
|
|
69
|
+
self.not_self_roles: set[str] = set()
|
|
70
|
+
self.parent: typing.Optional[Individual] = parent
|
|
71
|
+
self.role_name: str = role_name
|
|
72
|
+
self.depth: int = (
|
|
73
|
+
typing.cast(CreatedIndividual, parent).depth + 1
|
|
74
|
+
if parent is not None and parent.is_blockable()
|
|
75
|
+
else 2
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
self.blocking_ancestor: typing.Optional[str] = None
|
|
79
|
+
self.blocking_ancestor_y: typing.Optional[str] = None
|
|
80
|
+
self.blocking_ancestor_y_prime: typing.Optional[str] = None
|
|
81
|
+
self._is_concrete: bool = False
|
|
82
|
+
|
|
83
|
+
if parent is not None:
|
|
84
|
+
Util.debug(
|
|
85
|
+
f"Created new individual {name}, ID = {self.get_integer_id()} with parent {parent}"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
def __created_ind_init_2(self, name: str) -> None:
|
|
89
|
+
self.__created_ind_init_1(name, None, None)
|
|
90
|
+
Util.debug(f"Created new individual {name}, ID = {self.get_integer_id()}")
|
|
91
|
+
|
|
92
|
+
def clone(self) -> typing.Self:
|
|
93
|
+
ind: CreatedIndividual = CreatedIndividual(str(self), None, self.role_name)
|
|
94
|
+
self.clone_special_attributes(ind)
|
|
95
|
+
return ind
|
|
96
|
+
|
|
97
|
+
def clone_special_attributes(self, ind: typing.Self) -> None:
|
|
98
|
+
self.clone_attributes(ind)
|
|
99
|
+
ind.representatives = copy.deepcopy(self.representatives)
|
|
100
|
+
ind.blocking_ancestor = (
|
|
101
|
+
self.blocking_ancestor if self.blocking_ancestor is not None else None
|
|
102
|
+
)
|
|
103
|
+
ind.blocking_ancestor_y = (
|
|
104
|
+
self.blocking_ancestor_y if self.blocking_ancestor_y is not None else None
|
|
105
|
+
)
|
|
106
|
+
ind.blocking_ancestor_y_prime = (
|
|
107
|
+
self.blocking_ancestor_y_prime
|
|
108
|
+
if self.blocking_ancestor_y_prime is not None
|
|
109
|
+
else None
|
|
110
|
+
)
|
|
111
|
+
ind.concept_list = copy.deepcopy(self.concept_list)
|
|
112
|
+
ind.depth = self.depth
|
|
113
|
+
ind.directly_blocked = self.directly_blocked
|
|
114
|
+
ind.indirectly_blocked = copy.deepcopy(self.indirectly_blocked)
|
|
115
|
+
ind._is_concrete = self._is_concrete
|
|
116
|
+
if self.parent is not None:
|
|
117
|
+
ind.parent = self.parent.clone()
|
|
118
|
+
ind.role_name = self.role_name
|
|
119
|
+
|
|
120
|
+
def get_integer_id(self) -> int:
|
|
121
|
+
return int(self.name[1:])
|
|
122
|
+
|
|
123
|
+
def get_depth(self) -> int:
|
|
124
|
+
return self.depth
|
|
125
|
+
|
|
126
|
+
def get_parent(self) -> typing.Optional[Individual]:
|
|
127
|
+
return self.parent
|
|
128
|
+
|
|
129
|
+
def get_parent_name(self) -> str:
|
|
130
|
+
return self.parent.name if self.parent else ""
|
|
131
|
+
|
|
132
|
+
def get_role_name(self) -> str:
|
|
133
|
+
return self.role_name
|
|
134
|
+
|
|
135
|
+
def get_representative_if_exists(
|
|
136
|
+
self,
|
|
137
|
+
type: InequalityType,
|
|
138
|
+
f_name: str,
|
|
139
|
+
f: TriangularFuzzyNumber,
|
|
140
|
+
) -> typing.Optional[typing.Self]:
|
|
141
|
+
for ind in self.representatives:
|
|
142
|
+
if (
|
|
143
|
+
ind.get_type() != type
|
|
144
|
+
or ind.get_feature_name() != f_name
|
|
145
|
+
or ind.get_fuzzy_number() != f
|
|
146
|
+
):
|
|
147
|
+
continue
|
|
148
|
+
return ind.get_individual()
|
|
149
|
+
return None
|
|
150
|
+
|
|
151
|
+
def mark_indirectly_blocked(self) -> None:
|
|
152
|
+
Util.debug(
|
|
153
|
+
f"{constants.SEPARATOR}Mark subtree of {self.name} indirectly blocked"
|
|
154
|
+
)
|
|
155
|
+
queue: deque[CreatedIndividual] = deque()
|
|
156
|
+
queue.append(self)
|
|
157
|
+
while len(queue) > 0:
|
|
158
|
+
ind: CreatedIndividual = queue.popleft()
|
|
159
|
+
if len(ind.role_relations) == 0:
|
|
160
|
+
break
|
|
161
|
+
for role in ind.role_relations:
|
|
162
|
+
rels: list[Relation] = copy.deepcopy(ind.role_relations[role])
|
|
163
|
+
for rel in rels:
|
|
164
|
+
Util.debug(
|
|
165
|
+
f"{rel.get_subject_individual()} has role {rel.get_role_name()} with filler {rel.get_object_individual()}"
|
|
166
|
+
)
|
|
167
|
+
son: Individual = rel.get_object_individual()
|
|
168
|
+
if son != ind.parent:
|
|
169
|
+
if not son.is_blockable():
|
|
170
|
+
continue
|
|
171
|
+
son: CreatedIndividual = typing.cast(CreatedIndividual, son)
|
|
172
|
+
Util.debug(
|
|
173
|
+
f"Filler is not {self.name}'s parent, so mark {son} as INDIRECTLY BLOCKED"
|
|
174
|
+
)
|
|
175
|
+
son.indirectly_blocked = CreatedIndividualBlockingType.BLOCKED
|
|
176
|
+
if rel.get_subject_individual() != rel.get_object_individual():
|
|
177
|
+
queue.append(son)
|
|
178
|
+
Util.debug("Filler is parent, so skip")
|
|
179
|
+
Util.debug(
|
|
180
|
+
f"{constants.SEPARATOR}END Mark INDIRECTLY BLOCKED subtree of {self.name}{constants.SEPARATOR}"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
def individual_set_intersection_of(
|
|
184
|
+
self, set1: SortedSet[typing.Self], set2: SortedSet[typing.Self]
|
|
185
|
+
) -> SortedSet[typing.Self]:
|
|
186
|
+
return set1.intersection(set2)
|
|
187
|
+
|
|
188
|
+
def set_concrete_individual(self) -> None:
|
|
189
|
+
self._is_concrete = True
|
|
190
|
+
|
|
191
|
+
def is_concrete(self) -> bool:
|
|
192
|
+
return self._is_concrete
|
|
193
|
+
|
|
194
|
+
def is_blockable(self) -> bool:
|
|
195
|
+
return len(self.nominal_list) == 0
|
|
196
|
+
|
|
197
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
198
|
+
return self.name == value.name
|
|
199
|
+
|
|
200
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
201
|
+
return not (self == value)
|
|
202
|
+
|
|
203
|
+
def __lt__(self, value: typing.Self) -> bool:
|
|
204
|
+
return self.get_integer_id() < value.get_integer_id()
|
|
205
|
+
|
|
206
|
+
def __ge__(self, value: typing.Self) -> bool:
|
|
207
|
+
return not (self < value)
|
|
208
|
+
|
|
209
|
+
def __le__(self, value: typing.Self) -> bool:
|
|
210
|
+
return self.get_integer_id() <= value.get_integer_id()
|
|
211
|
+
|
|
212
|
+
def __gt__(self, value: typing.Self) -> bool:
|
|
213
|
+
return not (self <= value)
|
|
214
|
+
|
|
215
|
+
def __hash__(self) -> int:
|
|
216
|
+
return hash(str(self))
|
|
217
|
+
|
|
218
|
+
def __str__(self) -> str:
|
|
219
|
+
return self.name
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
import typing
|
|
5
|
+
from abc import abstractmethod
|
|
6
|
+
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.assertion.assertion import Assertion
|
|
8
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_number.triangular_fuzzy_number import (
|
|
10
|
+
TriangularFuzzyNumber,
|
|
11
|
+
)
|
|
12
|
+
from fuzzy_dl_owl2.fuzzydl.exception.inconsistent_ontology_exception import (
|
|
13
|
+
InconsistentOntologyException,
|
|
14
|
+
)
|
|
15
|
+
from fuzzy_dl_owl2.fuzzydl.relation import Relation
|
|
16
|
+
from fuzzy_dl_owl2.fuzzydl.restriction.restriction import Restriction
|
|
17
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import RepresentativeIndividualType
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Individual:
|
|
21
|
+
DEFAULT_NAME: str = "i"
|
|
22
|
+
|
|
23
|
+
def __init__(self, name: str) -> None:
|
|
24
|
+
self.name: str = name
|
|
25
|
+
self.concrete_role_restrictions: dict[str, list[Assertion]] = dict()
|
|
26
|
+
self.fillers_to_show: dict[str, set[str]] = dict()
|
|
27
|
+
self.list_of_concepts: set[Concept] = set()
|
|
28
|
+
self.nominal_list: set[str] = set()
|
|
29
|
+
self.not_self_roles: set[str] = list()
|
|
30
|
+
self.role_relations: dict[str, list[Relation]] = dict()
|
|
31
|
+
self.role_restrictions: dict[str, list[Restriction]] = dict()
|
|
32
|
+
|
|
33
|
+
def clone(self) -> typing.Self:
|
|
34
|
+
ind = Individual(self.name)
|
|
35
|
+
self.clone_attributes(ind)
|
|
36
|
+
return ind
|
|
37
|
+
|
|
38
|
+
def clone_attributes(self, ind: typing.Self) -> None:
|
|
39
|
+
ind.concrete_role_restrictions = {
|
|
40
|
+
k: [a for a in v] for k, v in self.concrete_role_restrictions.items()
|
|
41
|
+
}
|
|
42
|
+
ind.fillers_to_show = copy.deepcopy(self.fillers_to_show)
|
|
43
|
+
ind.list_of_concepts = set([c for c in self.list_of_concepts])
|
|
44
|
+
ind.nominal_list = copy.deepcopy(self.nominal_list)
|
|
45
|
+
ind.not_self_roles = copy.deepcopy(self.not_self_roles)
|
|
46
|
+
# ind.representatives = copy.deepcopy(self.representatives)
|
|
47
|
+
ind.role_restrictions = {
|
|
48
|
+
k: [r.clone() for r in v] for k, v in self.role_restrictions.items()
|
|
49
|
+
}
|
|
50
|
+
ind.role_relations = {
|
|
51
|
+
k: [r.clone() for r in v] for k, v in self.role_relations.items()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def set_name(self, name: str) -> None:
|
|
55
|
+
self.name = name
|
|
56
|
+
|
|
57
|
+
def add_concrete_restriction(self, f_name: str, ass: Assertion) -> None:
|
|
58
|
+
self.concrete_role_restrictions[f_name] = self.concrete_role_restrictions.get(
|
|
59
|
+
f_name, []
|
|
60
|
+
) + [ass]
|
|
61
|
+
|
|
62
|
+
@abstractmethod
|
|
63
|
+
def get_representative_if_exists(
|
|
64
|
+
self,
|
|
65
|
+
type: RepresentativeIndividualType,
|
|
66
|
+
f_name: str,
|
|
67
|
+
f: TriangularFuzzyNumber,
|
|
68
|
+
):
|
|
69
|
+
pass
|
|
70
|
+
|
|
71
|
+
def add_concept(self, c: Concept) -> None:
|
|
72
|
+
self.list_of_concepts.add(c)
|
|
73
|
+
|
|
74
|
+
def get_concepts(self) -> set[Concept]:
|
|
75
|
+
return self.list_of_concepts
|
|
76
|
+
|
|
77
|
+
def add_to_nominal_list(self, ind_name: str) -> None:
|
|
78
|
+
self.nominal_list.add(ind_name)
|
|
79
|
+
|
|
80
|
+
def get_nominal_list(self) -> set[str]:
|
|
81
|
+
return self.nominal_list
|
|
82
|
+
|
|
83
|
+
def is_blockable(self) -> bool:
|
|
84
|
+
return False
|
|
85
|
+
|
|
86
|
+
def set_label(self, ind_name: str) -> None:
|
|
87
|
+
raise InconsistentOntologyException(
|
|
88
|
+
f"Individuals cannot have names {self.name} and {ind_name}"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def prune(self) -> None:
|
|
92
|
+
to_prune: list[Individual] = []
|
|
93
|
+
for role in self.role_relations:
|
|
94
|
+
rels: list[Relation] = self.role_relations.get(role, [])
|
|
95
|
+
for r in rels:
|
|
96
|
+
obj: Individual = r.get_object_individual()
|
|
97
|
+
if obj.is_blockable():
|
|
98
|
+
to_prune.append(obj)
|
|
99
|
+
self.role_relations = dict()
|
|
100
|
+
for i in to_prune:
|
|
101
|
+
i.prune()
|
|
102
|
+
|
|
103
|
+
def __eq__(self, value: typing.Self) -> bool:
|
|
104
|
+
return self.name == value.name
|
|
105
|
+
|
|
106
|
+
def __ne__(self, value: typing.Self) -> bool:
|
|
107
|
+
return not (self == value)
|
|
108
|
+
|
|
109
|
+
def __repr__(self) -> str:
|
|
110
|
+
return str(self)
|
|
111
|
+
|
|
112
|
+
def __str__(self) -> str:
|
|
113
|
+
return self.name
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
if typing.TYPE_CHECKING:
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_number.triangular_fuzzy_number import (
|
|
7
|
+
TriangularFuzzyNumber,
|
|
8
|
+
)
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.individual.created_individual import CreatedIndividual
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import RepresentativeIndividualType
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class RepresentativeIndividual:
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
c_type: RepresentativeIndividualType,
|
|
18
|
+
f_name: str,
|
|
19
|
+
f: TriangularFuzzyNumber,
|
|
20
|
+
ind: CreatedIndividual,
|
|
21
|
+
) -> None:
|
|
22
|
+
self.f_name: str = f_name
|
|
23
|
+
self.type: RepresentativeIndividualType = c_type
|
|
24
|
+
self.f: TriangularFuzzyNumber = f
|
|
25
|
+
self.ind: CreatedIndividual = ind
|
|
26
|
+
|
|
27
|
+
def get_type(self) -> RepresentativeIndividualType:
|
|
28
|
+
return self.type
|
|
29
|
+
|
|
30
|
+
def get_feature_name(self) -> str:
|
|
31
|
+
return self.f_name
|
|
32
|
+
|
|
33
|
+
def get_fuzzy_number(self) -> TriangularFuzzyNumber:
|
|
34
|
+
return self.f
|
|
35
|
+
|
|
36
|
+
def get_individual(self) -> CreatedIndividual:
|
|
37
|
+
return self.ind
|