fuzzy-dl-owl2 1.0.6__py3-none-any.whl → 1.0.8__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/fuzzydl/__init__.py +2 -1
- fuzzy_dl_owl2/fuzzydl/assertion/assertion.py +1 -0
- fuzzy_dl_owl2/fuzzydl/assertion/atomic_assertion.py +2 -0
- fuzzy_dl_owl2/fuzzydl/classification_node.py +64 -0
- fuzzy_dl_owl2/fuzzydl/concept/__init__.py +2 -0
- fuzzy_dl_owl2/fuzzydl/concept/atomic_concept.py +1 -1
- fuzzy_dl_owl2/fuzzydl/concept/choquet_integral.py +6 -0
- fuzzy_dl_owl2/fuzzydl/concept/concept.py +8 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/crisp_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/fuzzy_number/triangular_fuzzy_number.py +12 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/left_concrete_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/linear_concrete_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/modified_concrete_concept.py +4 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/right_concrete_concept.py +2 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/trapezoidal_concrete_concept.py +1 -0
- fuzzy_dl_owl2/fuzzydl/concept/concrete/triangular_concrete_concept.py +2 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/linearly_modified_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/modified_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/modified/triangularly_modified_concept.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/negated_nominal.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/operator_concept.py +8 -0
- fuzzy_dl_owl2/fuzzydl/concept/qowa_concept.py +4 -0
- fuzzy_dl_owl2/fuzzydl/concept/quasi_sugeno_integral.py +3 -0
- fuzzy_dl_owl2/fuzzydl/concept/sigma_concept.py +71 -0
- fuzzy_dl_owl2/fuzzydl/concept/sigma_count.py +56 -0
- fuzzy_dl_owl2/fuzzydl/concept/sugeno_integral.py +4 -0
- fuzzy_dl_owl2/fuzzydl/concept_equivalence.py +5 -0
- fuzzy_dl_owl2/fuzzydl/concrete_feature.py +6 -0
- fuzzy_dl_owl2/fuzzydl/domain_axiom.py +3 -0
- fuzzy_dl_owl2/fuzzydl/feature_function.py +12 -3
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2.py +3 -1
- fuzzy_dl_owl2/fuzzydl/general_concept_inclusion.py +6 -0
- fuzzy_dl_owl2/fuzzydl/individual/created_individual.py +41 -2
- fuzzy_dl_owl2/fuzzydl/individual/individual.py +14 -0
- fuzzy_dl_owl2/fuzzydl/individual/representative_individual.py +9 -0
- fuzzy_dl_owl2/fuzzydl/knowledge_base.py +2046 -250
- fuzzy_dl_owl2/fuzzydl/label.py +18 -10
- fuzzy_dl_owl2/fuzzydl/milp/expression.py +45 -24
- fuzzy_dl_owl2/fuzzydl/milp/inequation.py +20 -0
- fuzzy_dl_owl2/fuzzydl/milp/milp_helper.py +1398 -60
- fuzzy_dl_owl2/fuzzydl/milp/show_variables_helper.py +82 -0
- fuzzy_dl_owl2/fuzzydl/milp/solution.py +23 -0
- fuzzy_dl_owl2/fuzzydl/milp/term.py +4 -1
- fuzzy_dl_owl2/fuzzydl/milp/variable.py +7 -0
- fuzzy_dl_owl2/fuzzydl/modifier/linear_modifier.py +3 -0
- fuzzy_dl_owl2/fuzzydl/modifier/modifier.py +21 -0
- fuzzy_dl_owl2/fuzzydl/parser/dl_parser.py +48 -7
- fuzzy_dl_owl2/fuzzydl/primitive_concept_definition.py +7 -0
- fuzzy_dl_owl2/fuzzydl/query/__init__.py +1 -0
- fuzzy_dl_owl2/fuzzydl/query/all_instances_query.py +80 -1
- fuzzy_dl_owl2/fuzzydl/query/bnp_query.py +2 -0
- fuzzy_dl_owl2/fuzzydl/query/classification_query.py +26 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/defuzzify_query.py +2 -1
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/lom_defuzzify_query.py +4 -0
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/mom_defuzzify_query.py +6 -2
- fuzzy_dl_owl2/fuzzydl/query/defuzzify/som_defuzzify_query.py +2 -0
- fuzzy_dl_owl2/fuzzydl/query/instance_query.py +5 -0
- fuzzy_dl_owl2/fuzzydl/query/kb_satisfiable_query.py +12 -2
- fuzzy_dl_owl2/fuzzydl/query/max/max_instance_query.py +6 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_query.py +7 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_related_query.py +6 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_satisfiable_query.py +15 -1
- fuzzy_dl_owl2/fuzzydl/query/max/max_subsumes_query.py +4 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_instance_query.py +6 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_query.py +7 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_related_query.py +5 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_satisfiable_query.py +17 -1
- fuzzy_dl_owl2/fuzzydl/query/min/min_subsumes_query.py +47 -7
- fuzzy_dl_owl2/fuzzydl/query/query.py +5 -2
- fuzzy_dl_owl2/fuzzydl/query/related_query.py +8 -1
- fuzzy_dl_owl2/fuzzydl/query/satisfiable_query.py +17 -0
- fuzzy_dl_owl2/fuzzydl/query/subsumption_query.py +5 -0
- fuzzy_dl_owl2/fuzzydl/range_axiom.py +4 -0
- fuzzy_dl_owl2/fuzzydl/relation.py +5 -0
- fuzzy_dl_owl2/fuzzydl/restriction/has_value_restriction.py +2 -0
- fuzzy_dl_owl2/fuzzydl/restriction/restriction.py +3 -0
- fuzzy_dl_owl2/fuzzydl/role_parent_with_degree.py +6 -1
- fuzzy_dl_owl2/fuzzydl/util/config_reader.py +34 -2
- fuzzy_dl_owl2/fuzzydl/util/constants.py +105 -6
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2.py +3 -1
- fuzzy_dl_owl2-1.0.8.dist-info/METADATA +817 -0
- {fuzzy_dl_owl2-1.0.6.dist-info → fuzzy_dl_owl2-1.0.8.dist-info}/RECORD +85 -81
- fuzzy_dl_owl2-1.0.6.dist-info/METADATA +0 -340
- {fuzzy_dl_owl2-1.0.6.dist-info → fuzzy_dl_owl2-1.0.8.dist-info}/LICENSE +0 -0
- {fuzzy_dl_owl2-1.0.6.dist-info → fuzzy_dl_owl2-1.0.8.dist-info}/WHEEL +0 -0
|
@@ -8,6 +8,8 @@ from fuzzy_dl_owl2.fuzzydl.util.constants import LogicOperatorType
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class GeneralConceptInclusion:
|
|
11
|
+
"""General concept inclusion axiom."""
|
|
12
|
+
|
|
11
13
|
def __init__(
|
|
12
14
|
self,
|
|
13
15
|
subsumer: Concept,
|
|
@@ -15,9 +17,13 @@ class GeneralConceptInclusion:
|
|
|
15
17
|
degree: Degree,
|
|
16
18
|
type_: LogicOperatorType,
|
|
17
19
|
):
|
|
20
|
+
# Subsumer concept
|
|
18
21
|
self.subsumer: Concept = subsumer
|
|
22
|
+
# Subsumed concept
|
|
19
23
|
self.subsumed: Concept = subsumed
|
|
24
|
+
# Lower bound degree
|
|
20
25
|
self.degree: Degree = degree
|
|
26
|
+
# Type (depends on the fuzzy implication)
|
|
21
27
|
self.type: LogicOperatorType = type_
|
|
22
28
|
|
|
23
29
|
def clone(self) -> typing.Self:
|
|
@@ -57,27 +57,41 @@ class CreatedIndividual(Individual):
|
|
|
57
57
|
) -> None:
|
|
58
58
|
super().__init__(name)
|
|
59
59
|
|
|
60
|
+
# Array of representative individuals
|
|
60
61
|
self.representatives: list[RepresentativeIndividual] = list()
|
|
61
62
|
|
|
63
|
+
# List of concept labels
|
|
62
64
|
self.concept_list: set[int] = set()
|
|
65
|
+
|
|
66
|
+
# Indicates if the individual is directly blocked or not
|
|
63
67
|
self.directly_blocked: CreatedIndividualBlockingType = (
|
|
64
68
|
CreatedIndividualBlockingType.UNCHECKED
|
|
65
69
|
)
|
|
70
|
+
|
|
71
|
+
# Indicates if the individual is indirectly blocked or not
|
|
66
72
|
self.indirectly_blocked: CreatedIndividualBlockingType = (
|
|
67
73
|
CreatedIndividualBlockingType.UNCHECKED
|
|
68
74
|
)
|
|
75
|
+
|
|
69
76
|
self.not_self_roles: set[str] = set()
|
|
77
|
+
# Parent of the individual
|
|
70
78
|
self.parent: typing.Optional[Individual] = parent
|
|
79
|
+
# Name of the role for which the individual is a filler
|
|
71
80
|
self.role_name: str = role_name
|
|
81
|
+
|
|
82
|
+
# Depth of the individual in the completion forest
|
|
72
83
|
self.depth: int = (
|
|
73
84
|
typing.cast(CreatedIndividual, parent).depth + 1
|
|
74
85
|
if parent is not None and parent.is_blockable()
|
|
75
86
|
else 2
|
|
76
87
|
)
|
|
77
88
|
|
|
89
|
+
# Name of the blocking ancestors
|
|
78
90
|
self.blocking_ancestor: typing.Optional[str] = None
|
|
79
91
|
self.blocking_ancestor_y: typing.Optional[str] = None
|
|
80
92
|
self.blocking_ancestor_y_prime: typing.Optional[str] = None
|
|
93
|
+
|
|
94
|
+
# Indicates if the individual is concrete or not (abstract)
|
|
81
95
|
self._is_concrete: bool = False
|
|
82
96
|
|
|
83
97
|
if parent is not None:
|
|
@@ -118,7 +132,8 @@ class CreatedIndividual(Individual):
|
|
|
118
132
|
ind.role_name = self.role_name
|
|
119
133
|
|
|
120
134
|
def get_integer_id(self) -> int:
|
|
121
|
-
|
|
135
|
+
prefix_len: int = len(Individual.DEFAULT_NAME)
|
|
136
|
+
return int(self.name[prefix_len:])
|
|
122
137
|
|
|
123
138
|
def get_depth(self) -> int:
|
|
124
139
|
return self.depth
|
|
@@ -138,6 +153,19 @@ class CreatedIndividual(Individual):
|
|
|
138
153
|
f_name: str,
|
|
139
154
|
f: TriangularFuzzyNumber,
|
|
140
155
|
) -> typing.Optional[typing.Self]:
|
|
156
|
+
"""
|
|
157
|
+
Return b individual p with b representative of b set of individuals if it exists. Given b fuzzy number F, b representative individual is the set of individuals that are greater or equal (or less or equal) than F.
|
|
158
|
+
The representative individual is related to p via b concrete feature f.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
type (InequalityType): Type of the representative individual (GREATER_EQUAL, LESS_EQUAL)
|
|
162
|
+
f_name (str): Name of the feature for which the individual is b filler
|
|
163
|
+
f (TriangularFuzzyNumber): Fuzzy number
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
typing.Optional[typing.Self]: A new individual with b representative individual
|
|
167
|
+
"""
|
|
168
|
+
# Retrieve representative individual, if it exists
|
|
141
169
|
for ind in self.representatives:
|
|
142
170
|
if (
|
|
143
171
|
ind.get_type() != type
|
|
@@ -146,9 +174,13 @@ class CreatedIndividual(Individual):
|
|
|
146
174
|
):
|
|
147
175
|
continue
|
|
148
176
|
return ind.get_individual()
|
|
177
|
+
# // Otherwise, None
|
|
149
178
|
return None
|
|
150
179
|
|
|
151
180
|
def mark_indirectly_blocked(self) -> None:
|
|
181
|
+
"""
|
|
182
|
+
Marks the subtree of a node as indirectly blocked
|
|
183
|
+
"""
|
|
152
184
|
Util.debug(
|
|
153
185
|
f"{constants.SEPARATOR}Mark subtree of {self.name} indirectly blocked"
|
|
154
186
|
)
|
|
@@ -156,6 +188,7 @@ class CreatedIndividual(Individual):
|
|
|
156
188
|
queue.append(self)
|
|
157
189
|
while len(queue) > 0:
|
|
158
190
|
ind: CreatedIndividual = queue.popleft()
|
|
191
|
+
# If there are no descendants, skip
|
|
159
192
|
if len(ind.role_relations) == 0:
|
|
160
193
|
break
|
|
161
194
|
for role in ind.role_relations:
|
|
@@ -165,7 +198,7 @@ class CreatedIndividual(Individual):
|
|
|
165
198
|
f"{rel.get_subject_individual()} has role {rel.get_role_name()} with filler {rel.get_object_individual()}"
|
|
166
199
|
)
|
|
167
200
|
son: Individual = rel.get_object_individual()
|
|
168
|
-
if son != ind.parent:
|
|
201
|
+
if son != ind.parent: # son is not the parent via inverse role
|
|
169
202
|
if not son.is_blockable():
|
|
170
203
|
continue
|
|
171
204
|
son: CreatedIndividual = typing.cast(CreatedIndividual, son)
|
|
@@ -183,9 +216,15 @@ class CreatedIndividual(Individual):
|
|
|
183
216
|
def individual_set_intersection_of(
|
|
184
217
|
self, set1: SortedSet[typing.Self], set2: SortedSet[typing.Self]
|
|
185
218
|
) -> SortedSet[typing.Self]:
|
|
219
|
+
"""
|
|
220
|
+
Gets the intersection of two concept labels.
|
|
221
|
+
"""
|
|
186
222
|
return set1.intersection(set2)
|
|
187
223
|
|
|
188
224
|
def set_concrete_individual(self) -> None:
|
|
225
|
+
"""
|
|
226
|
+
Sets that the individual is concrete.
|
|
227
|
+
"""
|
|
189
228
|
self._is_concrete = True
|
|
190
229
|
|
|
191
230
|
def is_concrete(self) -> bool:
|
|
@@ -18,16 +18,24 @@ from fuzzy_dl_owl2.fuzzydl.util.constants import RepresentativeIndividualType
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class Individual:
|
|
21
|
+
# Default prefix for new individual names
|
|
21
22
|
DEFAULT_NAME: str = "i"
|
|
22
23
|
|
|
23
24
|
def __init__(self, name: str) -> None:
|
|
24
25
|
self.name: str = name
|
|
26
|
+
# Concrete role restrictions
|
|
25
27
|
self.concrete_role_restrictions: dict[str, list[Assertion]] = dict()
|
|
28
|
+
# Fillers to show
|
|
26
29
|
self.fillers_to_show: dict[str, set[str]] = dict()
|
|
30
|
+
# List of concepts such that a concept assertion has been processed
|
|
27
31
|
self.list_of_concepts: set[Concept] = set()
|
|
32
|
+
# Indicates if the individual is indirectly blocked or not
|
|
28
33
|
self.nominal_list: set[str] = set()
|
|
34
|
+
# List of roles for which to apply the not self rule
|
|
29
35
|
self.not_self_roles: set[str] = list()
|
|
36
|
+
# Role relations
|
|
30
37
|
self.role_relations: dict[str, list[Relation]] = dict()
|
|
38
|
+
# Role restrictions
|
|
31
39
|
self.role_restrictions: dict[str, list[Restriction]] = dict()
|
|
32
40
|
|
|
33
41
|
def clone(self) -> typing.Self:
|
|
@@ -55,6 +63,9 @@ class Individual:
|
|
|
55
63
|
self.name = name
|
|
56
64
|
|
|
57
65
|
def add_concrete_restriction(self, f_name: str, ass: Assertion) -> None:
|
|
66
|
+
"""
|
|
67
|
+
Adds a negated datatype restriction to the individual.
|
|
68
|
+
"""
|
|
58
69
|
self.concrete_role_restrictions[f_name] = self.concrete_role_restrictions.get(
|
|
59
70
|
f_name, []
|
|
60
71
|
) + [ass]
|
|
@@ -91,12 +102,15 @@ class Individual:
|
|
|
91
102
|
def prune(self) -> None:
|
|
92
103
|
to_prune: list[Individual] = []
|
|
93
104
|
for role in self.role_relations:
|
|
105
|
+
# We remove all relations
|
|
94
106
|
rels: list[Relation] = self.role_relations.get(role, [])
|
|
95
107
|
for r in rels:
|
|
96
108
|
obj: Individual = r.get_object_individual()
|
|
97
109
|
if obj.is_blockable():
|
|
98
110
|
to_prune.append(obj)
|
|
111
|
+
# We remove all relations
|
|
99
112
|
self.role_relations = dict()
|
|
113
|
+
# Prune blockable successors
|
|
100
114
|
for i in to_prune:
|
|
101
115
|
i.prune()
|
|
102
116
|
|
|
@@ -12,6 +12,11 @@ if typing.TYPE_CHECKING:
|
|
|
12
12
|
|
|
13
13
|
class RepresentativeIndividual:
|
|
14
14
|
|
|
15
|
+
"""
|
|
16
|
+
New concrete individual being a representative of a set of individuals.
|
|
17
|
+
Given an individual p and a fuzzy number F, a representative individual is the set of individuals that are greater or equal (or less or equal) than F. Then, p is related to the representative individual in some way.
|
|
18
|
+
"""
|
|
19
|
+
|
|
15
20
|
def __init__(
|
|
16
21
|
self,
|
|
17
22
|
c_type: RepresentativeIndividualType,
|
|
@@ -19,9 +24,13 @@ class RepresentativeIndividual:
|
|
|
19
24
|
f: TriangularFuzzyNumber,
|
|
20
25
|
ind: CreatedIndividual,
|
|
21
26
|
) -> None:
|
|
27
|
+
# Name of the feature for which the individual is a filler.
|
|
22
28
|
self.f_name: str = f_name
|
|
29
|
+
# Type of the individual
|
|
23
30
|
self.type: RepresentativeIndividualType = c_type
|
|
31
|
+
# Fuzzy number
|
|
24
32
|
self.f: TriangularFuzzyNumber = f
|
|
33
|
+
# Reference individual
|
|
25
34
|
self.ind: CreatedIndividual = ind
|
|
26
35
|
|
|
27
36
|
def get_type(self) -> RepresentativeIndividualType:
|