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,65 @@
1
+ from __future__ import annotations
2
+
3
+ from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
4
+ from fuzzy_dl_owl2.fuzzydl.concept.implies_concept import ImpliesConcept
5
+ from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
6
+ from fuzzy_dl_owl2.fuzzydl.degree.degree_expression import DegreeExpression
7
+ from fuzzy_dl_owl2.fuzzydl.exception.inconsistent_ontology_exception import (
8
+ InconsistentOntologyException,
9
+ )
10
+ from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
11
+ from fuzzy_dl_owl2.fuzzydl.knowledge_base import KnowledgeBase
12
+ from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
13
+ from fuzzy_dl_owl2.fuzzydl.milp.solution import Solution
14
+ from fuzzy_dl_owl2.fuzzydl.milp.term import Term
15
+ from fuzzy_dl_owl2.fuzzydl.milp.variable import Variable
16
+ from fuzzy_dl_owl2.fuzzydl.query.subsumption_query import SubsumptionQuery
17
+ from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
18
+ from fuzzy_dl_owl2.fuzzydl.util.constants import LogicOperatorType, VariableType
19
+
20
+
21
+ class MinSubsumesQuery(SubsumptionQuery):
22
+
23
+ def __init__(self, c1: Concept, c2: Concept, type_: LogicOperatorType) -> None:
24
+ super().__init__(c1, c2, type_)
25
+
26
+ def preprocess(self, kb: KnowledgeBase) -> None:
27
+ ind: Individual = kb.get_new_individual()
28
+
29
+ if self.type == LogicOperatorType.LUKASIEWICZ:
30
+ conc: Concept = OperatorConcept.lukasiewicz_or(-self.c2, self.c1)
31
+ elif self.type == LogicOperatorType.GOEDEL:
32
+ conc: Concept = ImpliesConcept.goedel_implies(self.c2, self.c1)
33
+ elif self.type == LogicOperatorType.KLEENE_DIENES:
34
+ conc: Concept = ImpliesConcept.zadeh_implies(self.c2, self.c1)
35
+ else: # LogicOperatorType.ZADEH
36
+ conc: Concept = OperatorConcept.goedel_or(-self.c2, self.c1)
37
+
38
+ q: Variable = kb.milp.get_new_variable(VariableType.SEMI_CONTINUOUS)
39
+ kb.old_01_variables += 1
40
+ self.obj_expr: Expression = Expression(Term(1.0, q))
41
+
42
+ kb.add_assertion(
43
+ ind,
44
+ -conc,
45
+ DegreeExpression.get_degree(Expression(1.0, Term(-1.0, q))),
46
+ )
47
+ kb.solve_assertions()
48
+
49
+ def solve(self, kb: KnowledgeBase) -> Solution:
50
+ try:
51
+ self.set_initial_time()
52
+ if ConfigReader.OPTIMIZATIONS == 0 or kb.has_nominals_in_tbox():
53
+ cloned: KnowledgeBase = kb.clone()
54
+ cloned.solve_abox()
55
+ else:
56
+ cloned: KnowledgeBase = kb.clone_without_abox()
57
+ self.preprocess(cloned)
58
+ sol: Solution = cloned.optimize(self.obj_expr)
59
+ self.set_total_time()
60
+ return sol
61
+ except InconsistentOntologyException:
62
+ return Solution(False)
63
+
64
+ def __str__(self) -> str:
65
+ return f"{self.c1} subsumes {self.c2} ? >= "
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ import time
4
+ from abc import ABC, abstractmethod
5
+
6
+ from fuzzy_dl_owl2.fuzzydl.knowledge_base import KnowledgeBase
7
+ from fuzzy_dl_owl2.fuzzydl.milp.solution import Solution
8
+
9
+
10
+ class Query(ABC):
11
+ def __init__(self) -> None:
12
+ self.initial_time: int = 0
13
+ self.total_time: int = 0
14
+
15
+ def set_initial_time(self) -> None:
16
+ self.initial_time = time.perf_counter_ns()
17
+
18
+ def set_total_time(self) -> None:
19
+ end_time: int = time.perf_counter_ns()
20
+ self.total_time = end_time - self.initial_time
21
+
22
+ def get_total_time(self) -> float:
23
+ return self.total_time / 1e9
24
+
25
+ @abstractmethod
26
+ def preprocess(self, knowledge_base: KnowledgeBase) -> None:
27
+ """Preprocess the query with given knowledge base"""
28
+ pass
29
+
30
+ @abstractmethod
31
+ def solve(self, knowledge_base: KnowledgeBase) -> Solution:
32
+ """Solve the query using given knowledge base"""
33
+ pass
34
+
35
+ @abstractmethod
36
+ def __str__(self) -> str:
37
+ """String representation of the query"""
38
+ pass
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
4
+ from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
5
+ from fuzzy_dl_owl2.fuzzydl.query.query import Query
6
+
7
+
8
+ class RelatedQuery(Query):
9
+
10
+ def __init__(self) -> None:
11
+ super().__init__()
12
+ self.role: str = None
13
+ self.ind1: Individual = None
14
+ self.ind2: Individual = None
15
+ self.obj_expr: Expression = None
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
6
+ from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
7
+ from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
8
+ from fuzzy_dl_owl2.fuzzydl.query.query import Query
9
+ from fuzzy_dl_owl2.fuzzydl.util.util import Util
10
+
11
+
12
+ class SatisfiableQuery(Query):
13
+
14
+ @typing.overload
15
+ def __init__(self, c: Concept, a: Individual) -> None: ...
16
+
17
+ @typing.overload
18
+ def __init__(self, c: Concept) -> None: ...
19
+
20
+ def __init__(self, *args) -> None:
21
+ assert len(args) in [1, 2]
22
+ assert isinstance(args[0], Concept)
23
+ if len(args) == 1:
24
+ self.__satisfiable_query_init_2(*args)
25
+ else:
26
+ assert args[1] is None or isinstance(args[1], Individual)
27
+ self.__satisfiable_query_init_1(*args)
28
+
29
+ def __satisfiable_query_init_1(self, c: Concept, a: Individual) -> None:
30
+ if c.is_concrete():
31
+ Util.error(f"Error: {c} cannot be a concrete concept.")
32
+ self.conc: Concept = c
33
+ self.ind: Individual = a
34
+ self.obj_expr: Expression = None
35
+
36
+ def __satisfiable_query_init_2(self, c: Concept) -> None:
37
+ self.__init__(c, None)
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
4
+ from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
5
+ from fuzzy_dl_owl2.fuzzydl.query.query import Query
6
+ from fuzzy_dl_owl2.fuzzydl.util.constants import LogicOperatorType
7
+ from fuzzy_dl_owl2.fuzzydl.util.util import Util
8
+
9
+
10
+ class SubsumptionQuery(Query):
11
+
12
+ def __init__(self, c1: Concept, c2: Concept, s_type: LogicOperatorType) -> None:
13
+ if c1.is_concrete():
14
+ Util.error(f"Error: {c1} cannot be a concrete concept.")
15
+ if c2.is_concrete():
16
+ Util.error(f"Error: {c1} cannot be a concrete concept.")
17
+ self.c1: Concept = c1
18
+ self.c2: Concept = c2
19
+ self.type: LogicOperatorType = s_type
20
+ self.obj_expr: Expression = None
@@ -0,0 +1,7 @@
1
+ from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
2
+
3
+
4
+ class RangeAxiom:
5
+ def __init__(self, role: str, concept: Concept) -> None:
6
+ self.role: str = role
7
+ self.concept: Concept = concept
@@ -0,0 +1,47 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ if typing.TYPE_CHECKING:
6
+ from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
7
+ from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
8
+
9
+
10
+ class Relation:
11
+ def __init__(
12
+ self, role_name: str, ind1: Individual, ind2: Individual, degree: Degree
13
+ ):
14
+ self.role_name: str = role_name
15
+ self.ind_a: Individual = ind1
16
+ self.ind_b: Individual = ind2
17
+ self.degree: Degree = degree
18
+
19
+ def clone(self) -> typing.Self:
20
+ return Relation(self.role_name, self.ind_a, self.ind_b, self.degree)
21
+
22
+ def get_subject_individual(self) -> Individual:
23
+ return self.ind_a
24
+
25
+ def get_object_individual(self) -> Individual:
26
+ return self.ind_b
27
+
28
+ def set_object_individual(self, ind: Individual) -> None:
29
+ self.ind_b = ind
30
+
31
+ def set_subject_individual(self, ind: Individual) -> None:
32
+ self.ind_a = ind
33
+
34
+ def get_role_name(self) -> str:
35
+ return self.role_name
36
+
37
+ def get_degree(self) -> Degree:
38
+ return self.degree
39
+
40
+ def get_name_without_degree(self) -> str:
41
+ return f"({self.ind_a}, {self.ind_b}): {self.role_name}"
42
+
43
+ def __repr__(self) -> str:
44
+ return str(self)
45
+
46
+ def __str__(self) -> str:
47
+ return f"{self.get_name_without_degree()} >= {self.degree}"
@@ -0,0 +1,2 @@
1
+ from .restriction import Restriction
2
+ from .has_value_restriction import HasValueRestriction
@@ -0,0 +1,16 @@
1
+ from __future__ import annotations
2
+
3
+ from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
4
+ from fuzzy_dl_owl2.fuzzydl.restriction.restriction import Restriction
5
+
6
+
7
+ class HasValueRestriction(Restriction):
8
+ def __init__(self, role_name: str, individual: str, degree: Degree) -> None:
9
+ super().__init__(role_name, None, degree)
10
+ self.ind_name: str = individual
11
+
12
+ def get_individual(self) -> str:
13
+ return self.ind_name
14
+
15
+ def get_name_without_degree(self) -> str:
16
+ return f"(not (b-some {self.role_name} {self.ind_name}))"
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
6
+ from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
7
+
8
+
9
+ class Restriction:
10
+ def __init__(self, role_name: str, concept: Concept, degree: Degree) -> None:
11
+ self.role_name: str = role_name
12
+ self.concept: Concept = concept
13
+ self.degree: Degree = degree
14
+
15
+ def clone(self) -> typing.Self:
16
+ return Restriction(self.role_name, self.concept, self.degree)
17
+
18
+ def get_role_name(self) -> str:
19
+ return self.role_name
20
+
21
+ def get_degree(self) -> Degree:
22
+ return self.degree
23
+
24
+ def get_concept(self) -> Concept:
25
+ return self.concept
26
+
27
+ def get_name_without_degree(self) -> str:
28
+ return f"(all {self.role_name} {self.concept})"
29
+
30
+ def __repr__(self) -> str:
31
+ return str(self)
32
+
33
+ def __str__(self) -> str:
34
+ return f"{self.get_name_without_degree()} >= {self.degree}"
@@ -0,0 +1,10 @@
1
+ class RoleParentWithDegree:
2
+ def __init__(self, parent: str, degree: float) -> None:
3
+ self.degree: float = degree
4
+ self.parent: str = parent
5
+
6
+ def get_degree(self) -> float:
7
+ return self.degree
8
+
9
+ def get_parent(self) -> str:
10
+ return self.parent
@@ -0,0 +1,3 @@
1
+ from .config_reader import ConfigReader
2
+ from .util import Util
3
+ from .utils import *
@@ -0,0 +1,56 @@
1
+ from __future__ import annotations
2
+
3
+ import configparser
4
+ import math
5
+
6
+
7
+ class ConfigReader:
8
+ ANYWHERE_DOUBLE_BLOCKING: bool = True
9
+ ANYWHERE_SIMPLE_BLOCKING: bool = True
10
+ RELAX_MILP: bool = False
11
+ DEBUG_PRINT: bool = True
12
+ EPSILON: float = 0.001
13
+ MAX_INDIVIDUALS: int = -1
14
+ NUMBER_DIGITS: int = 2
15
+ OPTIMIZATIONS: int = 1
16
+ RULE_ACYCLIC_TBOXES: bool = True
17
+ SHOW_VERSION: bool = False
18
+ AUTHOR: bool = False
19
+
20
+ @staticmethod
21
+ def load_parameters(config_file: str, args: list[str]) -> None:
22
+ try:
23
+ config = configparser.ConfigParser()
24
+ config.read(config_file)
25
+
26
+ if len(args) > 1:
27
+ for i in range(0, len(args), 2):
28
+ config["DEFAULT"][args[i]] = args[i + 1]
29
+ # else:
30
+ # config["DEFAULT"] = {
31
+ # "epsilon": ConfigReader.EPSILON,
32
+ # "debugPrint": ConfigReader.DEBUG_PRINT,
33
+ # "maxIndividuals": ConfigReader.MAX_INDIVIDUALS,
34
+ # "showVersion": ConfigReader.SHOW_VERSION,
35
+ # "author": False,
36
+ # }
37
+
38
+ ConfigReader.RELAX_MILP = config.getboolean("DEFAULT", "relaxMilp")
39
+ ConfigReader.DEBUG_PRINT = config.getboolean("DEFAULT", "debugPrint")
40
+ ConfigReader.EPSILON = config.getfloat("DEFAULT", "epsilon")
41
+ ConfigReader.MAX_INDIVIDUALS = config.getint("DEFAULT", "maxIndividuals")
42
+ ConfigReader.NUMBER_DIGITS = int(
43
+ round(abs(math.log10(ConfigReader.EPSILON) - 1.0))
44
+ )
45
+ ConfigReader.SHOW_VERSION = config.getboolean("DEFAULT", "showVersion")
46
+
47
+ if ConfigReader.DEBUG_PRINT:
48
+ print(f"Debugging mode = {ConfigReader.DEBUG_PRINT}")
49
+
50
+ if config.getboolean("DEFAULT", "author"):
51
+ print("Author of python-fuzzyDL: Giuseppe Filippone")
52
+
53
+ except FileNotFoundError:
54
+ print(f"Error: File {config_file} not found.")
55
+ except Exception as e:
56
+ print(f"Error: {e}.")