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