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,956 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import string
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from fuzzy_dl_owl2.fuzzydl.util.constants import FuzzyDLKeyword
|
|
7
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
8
|
+
from fuzzy_dl_owl2.fuzzyowl2.fuzzyowl2_java import FuzzyOwl2
|
|
9
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.choquet_concept import ChoquetConcept
|
|
10
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.fuzzy_nominal_concept import FuzzyNominalConcept
|
|
11
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.left_shoulder_function import (
|
|
12
|
+
LeftShoulderFunction,
|
|
13
|
+
)
|
|
14
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.linear_function import LinearFunction
|
|
15
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.linear_modifier import LinearModifier
|
|
16
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.modified_concept import ModifiedConcept
|
|
17
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.modified_function import ModifiedFunction
|
|
18
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.modified_property import ModifiedProperty
|
|
19
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.owa_concept import OwaConcept
|
|
20
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.qowa_concept import QowaConcept
|
|
21
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.quasi_sugeno_concept import QsugenoConcept
|
|
22
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.right_shoulder_function import (
|
|
23
|
+
RightShoulderFunction,
|
|
24
|
+
)
|
|
25
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.sugeno_concept import SugenoConcept
|
|
26
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.trapezoidal_function import TrapezoidalFunction
|
|
27
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.triangular_function import TriangularFunction
|
|
28
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.triangular_modifer import TriangularModifier
|
|
29
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_concept import WeightedConcept
|
|
30
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_max_concept import WeightedMaxConcept
|
|
31
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_min_concept import WeightedMinConcept
|
|
32
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_sum_concept import WeightedSumConcept
|
|
33
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_sum_zero_concept import (
|
|
34
|
+
WeightedSumZeroConcept,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
from org.semanticweb.owlapi.model import (
|
|
39
|
+
ClassExpressionType,
|
|
40
|
+
DataRangeType,
|
|
41
|
+
OWLClass,
|
|
42
|
+
OWLClassExpression,
|
|
43
|
+
OWLDataIntersectionOf,
|
|
44
|
+
OWLDataOneOf,
|
|
45
|
+
OWLDataProperty,
|
|
46
|
+
OWLDataPropertyExpression,
|
|
47
|
+
OWLDataRange,
|
|
48
|
+
OWLDatatype,
|
|
49
|
+
OWLEntity,
|
|
50
|
+
OWLFacetRestriction,
|
|
51
|
+
OWLIndividual,
|
|
52
|
+
OWLLiteral,
|
|
53
|
+
OWLObjectProperty,
|
|
54
|
+
OWLObjectPropertyExpression,
|
|
55
|
+
)
|
|
56
|
+
from org.semanticweb.owlapi.vocab import OWLFacet
|
|
57
|
+
except:
|
|
58
|
+
pass
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class FuzzyOwl2ToFuzzyDL(FuzzyOwl2):
|
|
62
|
+
EPSILON: float = 0.001
|
|
63
|
+
|
|
64
|
+
INTEGER_MAX_VALUE: int = 100000000 # 0x7FFFFFFF
|
|
65
|
+
INTEGER_MIN_VALUE: int = -INTEGER_MAX_VALUE
|
|
66
|
+
DOUBLE_MAX_VALUE: float = 1000 * float(INTEGER_MAX_VALUE)
|
|
67
|
+
DOUBLE_MIN_VALUE: float = -DOUBLE_MAX_VALUE
|
|
68
|
+
|
|
69
|
+
def __init__(
|
|
70
|
+
self,
|
|
71
|
+
input_file: str,
|
|
72
|
+
output_file: str,
|
|
73
|
+
base_iri: str = "http://www.semanticweb.org/ontologies/fuzzydl_ontology.owl",
|
|
74
|
+
) -> None:
|
|
75
|
+
super().__init__(input_file, output_file, base_iri)
|
|
76
|
+
|
|
77
|
+
if os.path.exists(self.output_dl):
|
|
78
|
+
os.remove(self.output_dl)
|
|
79
|
+
|
|
80
|
+
self.boolean_datatypes: set[str] = set()
|
|
81
|
+
self.numerical_datatypes: set[str] = set()
|
|
82
|
+
self.string_datatypes: set[str] = set()
|
|
83
|
+
self.data_properties: set[str] = set()
|
|
84
|
+
self.object_properties: set[str] = set()
|
|
85
|
+
self.processed_functional_data_properties: set[str] = set()
|
|
86
|
+
self.processed_functional_object_properties: set[str] = set()
|
|
87
|
+
|
|
88
|
+
@staticmethod
|
|
89
|
+
def is_reserved_word(s: str) -> bool:
|
|
90
|
+
if s in (
|
|
91
|
+
FuzzyDLKeyword.LINEAR,
|
|
92
|
+
FuzzyDLKeyword.TRIANGULAR,
|
|
93
|
+
FuzzyDLKeyword.CRISP,
|
|
94
|
+
FuzzyDLKeyword.TRAPEZOIDAL,
|
|
95
|
+
FuzzyDLKeyword.CLASSICAL,
|
|
96
|
+
FuzzyDLKeyword.DISJOINT,
|
|
97
|
+
FuzzyDLKeyword.DISJOINT,
|
|
98
|
+
FuzzyDLKeyword.INSTANCE,
|
|
99
|
+
FuzzyDLKeyword.RELATED,
|
|
100
|
+
FuzzyDLKeyword.DOMAIN,
|
|
101
|
+
FuzzyDLKeyword.RANGE,
|
|
102
|
+
):
|
|
103
|
+
return True
|
|
104
|
+
# avoid numbers
|
|
105
|
+
try:
|
|
106
|
+
_ = float(s)
|
|
107
|
+
return True
|
|
108
|
+
except:
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
def __write(self, line: str) -> None:
|
|
112
|
+
with open(self.output_dl, "a") as file:
|
|
113
|
+
file.write(f"{line}\n")
|
|
114
|
+
|
|
115
|
+
def get_short_name(self, s: typing.Union[OWLEntity, str]):
|
|
116
|
+
if isinstance(s, OWLEntity):
|
|
117
|
+
# s = str(self.pm.getShortForm(s))
|
|
118
|
+
s = str(s.toString().replaceAll("\\<", "").replaceAll("\\>", "")).replace(
|
|
119
|
+
f"{self.ontology_path}#", ""
|
|
120
|
+
)
|
|
121
|
+
s = s.replace(r"\\(", "")
|
|
122
|
+
s = s.replace(r"\\)", "")
|
|
123
|
+
if FuzzyOwl2ToFuzzyDL.is_reserved_word(s):
|
|
124
|
+
return f"_{s}"
|
|
125
|
+
else:
|
|
126
|
+
return s
|
|
127
|
+
|
|
128
|
+
def __get_facets(self, name: str) -> list[float]:
|
|
129
|
+
facets: list[float] = [
|
|
130
|
+
FuzzyOwl2ToFuzzyDL.INTEGER_MIN_VALUE,
|
|
131
|
+
FuzzyOwl2ToFuzzyDL.INTEGER_MAX_VALUE,
|
|
132
|
+
]
|
|
133
|
+
if name == "xsd:nonPositiveInteger":
|
|
134
|
+
facets[1] = 0
|
|
135
|
+
elif name == "xsd:NegativeInteger":
|
|
136
|
+
facets[1] = -1
|
|
137
|
+
elif name == "xsd:nonNegativeInteger":
|
|
138
|
+
facets[0] = 0
|
|
139
|
+
elif name == "xsd:positiveInteger":
|
|
140
|
+
facets[0] = 1
|
|
141
|
+
return facets
|
|
142
|
+
|
|
143
|
+
def __is_real_datatype(self, d: typing.Union[OWLDatatype, OWLLiteral]) -> bool:
|
|
144
|
+
if d.isDouble() or d.isFloat():
|
|
145
|
+
return True
|
|
146
|
+
name: str = str(d.toString())
|
|
147
|
+
return "owl:real" in name or "owl:rational" in name or "xsd:decimal" in name
|
|
148
|
+
|
|
149
|
+
def __is_integer_datatype(self, d: typing.Union[OWLDatatype, OWLLiteral]) -> bool:
|
|
150
|
+
if d.isInteger():
|
|
151
|
+
return True
|
|
152
|
+
name: str = str(d.toString())
|
|
153
|
+
return (
|
|
154
|
+
name == "xsd:integer"
|
|
155
|
+
or name == "xsd:nonNegativeInteger"
|
|
156
|
+
or name == "xsd:nonPositiveInteger"
|
|
157
|
+
or name == "xsd:positiveInteger"
|
|
158
|
+
or name == "xsd:negativeInteger"
|
|
159
|
+
or name == "xsd:long"
|
|
160
|
+
or name == "xsd:int"
|
|
161
|
+
or name == "xsd:short"
|
|
162
|
+
or name == "xsd:byte"
|
|
163
|
+
or name == "xsd:unsignedLong"
|
|
164
|
+
or name == "xsd:unsignedInt"
|
|
165
|
+
or name == "xsd:unsignedShort"
|
|
166
|
+
or name == "xsd:unsignedByte"
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
def get_individual_name(self, i: OWLIndividual) -> str:
|
|
170
|
+
if i.isAnonymous():
|
|
171
|
+
return str(i.toString())
|
|
172
|
+
else:
|
|
173
|
+
return self.get_short_name(i.asOWLNamedIndividual())
|
|
174
|
+
|
|
175
|
+
def get_top_concept_name(self) -> str:
|
|
176
|
+
return "*top*"
|
|
177
|
+
|
|
178
|
+
def get_bottom_concept_name(self) -> str:
|
|
179
|
+
return "*bottom*"
|
|
180
|
+
|
|
181
|
+
def get_atomic_concept_name(self, c: OWLClass) -> str:
|
|
182
|
+
return self.get_short_name(c)
|
|
183
|
+
|
|
184
|
+
def get_object_intersection_of_name(self, operands: set[OWLClassExpression]) -> str:
|
|
185
|
+
if len(operands) == 1:
|
|
186
|
+
return self.get_class_name(operands.pop())
|
|
187
|
+
return f"(and {' '.join([self.get_class_name(c) for c in operands])})"
|
|
188
|
+
|
|
189
|
+
def get_object_union_of_name(self, operands: set[OWLClassExpression]) -> str:
|
|
190
|
+
if len(operands) == 1:
|
|
191
|
+
return self.get_class_name(operands.pop())
|
|
192
|
+
return f"(or {' '.join([self.get_class_name(c) for c in operands])})"
|
|
193
|
+
|
|
194
|
+
def get_object_some_values_from_name(
|
|
195
|
+
self, p: OWLObjectPropertyExpression, c: OWLClassExpression
|
|
196
|
+
) -> str:
|
|
197
|
+
return f"(some {self.get_object_property_name(p)} {self.get_class_name(c)})"
|
|
198
|
+
|
|
199
|
+
def get_object_all_values_from_name(
|
|
200
|
+
self, p: OWLObjectPropertyExpression, c: OWLClassExpression
|
|
201
|
+
) -> str:
|
|
202
|
+
return f"(all {self.get_object_property_name(p)} {self.get_class_name(c)})"
|
|
203
|
+
|
|
204
|
+
def get_data_some_values_from_name(
|
|
205
|
+
self, p: OWLDataPropertyExpression, range: OWLDataRange
|
|
206
|
+
) -> str:
|
|
207
|
+
type: DataRangeType = range.getDataRangeType()
|
|
208
|
+
if type == DataRangeType.DATATYPE:
|
|
209
|
+
datatype_name: str = self.get_short_name(range.asOWLDatatype())
|
|
210
|
+
if datatype_name in self.fuzzy_datatypes:
|
|
211
|
+
return f"(some {self.get_data_property_name(p)} {datatype_name})"
|
|
212
|
+
else:
|
|
213
|
+
d: OWLDatatype = range.asOWLDatatype()
|
|
214
|
+
dp_name: str = self.get_data_property_name(p)
|
|
215
|
+
if self.__is_real_datatype(d) or self.__is_integer_datatype(d):
|
|
216
|
+
if dp_name not in self.numerical_datatypes:
|
|
217
|
+
self.numerical_datatypes.add(dp_name)
|
|
218
|
+
if self.__is_real_datatype(d):
|
|
219
|
+
self.__write(
|
|
220
|
+
f"(range {dp_name} *real* {FuzzyOwl2ToFuzzyDL.DOUBLE_MIN_VALUE} {FuzzyOwl2ToFuzzyDL.DOUBLE_MAX_VALUE})"
|
|
221
|
+
)
|
|
222
|
+
else:
|
|
223
|
+
facets: list[float] = self.__get_facets(str(d.toString()))
|
|
224
|
+
self.__write(
|
|
225
|
+
f"(range {dp_name} *integer* {facets[0]} {facets[1]})"
|
|
226
|
+
)
|
|
227
|
+
if self.__is_real_datatype(d):
|
|
228
|
+
return f"(>= {dp_name} {FuzzyOwl2ToFuzzyDL.DOUBLE_MIN_VALUE})"
|
|
229
|
+
else:
|
|
230
|
+
return f"(>= {dp_name} {FuzzyOwl2ToFuzzyDL.INTEGER_MIN_VALUE})"
|
|
231
|
+
elif d.isBoolean():
|
|
232
|
+
return f"(= {self.get_data_property_name(p)} {d})"
|
|
233
|
+
elif type == DataRangeType.DATA_ONE_OF:
|
|
234
|
+
o: OWLDataOneOf = typing.cast(OWLDataOneOf, range)
|
|
235
|
+
literat_set: set[OWLLiteral] = o.getValues()
|
|
236
|
+
if len(literat_set) > 0:
|
|
237
|
+
return f"(= {self.get_data_property_name(p)} {list(literat_set)[0].getLiteral()})"
|
|
238
|
+
Util.error(
|
|
239
|
+
f"Data some values restriction with range {range} and type {type} not supported -- DataSomeValuesFrom({p} {range})"
|
|
240
|
+
)
|
|
241
|
+
return None
|
|
242
|
+
|
|
243
|
+
def get_data_all_values_from_name(
|
|
244
|
+
self, p: OWLDataPropertyExpression, range: OWLDataRange
|
|
245
|
+
) -> str:
|
|
246
|
+
type: DataRangeType = range.getDataRangeType()
|
|
247
|
+
if type == DataRangeType.DATATYPE:
|
|
248
|
+
datatype_name: str = self.get_short_name(range.asOWLDatatype())
|
|
249
|
+
if datatype_name in self.fuzzy_datatypes:
|
|
250
|
+
return f"(all {self.get_data_property_name(p)} {datatype_name})"
|
|
251
|
+
Util.error(
|
|
252
|
+
f"Data all values restriction with range {range} and type {type} not supported -- DataAllValuesFrom({p} {range})"
|
|
253
|
+
)
|
|
254
|
+
return None
|
|
255
|
+
|
|
256
|
+
def get_object_complement_of_name(self, c: OWLClassExpression) -> str:
|
|
257
|
+
return f"(not {self.get_class_name(c)})"
|
|
258
|
+
|
|
259
|
+
def get_object_has_self_name(self, p: OWLObjectPropertyExpression) -> str:
|
|
260
|
+
return f"(self {self.get_object_property_name(p)})"
|
|
261
|
+
|
|
262
|
+
def __get_set_name(self, curr_set: set) -> str:
|
|
263
|
+
return str(
|
|
264
|
+
curr_set.toString()
|
|
265
|
+
.replaceAll("\\[", "")
|
|
266
|
+
.replaceAll("\\]", "")
|
|
267
|
+
.replaceAll(", ", " ")
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
def get_object_one_of_name(self, ind_set: set[OWLIndividual]) -> str:
|
|
271
|
+
Util.error(
|
|
272
|
+
f"OneOf concept not supported -- (OneOf {self.__get_set_name(ind_set)})"
|
|
273
|
+
)
|
|
274
|
+
return None
|
|
275
|
+
|
|
276
|
+
def get_object_has_value_name(
|
|
277
|
+
self, p: OWLObjectPropertyExpression, i: OWLIndividual
|
|
278
|
+
) -> str:
|
|
279
|
+
return (
|
|
280
|
+
f"(b-some {self.get_object_property_name(p)} {self.get_individual_name(i)})"
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
def get_data_has_value_name(
|
|
284
|
+
self, p: OWLDataPropertyExpression, literal: OWLLiteral
|
|
285
|
+
) -> str:
|
|
286
|
+
dp_name: str = self.get_data_property_name(p)
|
|
287
|
+
if self.__is_integer_datatype(literal) or self.__is_real_datatype(literal):
|
|
288
|
+
if dp_name not in self.numerical_datatypes:
|
|
289
|
+
self.numerical_datatypes.add(dp_name)
|
|
290
|
+
self.write_functional_data_property_axiom(p)
|
|
291
|
+
if self.__is_real_datatype(literal):
|
|
292
|
+
self.__write(
|
|
293
|
+
f"(range {dp_name} *real* {FuzzyOwl2ToFuzzyDL.DOUBLE_MIN_VALUE} {FuzzyOwl2ToFuzzyDL.DOUBLE_MAX_VALUE})"
|
|
294
|
+
)
|
|
295
|
+
else:
|
|
296
|
+
facets: list[float] = self.__get_facets(str(literal.toString()))
|
|
297
|
+
self.__write(f"(range {dp_name} *integer* {facets[0]} {facets[1]})")
|
|
298
|
+
return f"(= {dp_name} {literal.getLiteral()})"
|
|
299
|
+
elif literal.isBoolean():
|
|
300
|
+
if dp_name not in self.boolean_datatypes:
|
|
301
|
+
self.boolean_datatypes.add(dp_name)
|
|
302
|
+
self.write_functional_data_property_axiom(p)
|
|
303
|
+
self.__write(f"(range {dp_name} *boolean*)")
|
|
304
|
+
return f"(= {dp_name} {literal.getLiteral()})"
|
|
305
|
+
else:
|
|
306
|
+
Util.error(
|
|
307
|
+
f"Data hasValue restriction with literal {literal} not supported -- DataHasValue({p} {literal})"
|
|
308
|
+
)
|
|
309
|
+
return None
|
|
310
|
+
|
|
311
|
+
def get_object_min_cardinality_restriction(
|
|
312
|
+
self,
|
|
313
|
+
cardinality: int,
|
|
314
|
+
p: OWLObjectPropertyExpression,
|
|
315
|
+
c: OWLClassExpression = None,
|
|
316
|
+
) -> str:
|
|
317
|
+
if c is not None:
|
|
318
|
+
Util.error(
|
|
319
|
+
(
|
|
320
|
+
f"Object min cardinality restriction not supported -- ObjectMaxCardinalityRestriction({cardinality} {p} {c})"
|
|
321
|
+
)
|
|
322
|
+
)
|
|
323
|
+
else:
|
|
324
|
+
Util.error(
|
|
325
|
+
(
|
|
326
|
+
f"Object min cardinality restriction not supported -- ObjectMaxCardinalityRestriction({cardinality} {p})"
|
|
327
|
+
)
|
|
328
|
+
)
|
|
329
|
+
return None
|
|
330
|
+
|
|
331
|
+
def get_object_max_cardinality_restriction(
|
|
332
|
+
self,
|
|
333
|
+
cardinality: int,
|
|
334
|
+
p: OWLObjectPropertyExpression,
|
|
335
|
+
c: OWLClassExpression = None,
|
|
336
|
+
) -> str:
|
|
337
|
+
if c is not None:
|
|
338
|
+
Util.error(
|
|
339
|
+
(
|
|
340
|
+
f"Object max cardinality restriction not supported -- ObjectMaxCardinalityRestriction({cardinality} {p} {c})"
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
else:
|
|
344
|
+
Util.error(
|
|
345
|
+
(
|
|
346
|
+
f"Object max cardinality restriction not supported -- ObjectMaxCardinalityRestriction({cardinality} {p})"
|
|
347
|
+
)
|
|
348
|
+
)
|
|
349
|
+
return None
|
|
350
|
+
|
|
351
|
+
def get_object_exact_cardinality_restriction(
|
|
352
|
+
self,
|
|
353
|
+
cardinality: int,
|
|
354
|
+
p: OWLObjectPropertyExpression,
|
|
355
|
+
c: OWLClassExpression = None,
|
|
356
|
+
) -> str:
|
|
357
|
+
if c is not None:
|
|
358
|
+
Util.error(
|
|
359
|
+
(
|
|
360
|
+
f"Object exact cardinality restriction not supported -- ObjectExactCardinalityRestriction({cardinality} {p} {c})"
|
|
361
|
+
)
|
|
362
|
+
)
|
|
363
|
+
else:
|
|
364
|
+
Util.error(
|
|
365
|
+
(
|
|
366
|
+
f"Object exact cardinality restriction not supported -- ObjectExactCardinalityRestriction({cardinality} {p})"
|
|
367
|
+
)
|
|
368
|
+
)
|
|
369
|
+
return None
|
|
370
|
+
|
|
371
|
+
def get_data_min_cardinality_restriction(
|
|
372
|
+
self, cardinality: int, p: OWLDataPropertyExpression, range: OWLDataRange = None
|
|
373
|
+
) -> str:
|
|
374
|
+
if range is not None:
|
|
375
|
+
Util.error(
|
|
376
|
+
(
|
|
377
|
+
f"Data min cardinality restriction not supported -- DataMinCardinalityRestriction({cardinality} {p} {range})"
|
|
378
|
+
)
|
|
379
|
+
)
|
|
380
|
+
else:
|
|
381
|
+
Util.error(
|
|
382
|
+
(
|
|
383
|
+
f"Data min cardinality restriction not supported -- DataMinCardinalityRestriction({cardinality} {p})"
|
|
384
|
+
)
|
|
385
|
+
)
|
|
386
|
+
return None
|
|
387
|
+
|
|
388
|
+
def get_data_max_cardinality_restriction(
|
|
389
|
+
self, cardinality: int, p: OWLDataPropertyExpression, range: OWLDataRange = None
|
|
390
|
+
) -> str:
|
|
391
|
+
if range is not None:
|
|
392
|
+
Util.error(
|
|
393
|
+
(
|
|
394
|
+
f"Data max cardinality restriction not supported -- DataMaxCardinalityRestriction({cardinality} {p} {range})"
|
|
395
|
+
)
|
|
396
|
+
)
|
|
397
|
+
else:
|
|
398
|
+
Util.error(
|
|
399
|
+
(
|
|
400
|
+
f"Data max cardinality restriction not supported -- DataMaxCardinalityRestriction({cardinality} {p})"
|
|
401
|
+
)
|
|
402
|
+
)
|
|
403
|
+
return None
|
|
404
|
+
|
|
405
|
+
def get_data_exact_cardinality_restriction(
|
|
406
|
+
self, cardinality: int, p: OWLDataPropertyExpression, range: OWLDataRange = None
|
|
407
|
+
) -> str:
|
|
408
|
+
if range is not None:
|
|
409
|
+
Util.error(
|
|
410
|
+
(
|
|
411
|
+
f"Data exact cardinality restriction not supported -- DataExactCardinalityRestriction({cardinality} {p} {range})"
|
|
412
|
+
)
|
|
413
|
+
)
|
|
414
|
+
else:
|
|
415
|
+
Util.error(
|
|
416
|
+
(
|
|
417
|
+
f"Data exact cardinality restriction not supported -- DataExactCardinalityRestriction({cardinality} {p})"
|
|
418
|
+
)
|
|
419
|
+
)
|
|
420
|
+
return None
|
|
421
|
+
|
|
422
|
+
def get_top_object_property_name(self) -> str:
|
|
423
|
+
Util.error("Top object property not supported")
|
|
424
|
+
return None
|
|
425
|
+
|
|
426
|
+
def get_bottom_object_property_name(self) -> str:
|
|
427
|
+
Util.error("Bottom object property not supported")
|
|
428
|
+
return None
|
|
429
|
+
|
|
430
|
+
def get_atomic_object_property_name(self, p: OWLObjectProperty) -> str:
|
|
431
|
+
name: str = self.get_short_name(p)
|
|
432
|
+
if name in self.data_properties:
|
|
433
|
+
name = f"_op@{name}"
|
|
434
|
+
else:
|
|
435
|
+
self.object_properties.add(name)
|
|
436
|
+
return name
|
|
437
|
+
|
|
438
|
+
def get_top_data_property_name(self) -> str:
|
|
439
|
+
Util.error("Top data property not supported")
|
|
440
|
+
return None
|
|
441
|
+
|
|
442
|
+
def get_bottom_data_property_name(self) -> str:
|
|
443
|
+
Util.error("Bottom data property not supported")
|
|
444
|
+
return None
|
|
445
|
+
|
|
446
|
+
def get_atomic_data_property_name(self, p: OWLDataProperty) -> str:
|
|
447
|
+
name: str = self.get_short_name(p)
|
|
448
|
+
if name in self.object_properties:
|
|
449
|
+
name = f"_dp@{name}"
|
|
450
|
+
else:
|
|
451
|
+
self.data_properties.add(name)
|
|
452
|
+
return name
|
|
453
|
+
|
|
454
|
+
def write_fuzzy_logic(self, logic: str) -> None:
|
|
455
|
+
self.__write("(define-fuzzy-logic " + logic + ")")
|
|
456
|
+
|
|
457
|
+
def write_concept_declaration(self, c: OWLClassExpression) -> None:
|
|
458
|
+
self.__write(
|
|
459
|
+
f"(define-primitive-concept {self.get_class_name(c)} {self.get_top_concept_name()})"
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
def write_data_property_declaration(self, dp: OWLDataPropertyExpression) -> None:
|
|
463
|
+
self.write_functional_data_property_axiom(dp)
|
|
464
|
+
self.__write(f"(range {self.get_data_property_name(dp)} *string*)")
|
|
465
|
+
|
|
466
|
+
def write_object_property_declaration(
|
|
467
|
+
self, op: OWLObjectPropertyExpression
|
|
468
|
+
) -> None:
|
|
469
|
+
pass
|
|
470
|
+
|
|
471
|
+
def write_concept_assertion_axiom(
|
|
472
|
+
self, i: OWLIndividual, c: OWLClassExpression, d: float
|
|
473
|
+
) -> None:
|
|
474
|
+
self.__write(
|
|
475
|
+
f"(instance {self.get_individual_name(i)} {self.get_class_name(c)} {d})"
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
def write_object_property_assertion_axiom(
|
|
479
|
+
self,
|
|
480
|
+
i1: OWLIndividual,
|
|
481
|
+
i2: OWLIndividual,
|
|
482
|
+
p: OWLObjectPropertyExpression,
|
|
483
|
+
d: float,
|
|
484
|
+
) -> None:
|
|
485
|
+
self.__write(
|
|
486
|
+
f"(related {self.get_individual_name(i1)} {self.get_individual_name(i2)} {self.get_object_property_name(p)} {d})"
|
|
487
|
+
)
|
|
488
|
+
|
|
489
|
+
def write_data_property_assertion_axiom(
|
|
490
|
+
self,
|
|
491
|
+
i1: OWLIndividual,
|
|
492
|
+
i2: OWLIndividual,
|
|
493
|
+
p: OWLDataPropertyExpression,
|
|
494
|
+
d: float,
|
|
495
|
+
) -> None:
|
|
496
|
+
datatype: OWLDatatype = i2.getDatatype()
|
|
497
|
+
dp_name: str = self.get_data_property_name(p)
|
|
498
|
+
if datatype is None:
|
|
499
|
+
self.__write(
|
|
500
|
+
f"(instance {self.get_individual_name(i1)} (= {dp_name} {i2.getLiteral()}) {d})"
|
|
501
|
+
)
|
|
502
|
+
else:
|
|
503
|
+
datatype_name: str = self.get_short_name(datatype.asOWLDatatype())
|
|
504
|
+
if datatype_name in self.fuzzy_datatypes:
|
|
505
|
+
self.__write(
|
|
506
|
+
f"(instance {self.get_individual_name(i1)} (some {dp_name} {datatype_name}) {d})"
|
|
507
|
+
)
|
|
508
|
+
else:
|
|
509
|
+
if self.__is_real_datatype(i2) or self.__is_integer_datatype(i2):
|
|
510
|
+
if dp_name not in self.numerical_datatypes:
|
|
511
|
+
self.numerical_datatypes.add(dp_name)
|
|
512
|
+
self.write_functional_data_property_axiom(p)
|
|
513
|
+
if self.__is_integer_datatype(i2):
|
|
514
|
+
self.__write(
|
|
515
|
+
f"(range {dp_name} *integer* {FuzzyOwl2ToFuzzyDL.INTEGER_MIN_VALUE} {FuzzyOwl2ToFuzzyDL.INTEGER_MAX_VALUE})"
|
|
516
|
+
)
|
|
517
|
+
else:
|
|
518
|
+
self.__write(
|
|
519
|
+
f"(range {dp_name} *real* {FuzzyOwl2ToFuzzyDL.DOUBLE_MIN_VALUE} {FuzzyOwl2ToFuzzyDL.DOUBLE_MAX_VALUE})"
|
|
520
|
+
)
|
|
521
|
+
value: typing.Any = None
|
|
522
|
+
if self.__is_real_datatype(i2):
|
|
523
|
+
value = float(i2.parseDouble())
|
|
524
|
+
else:
|
|
525
|
+
value = int(i2.parseInteger())
|
|
526
|
+
self.__write(
|
|
527
|
+
f"(instance {self.get_individual_name(i1)} (>= {dp_name} {value}) {d})"
|
|
528
|
+
)
|
|
529
|
+
else:
|
|
530
|
+
if dp_name not in self.string_datatypes:
|
|
531
|
+
self.string_datatypes.add(dp_name)
|
|
532
|
+
self.write_data_property_declaration(p)
|
|
533
|
+
l: str = str(i2.getLiteral())
|
|
534
|
+
l: str = re.sub(r"\s", "_", l)
|
|
535
|
+
l: str = re.sub(r"[\)\(]", "--", l)
|
|
536
|
+
l: str = re.sub(r"\"", "'", l)
|
|
537
|
+
if l[0] in string.digits:
|
|
538
|
+
l = f"_{l}"
|
|
539
|
+
self.__write(
|
|
540
|
+
f"(instance {self.get_individual_name(i1)} (= {dp_name} {l}) {d})"
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
def write_negative_object_property_assertion_axiom(
|
|
544
|
+
self,
|
|
545
|
+
i1: OWLIndividual,
|
|
546
|
+
i2: OWLIndividual,
|
|
547
|
+
p: OWLObjectPropertyExpression,
|
|
548
|
+
d: float,
|
|
549
|
+
) -> None:
|
|
550
|
+
Util.error(
|
|
551
|
+
f"Negative object property assertion not supported -- NegativeObjectPropertyAssertion({p} {i1} {i2} {d})"
|
|
552
|
+
)
|
|
553
|
+
return None
|
|
554
|
+
|
|
555
|
+
def write_negative_data_property_assertion_axiom(
|
|
556
|
+
self,
|
|
557
|
+
i1: OWLIndividual,
|
|
558
|
+
i2: OWLIndividual,
|
|
559
|
+
p: OWLDataPropertyExpression,
|
|
560
|
+
d: float,
|
|
561
|
+
) -> None:
|
|
562
|
+
Util.error(
|
|
563
|
+
f"Negative data property assertion not supported -- NegativeDataPropertyAssertion({p} {i1} {i2} {d})"
|
|
564
|
+
)
|
|
565
|
+
return None
|
|
566
|
+
|
|
567
|
+
def write_same_individual_axiom(self, ind_set: set[OWLIndividual]) -> None:
|
|
568
|
+
Util.error(
|
|
569
|
+
f"Same individual axiom not supported -- NegativeDataPropertyAssertion({self.__get_set_name(ind_set)})"
|
|
570
|
+
)
|
|
571
|
+
return None
|
|
572
|
+
|
|
573
|
+
def write_different_individuals_axiom(self, ind_set: set[OWLIndividual]) -> None:
|
|
574
|
+
Util.error(
|
|
575
|
+
f"Different individual axiom not supported -- DifferentIndividuals({self.__get_set_name(ind_set)})"
|
|
576
|
+
)
|
|
577
|
+
return None
|
|
578
|
+
|
|
579
|
+
def write_disjoint_classes_axiom(self, class_set: set[OWLClassExpression]) -> None:
|
|
580
|
+
if len(class_set) <= 1:
|
|
581
|
+
return
|
|
582
|
+
self.__write(
|
|
583
|
+
f"(disjoint {' '.join(self.get_short_name(c.asOWLClass()) for c in class_set)})"
|
|
584
|
+
)
|
|
585
|
+
|
|
586
|
+
def write_disjoint_union_axiom(self, class_set: set[OWLClassExpression]) -> None:
|
|
587
|
+
if len(class_set) <= 1:
|
|
588
|
+
return
|
|
589
|
+
for c in class_set:
|
|
590
|
+
if c.getClassExpressionType() != ClassExpressionType.OWL_CLASS:
|
|
591
|
+
Util.error("Concept type not supported in disjoint union axiom")
|
|
592
|
+
self.__write(
|
|
593
|
+
f"(disjoint-union {' '.join(self.get_short_name(c.asOWLClass()) for c in class_set)})"
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
def write_subclass_of_axiom(
|
|
597
|
+
self, subclass: OWLClassExpression, superclass: OWLClassExpression, d: float
|
|
598
|
+
) -> None:
|
|
599
|
+
type: ClassExpressionType = subclass.getClassExpressionType()
|
|
600
|
+
if type == ClassExpressionType.OWL_CLASS and d == 1:
|
|
601
|
+
self.__write(
|
|
602
|
+
f"(define-primitive-concept {self.get_short_name(subclass.asOWLClass())} {self.get_class_name(superclass)})"
|
|
603
|
+
)
|
|
604
|
+
else:
|
|
605
|
+
self.__write(
|
|
606
|
+
f"(implies {self.get_class_name(subclass)} {self.get_class_name(superclass)} {d})"
|
|
607
|
+
)
|
|
608
|
+
|
|
609
|
+
def write_equivalent_classes_axiom(
|
|
610
|
+
self, class_set: set[OWLClassExpression]
|
|
611
|
+
) -> None:
|
|
612
|
+
name: str = None
|
|
613
|
+
left_class: OWLClassExpression = None
|
|
614
|
+
for c in class_set:
|
|
615
|
+
if c.getClassExpressionType() == ClassExpressionType.OWL_CLASS:
|
|
616
|
+
name = self.get_short_name(c.asOWLClass())
|
|
617
|
+
left_class = c
|
|
618
|
+
break
|
|
619
|
+
if name is None:
|
|
620
|
+
self.__write(
|
|
621
|
+
f"(equivalent-concepts {' '.join(self.get_class_name(c) for c in class_set)})"
|
|
622
|
+
)
|
|
623
|
+
else:
|
|
624
|
+
for c in class_set:
|
|
625
|
+
if c != left_class:
|
|
626
|
+
self.__write(f"(define-concept {name} {self.get_class_name(c)})")
|
|
627
|
+
|
|
628
|
+
def write_sub_object_property_of_axiom(
|
|
629
|
+
self,
|
|
630
|
+
subproperty: OWLObjectPropertyExpression,
|
|
631
|
+
superproperty: OWLObjectPropertyExpression,
|
|
632
|
+
d: float,
|
|
633
|
+
) -> None:
|
|
634
|
+
self.__write(
|
|
635
|
+
f"(implies-role {self.get_object_property_name(subproperty)} {self.get_object_property_name(superproperty)} {d})"
|
|
636
|
+
)
|
|
637
|
+
|
|
638
|
+
def write_sub_data_property_of_axiom(
|
|
639
|
+
self,
|
|
640
|
+
subproperty: OWLDataPropertyExpression,
|
|
641
|
+
superproperty: OWLDataPropertyExpression,
|
|
642
|
+
d: float,
|
|
643
|
+
) -> None:
|
|
644
|
+
self.__write(
|
|
645
|
+
f"(implies-role {self.get_object_property_name(subproperty)} {self.get_object_property_name(superproperty)} {d})"
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
def write_sub_property_chain_of_axiom(
|
|
649
|
+
self,
|
|
650
|
+
chain: list[OWLObjectPropertyExpression],
|
|
651
|
+
superproperty: OWLObjectPropertyExpression,
|
|
652
|
+
d: float,
|
|
653
|
+
) -> None:
|
|
654
|
+
Util.error(
|
|
655
|
+
f"Subproperty chain axiom not supported -- SubObjectPropertyOf(ObjectPropertyChain({self.__get_set_name(chain)}) {superproperty} {d})"
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
def write_equivalent_object_properties_axiom(
|
|
659
|
+
self, class_set: set[OWLObjectPropertyExpression]
|
|
660
|
+
) -> None:
|
|
661
|
+
first: OWLObjectPropertyExpression = next(class_set)
|
|
662
|
+
first_name: str = self.get_object_property_name(first)
|
|
663
|
+
for property in class_set - set([first]):
|
|
664
|
+
property_name: str = self.get_object_property_name(property)
|
|
665
|
+
self.__write(f"(implies-role {first_name} {property_name})")
|
|
666
|
+
self.__write(f"(implies-role {property_name} {first_name})")
|
|
667
|
+
|
|
668
|
+
def write_equivalent_data_properties_axiom(
|
|
669
|
+
self, class_set: set[OWLDataPropertyExpression]
|
|
670
|
+
) -> None:
|
|
671
|
+
first: OWLDataPropertyExpression = next(class_set)
|
|
672
|
+
first_name: str = self.get_object_property_name(first)
|
|
673
|
+
for property in class_set - set([first]):
|
|
674
|
+
property_name: str = self.get_object_property_name(property)
|
|
675
|
+
self.__write(f"(implies-role {first_name} {property_name})")
|
|
676
|
+
self.__write(f"(implies-role {property_name} {first_name})")
|
|
677
|
+
|
|
678
|
+
def write_transitive_object_property_axiom(
|
|
679
|
+
self, p: OWLObjectPropertyExpression
|
|
680
|
+
) -> None:
|
|
681
|
+
self.__write(f"(transitive {self.get_object_property_name(p)})")
|
|
682
|
+
|
|
683
|
+
def write_symmetric_object_property_axiom(
|
|
684
|
+
self, p: OWLObjectPropertyExpression
|
|
685
|
+
) -> None:
|
|
686
|
+
self.__write(f"(symmetric {self.get_object_property_name(p)})")
|
|
687
|
+
|
|
688
|
+
def write_asymmetric_object_property_axiom(
|
|
689
|
+
self, p: OWLObjectPropertyExpression
|
|
690
|
+
) -> None:
|
|
691
|
+
Util.error(
|
|
692
|
+
f"Asymmetric object property axiom not supported -- AsymmetricObjectProperty({p})"
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
def write_reflexive_object_property_axiom(
|
|
696
|
+
self, p: OWLObjectPropertyExpression
|
|
697
|
+
) -> None:
|
|
698
|
+
self.__write(f"(reflexive {self.get_object_property_name(p)})")
|
|
699
|
+
|
|
700
|
+
def write_irreflexive_object_property_axiom(
|
|
701
|
+
self, p: OWLObjectPropertyExpression
|
|
702
|
+
) -> None:
|
|
703
|
+
Util.error(
|
|
704
|
+
f"Irreflexive object property axiom not supported -- IrreflexiveObjectProperty({p})"
|
|
705
|
+
)
|
|
706
|
+
|
|
707
|
+
def write_functional_object_property_axiom(
|
|
708
|
+
self, p: OWLObjectPropertyExpression
|
|
709
|
+
) -> None:
|
|
710
|
+
name: str = self.get_object_property_name(p)
|
|
711
|
+
if name not in self.processed_functional_object_properties:
|
|
712
|
+
self.processed_functional_object_properties.add(name)
|
|
713
|
+
self.__write(f"(functional {name})")
|
|
714
|
+
|
|
715
|
+
def write_functional_data_property_axiom(
|
|
716
|
+
self, p: OWLObjectPropertyExpression
|
|
717
|
+
) -> None:
|
|
718
|
+
name: str = self.get_data_property_name(p)
|
|
719
|
+
if name not in self.processed_functional_data_properties:
|
|
720
|
+
self.processed_functional_data_properties.add(name)
|
|
721
|
+
self.__write(f"(functional {name})")
|
|
722
|
+
|
|
723
|
+
def write_inverse_object_property_axiom(
|
|
724
|
+
self, p1: OWLObjectPropertyExpression, p2: OWLObjectPropertyExpression
|
|
725
|
+
) -> None:
|
|
726
|
+
self.__write(
|
|
727
|
+
f"(inverse {self.get_object_property_name(p1)} {self.get_object_property_name(p2)})"
|
|
728
|
+
)
|
|
729
|
+
|
|
730
|
+
def write_inverse_functional_object_property_axiom(
|
|
731
|
+
self, p: OWLObjectPropertyExpression
|
|
732
|
+
) -> None:
|
|
733
|
+
self.__write(f"(inverse-functional {self.get_object_property_name(p)})")
|
|
734
|
+
|
|
735
|
+
def write_object_property_domain_axiom(
|
|
736
|
+
self, p: OWLObjectPropertyExpression, c: OWLClassExpression
|
|
737
|
+
) -> None:
|
|
738
|
+
self.__write(
|
|
739
|
+
f"(domain {self.get_object_property_name(p)} {self.get_class_name(c)})"
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
def write_object_property_range_axiom(
|
|
743
|
+
self, p: OWLObjectPropertyExpression, c: OWLClassExpression
|
|
744
|
+
) -> None:
|
|
745
|
+
self.__write(
|
|
746
|
+
f"(range {self.get_object_property_name(p)} {self.get_class_name(c)})"
|
|
747
|
+
)
|
|
748
|
+
|
|
749
|
+
def write_data_property_domain_axiom(
|
|
750
|
+
self, p: OWLDataPropertyExpression, c: OWLClassExpression
|
|
751
|
+
) -> None:
|
|
752
|
+
self.__write(
|
|
753
|
+
f"(domain {self.get_data_property_name(p)} {self.get_class_name(c)})"
|
|
754
|
+
)
|
|
755
|
+
|
|
756
|
+
def write_data_property_range_axiom(
|
|
757
|
+
self, p: OWLDataPropertyExpression, range: OWLDataRange
|
|
758
|
+
) -> None:
|
|
759
|
+
range_str: str = None
|
|
760
|
+
dp_name: str = self.get_data_property_name(p)
|
|
761
|
+
type: DataRangeType = range.getDataRangeType()
|
|
762
|
+
if type == DataRangeType.DATATYPE:
|
|
763
|
+
datatype: OWLDatatype = range.asOWLDatatype()
|
|
764
|
+
if datatype.isString() or str(range.toString()) in (
|
|
765
|
+
"xsd:date",
|
|
766
|
+
"xsd:dateTime",
|
|
767
|
+
"xsd:anyURI",
|
|
768
|
+
):
|
|
769
|
+
self.string_datatypes.add(dp_name)
|
|
770
|
+
range_str = "*string*"
|
|
771
|
+
elif datatype.isBoolean():
|
|
772
|
+
self.boolean_datatypes.add(dp_name)
|
|
773
|
+
range_str = "*boolean*"
|
|
774
|
+
elif type == DataRangeType.DATA_INTERSECTION_OF:
|
|
775
|
+
correctness: int = 0
|
|
776
|
+
is_integer: int = 0
|
|
777
|
+
min: float = 0.0
|
|
778
|
+
max: float = 0.0
|
|
779
|
+
data_range: set[OWLDataRange] = typing.cast(
|
|
780
|
+
OWLDataIntersectionOf, range
|
|
781
|
+
).getOperands()
|
|
782
|
+
if len(data_range) == 2:
|
|
783
|
+
for dr in data_range:
|
|
784
|
+
if dr.getDataRangeType() == DataRangeType.DATATYPE_RESTRICTION:
|
|
785
|
+
restrictions: set[OWLFacetRestriction] = typing.cast(
|
|
786
|
+
OWLFacetRestriction, dr
|
|
787
|
+
).getFacetRestrictions()
|
|
788
|
+
if len(restrictions) != 1:
|
|
789
|
+
continue
|
|
790
|
+
facet: OWLFacetRestriction = list(restrictions)[0]
|
|
791
|
+
val: str = str(facet.getFacetValue().getLiteral())
|
|
792
|
+
if facet.getFacetValue().isInteger():
|
|
793
|
+
is_integer += 1
|
|
794
|
+
k: float = float(val)
|
|
795
|
+
if facet.getFacet() == OWLFacet.MIN_INCLUSIVE:
|
|
796
|
+
min = k
|
|
797
|
+
correctness += 1
|
|
798
|
+
elif facet.getFacet() == OWLFacet.MIN_EXCLUSIVE:
|
|
799
|
+
if is_integer != 0:
|
|
800
|
+
min = k + 1
|
|
801
|
+
else:
|
|
802
|
+
min = k + FuzzyOwl2ToFuzzyDL.EPSILON
|
|
803
|
+
correctness += 1
|
|
804
|
+
elif facet.getFacet() == OWLFacet.MAX_INCLUSIVE:
|
|
805
|
+
max = k
|
|
806
|
+
correctness += 1
|
|
807
|
+
elif facet.getFacet() == OWLFacet.MAX_EXCLUSIVE:
|
|
808
|
+
if is_integer != 0:
|
|
809
|
+
min = k - 1
|
|
810
|
+
else:
|
|
811
|
+
min = k - FuzzyOwl2ToFuzzyDL.EPSILON
|
|
812
|
+
correctness += 1
|
|
813
|
+
if correctness == 2:
|
|
814
|
+
if is_integer == 2:
|
|
815
|
+
range_str = f"*integer* {min} {max}"
|
|
816
|
+
else:
|
|
817
|
+
range_str = f"*real* {min} {max}"
|
|
818
|
+
self.numerical_datatypes.add(dp_name)
|
|
819
|
+
else:
|
|
820
|
+
Util.error(
|
|
821
|
+
f"Data property range axiom with range {range} not supported -- DataPropertyRange({p} {range})"
|
|
822
|
+
)
|
|
823
|
+
if range_str is not None:
|
|
824
|
+
self.write_functional_data_property_axiom(p)
|
|
825
|
+
self.__write(f"(range {dp_name} {range_str})")
|
|
826
|
+
else:
|
|
827
|
+
if str(type.toString()) == "DATA_ONE_OF":
|
|
828
|
+
Util.error(
|
|
829
|
+
f"Data one of range axiom not supported -- DataPropertyRange({p} {range})"
|
|
830
|
+
)
|
|
831
|
+
else:
|
|
832
|
+
range_type: OWLDatatype = range.asOWLDatatype()
|
|
833
|
+
if self.__is_real_datatype(range_type):
|
|
834
|
+
self.write_functional_data_property_axiom(p)
|
|
835
|
+
self.__write(
|
|
836
|
+
f"(range {dp_name} *real* {FuzzyOwl2ToFuzzyDL.DOUBLE_MIN_VALUE} {FuzzyOwl2ToFuzzyDL.DOUBLE_MAX_VALUE})"
|
|
837
|
+
)
|
|
838
|
+
self.numerical_datatypes.add(dp_name)
|
|
839
|
+
elif self.__is_integer_datatype(range_type):
|
|
840
|
+
self.write_functional_data_property_axiom(p)
|
|
841
|
+
facets: float = self.__get_facets(str(range_type.toString()))
|
|
842
|
+
self.__write(f"(range {dp_name} *integer* {facets[0]} {facets[1]})")
|
|
843
|
+
self.numerical_datatypes.add(dp_name)
|
|
844
|
+
else:
|
|
845
|
+
Util.error(
|
|
846
|
+
f"Data property range axiom with range {range} not supported -- DataPropertyRange({p} {range})"
|
|
847
|
+
)
|
|
848
|
+
|
|
849
|
+
def write_disjoint_object_properties_axiom(
|
|
850
|
+
self, class_set: set[OWLObjectPropertyExpression]
|
|
851
|
+
) -> None:
|
|
852
|
+
Util.error(
|
|
853
|
+
f"Disjoint object properties axiom not supported -- DisjointObjectProperties({self.__get_set_name(class_set)})"
|
|
854
|
+
)
|
|
855
|
+
|
|
856
|
+
def write_disjoint_data_properties_axiom(
|
|
857
|
+
self, class_set: set[OWLDataPropertyExpression]
|
|
858
|
+
) -> None:
|
|
859
|
+
Util.error(
|
|
860
|
+
f"Disjoint data properties axiom not supported -- DisjointDataProperties({self.__get_set_name(class_set)})"
|
|
861
|
+
)
|
|
862
|
+
|
|
863
|
+
def write_triangular_modifier_definition(
|
|
864
|
+
self, name: str, mod: TriangularModifier
|
|
865
|
+
) -> None:
|
|
866
|
+
self.__write(f"(define-modifier {name} {mod})")
|
|
867
|
+
|
|
868
|
+
def write_linear_modifier_definition(self, name: str, mod: LinearModifier) -> None:
|
|
869
|
+
self.__write(f"(define-modifier {name} {mod})")
|
|
870
|
+
|
|
871
|
+
def write_left_shoulder_function_definition(
|
|
872
|
+
self, name: str, dat: LeftShoulderFunction
|
|
873
|
+
) -> None:
|
|
874
|
+
self.__write(f"(define-fuzzy-concept {name} {dat})")
|
|
875
|
+
|
|
876
|
+
def write_right_shoulder_function_definition(
|
|
877
|
+
self, name: str, dat: RightShoulderFunction
|
|
878
|
+
) -> None:
|
|
879
|
+
self.__write(f"(define-fuzzy-concept {name} {dat})")
|
|
880
|
+
|
|
881
|
+
def write_linear_function_definition(self, name: str, dat: LinearFunction) -> None:
|
|
882
|
+
self.__write(f"(define-fuzzy-concept {name} {dat})")
|
|
883
|
+
|
|
884
|
+
def write_triangular_function_definition(
|
|
885
|
+
self, name: str, dat: TriangularFunction
|
|
886
|
+
) -> None:
|
|
887
|
+
self.__write(f"(define-fuzzy-concept {name} {dat})")
|
|
888
|
+
|
|
889
|
+
def write_trapezoidal_function_definition(
|
|
890
|
+
self, name: str, dat: TrapezoidalFunction
|
|
891
|
+
) -> None:
|
|
892
|
+
self.__write(f"(define-fuzzy-concept {name} {dat})")
|
|
893
|
+
|
|
894
|
+
def write_modified_function_definition(
|
|
895
|
+
self, name: str, dat: ModifiedFunction
|
|
896
|
+
) -> None:
|
|
897
|
+
self.__write(f"(define-concept {name} {dat})")
|
|
898
|
+
|
|
899
|
+
def write_modified_property_definition(
|
|
900
|
+
self, name: str, dat: ModifiedProperty
|
|
901
|
+
) -> None:
|
|
902
|
+
Util.error(
|
|
903
|
+
f"Modified property not supported -- EquivalentObjectProperties({name} <{dat.get_fuzzy_modifier()} {dat.get_property()}>)"
|
|
904
|
+
)
|
|
905
|
+
|
|
906
|
+
def write_modified_concept_definition(
|
|
907
|
+
self, name: str, dat: ModifiedConcept
|
|
908
|
+
) -> None:
|
|
909
|
+
self.__write(f"(define-concept {name} {dat})")
|
|
910
|
+
|
|
911
|
+
def write_fuzzy_nominal_concept_definition(
|
|
912
|
+
self, name: str, dat: FuzzyNominalConcept
|
|
913
|
+
) -> None:
|
|
914
|
+
Util.error(
|
|
915
|
+
f"Fuzzy nominal not supported -- EquivalentConcepts({name} OneOf({dat}))"
|
|
916
|
+
)
|
|
917
|
+
|
|
918
|
+
def write_weighted_concept_definition(self, name: str, c: WeightedConcept) -> None:
|
|
919
|
+
self.__write(f"(define-concept {name} {c})")
|
|
920
|
+
|
|
921
|
+
def write_weighted_max_concept_definition(
|
|
922
|
+
self, name: str, c: WeightedMaxConcept
|
|
923
|
+
) -> None:
|
|
924
|
+
self.__write(f"(define-concept {name} {c})")
|
|
925
|
+
|
|
926
|
+
def write_weighted_min_concept_definition(
|
|
927
|
+
self, name: str, c: WeightedMinConcept
|
|
928
|
+
) -> None:
|
|
929
|
+
self.__write(f"(define-concept {name} {c})")
|
|
930
|
+
|
|
931
|
+
def write_weighted_sum_concept_definition(
|
|
932
|
+
self, name: str, c: WeightedSumConcept
|
|
933
|
+
) -> None:
|
|
934
|
+
self.__write(f"(define-concept {name} {c})")
|
|
935
|
+
|
|
936
|
+
def write_weighted_sum_zero_concept_definition(
|
|
937
|
+
self, name: str, c: WeightedSumZeroConcept
|
|
938
|
+
) -> None:
|
|
939
|
+
self.__write(f"(define-concept {name} {c})")
|
|
940
|
+
|
|
941
|
+
def write_owa_concept_definition(self, name: str, c: OwaConcept) -> None:
|
|
942
|
+
self.__write(f"(define-concept {name} {c})")
|
|
943
|
+
|
|
944
|
+
def write_choquet_concept_definition(self, name: str, c: ChoquetConcept) -> None:
|
|
945
|
+
self.__write(f"(define-concept {name} {c})")
|
|
946
|
+
|
|
947
|
+
def write_sugeno_concept_definition(self, name: str, c: SugenoConcept) -> None:
|
|
948
|
+
self.__write(f"(define-concept {name} {c})")
|
|
949
|
+
|
|
950
|
+
def write_quasi_sugeno_concept_definition(
|
|
951
|
+
self, name: str, c: QsugenoConcept
|
|
952
|
+
) -> None:
|
|
953
|
+
self.__write(f"(define-concept {name} {c})")
|
|
954
|
+
|
|
955
|
+
def write_qowa_concept_definition(self, name: str, c: QowaConcept) -> None:
|
|
956
|
+
self.__write(f"(define-concept {name} {c})")
|