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,491 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import traceback
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
import pyparsing as pp
|
|
8
|
+
|
|
9
|
+
from fuzzy_dl_owl2.fuzzydl.concept.qowa_concept import QowaConcept
|
|
10
|
+
from fuzzy_dl_owl2.fuzzydl.knowledge_base import KnowledgeBase
|
|
11
|
+
from fuzzy_dl_owl2.fuzzydl.modifier.linear_modifier import LinearModifier
|
|
12
|
+
from fuzzy_dl_owl2.fuzzydl.modifier.modifier import Modifier
|
|
13
|
+
from fuzzy_dl_owl2.fuzzydl.modifier.triangular_modifier import TriangularModifier
|
|
14
|
+
from fuzzy_dl_owl2.fuzzydl.query.query import Query
|
|
15
|
+
from fuzzy_dl_owl2.fuzzydl.util import utils
|
|
16
|
+
from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
|
|
17
|
+
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
18
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.choquet_concept import ChoquetConcept
|
|
19
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.concept_definition import ConceptDefinition
|
|
20
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.fuzzy_datatype import FuzzyDatatype
|
|
21
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.fuzzy_nominal_concept import FuzzyNominalConcept
|
|
22
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.left_shoulder_function import (
|
|
23
|
+
LeftShoulderFunction,
|
|
24
|
+
)
|
|
25
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.linear_function import LinearFunction
|
|
26
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.modified_concept import ModifiedConcept
|
|
27
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.modified_property import ModifiedProperty
|
|
28
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.owa_concept import OwaConcept
|
|
29
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.quasi_sugeno_concept import QsugenoConcept
|
|
30
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.right_shoulder_function import (
|
|
31
|
+
RightShoulderFunction,
|
|
32
|
+
)
|
|
33
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.sugeno_concept import SugenoConcept
|
|
34
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.trapezoidal_function import TrapezoidalFunction
|
|
35
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.triangular_function import TriangularFunction
|
|
36
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_concept import WeightedConcept
|
|
37
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_max_concept import WeightedMaxConcept
|
|
38
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_min_concept import WeightedMinConcept
|
|
39
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_sum_concept import WeightedSumConcept
|
|
40
|
+
from fuzzy_dl_owl2.fuzzyowl2.owl_types.weighted_sum_zero_concept import (
|
|
41
|
+
WeightedSumZeroConcept,
|
|
42
|
+
)
|
|
43
|
+
from fuzzy_dl_owl2.fuzzyowl2.util.constants import FuzzyOWL2Keyword
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _to_number(tokens: pp.ParseResults) -> float | int:
|
|
47
|
+
v: float = float(str(tokens.as_list()[0]))
|
|
48
|
+
return int(v) if v.is_integer() else v
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _parse_fuzzy_datatype(tokens: pp.ParseResults) -> FuzzyDatatype:
|
|
52
|
+
Util.debug(f"_parse_fuzzy_datatype -> {tokens}")
|
|
53
|
+
list_tokens: list = tokens.as_list()
|
|
54
|
+
if list_tokens[0] == FuzzyOWL2Keyword.LEFT_SHOULDER:
|
|
55
|
+
return LeftShoulderFunction(list_tokens[1], list_tokens[2])
|
|
56
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.RIGHT_SHOULDER:
|
|
57
|
+
return RightShoulderFunction(list_tokens[1], list_tokens[2])
|
|
58
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.LINEAR:
|
|
59
|
+
return LinearFunction(list_tokens[1], list_tokens[2])
|
|
60
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.TRIANGULAR:
|
|
61
|
+
return TriangularFunction(list_tokens[1], list_tokens[2], list_tokens[3])
|
|
62
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.TRAPEZOIDAL:
|
|
63
|
+
return TrapezoidalFunction(
|
|
64
|
+
list_tokens[1], list_tokens[2], list_tokens[3], list_tokens[4]
|
|
65
|
+
)
|
|
66
|
+
return tokens
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _parse_modifier_function(tokens: pp.ParseResults) -> Modifier:
|
|
70
|
+
Util.debug(f"_parse_modifier_function -> {tokens}")
|
|
71
|
+
list_tokens: list = tokens.as_list()
|
|
72
|
+
if list_tokens[0] == FuzzyOWL2Keyword.LINEAR:
|
|
73
|
+
return LinearModifier(None, list_tokens[1])
|
|
74
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.TRIANGULAR:
|
|
75
|
+
return TriangularModifier(None, list_tokens[1], list_tokens[2], list_tokens[3])
|
|
76
|
+
return tokens
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _parse_weighted_concept(tokens: pp.ParseResults) -> ConceptDefinition:
|
|
80
|
+
Util.debug(f"_parse_weighted_concept -> {tokens}")
|
|
81
|
+
list_tokens: list = tokens.as_list()
|
|
82
|
+
return WeightedConcept(list_tokens[0], list_tokens[1])
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _parse_modified_concept(tokens: pp.ParseResults) -> ConceptDefinition:
|
|
86
|
+
Util.debug(f"_parse_modified_concept -> {tokens}")
|
|
87
|
+
list_tokens: list = tokens.as_list()
|
|
88
|
+
return ModifiedConcept(list_tokens[0], list_tokens[1])
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _parse_q_owa_concept(tokens: pp.ParseResults) -> ConceptDefinition:
|
|
92
|
+
Util.debug(f"_parse_q_owa_concept -> {tokens}")
|
|
93
|
+
list_tokens: list = tokens.as_list()
|
|
94
|
+
return QowaConcept(list_tokens[0], list_tokens[1])
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _parse_fuzzy_nominal(tokens: pp.ParseResults) -> ConceptDefinition:
|
|
98
|
+
Util.debug(f"_parse_fuzzy_nominal -> {tokens}")
|
|
99
|
+
list_tokens: list = tokens.as_list()
|
|
100
|
+
return FuzzyNominalConcept(list_tokens[0], list_tokens[1])
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _parse_weighted_complex_concept(tokens: pp.ParseResults) -> ConceptDefinition:
|
|
104
|
+
Util.debug(f"_parse_weighted_complex_concept -> {tokens}")
|
|
105
|
+
list_tokens: list = tokens.as_list()
|
|
106
|
+
assert isinstance(list_tokens[1], list) and all(
|
|
107
|
+
isinstance(a, WeightedConcept) for a in list_tokens[1]
|
|
108
|
+
)
|
|
109
|
+
wc: list[WeightedConcept] = [
|
|
110
|
+
typing.cast(WeightedConcept, w) for w in list_tokens[1]
|
|
111
|
+
]
|
|
112
|
+
if list_tokens[0] == FuzzyOWL2Keyword.WEIGHTED_MAXIMUM:
|
|
113
|
+
return WeightedMaxConcept(wc)
|
|
114
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.WEIGHTED_MINIMUM:
|
|
115
|
+
return WeightedMinConcept(wc)
|
|
116
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.WEIGHTED_SUM:
|
|
117
|
+
return WeightedSumConcept(wc)
|
|
118
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.WEIGHTED_SUMZERO:
|
|
119
|
+
return WeightedSumZeroConcept(wc)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _parse_integral_concept(tokens: pp.ParseResults) -> ConceptDefinition:
|
|
123
|
+
Util.debug(f"_parse_integral_concept -> {tokens}")
|
|
124
|
+
list_tokens: list = tokens.as_list()
|
|
125
|
+
if list_tokens[0] == FuzzyOWL2Keyword.OWA:
|
|
126
|
+
return OwaConcept(list_tokens[1], list_tokens[2])
|
|
127
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.SUGENO:
|
|
128
|
+
return SugenoConcept(list_tokens[1], list_tokens[2])
|
|
129
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.QUASI_SUGENO:
|
|
130
|
+
return QsugenoConcept(list_tokens[1], list_tokens[2])
|
|
131
|
+
elif list_tokens[0] == FuzzyOWL2Keyword.CHOQUET:
|
|
132
|
+
return ChoquetConcept(list_tokens[1], list_tokens[2])
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _parse_property(tokens: pp.ParseResults) -> ModifiedProperty:
|
|
136
|
+
Util.debug(f"_parse_property -> {tokens}")
|
|
137
|
+
list_tokens: list = tokens.as_list()
|
|
138
|
+
assert isinstance(list_tokens[0], ModifiedConcept)
|
|
139
|
+
w: ModifiedConcept = typing.cast(ModifiedConcept, list_tokens[0])
|
|
140
|
+
return ModifiedProperty(w.get_fuzzy_modifier(), w.get_fuzzy_concept())
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class FuzzyOwl2Parser(object):
|
|
144
|
+
|
|
145
|
+
@staticmethod
|
|
146
|
+
def get_grammatics() -> pp.ParserElement:
|
|
147
|
+
"""
|
|
148
|
+
This function generate the grammatics to parse the predicate wih formula "formula".
|
|
149
|
+
|
|
150
|
+
Parameters
|
|
151
|
+
---------------------------
|
|
152
|
+
formula := The predicate formula used for the parsing.
|
|
153
|
+
|
|
154
|
+
Returns
|
|
155
|
+
---------------------------
|
|
156
|
+
The parsed result given by pyparsing.
|
|
157
|
+
"""
|
|
158
|
+
pp.ParserElement.enable_left_recursion(force=True)
|
|
159
|
+
|
|
160
|
+
open_tag = FuzzyOWL2Keyword.OPEN_TAG.get_value().suppress()
|
|
161
|
+
close_tag = FuzzyOWL2Keyword.CLOSE_TAG.get_value().suppress()
|
|
162
|
+
slash = FuzzyOWL2Keyword.SLASH.get_value().suppress()
|
|
163
|
+
single_close_tag = FuzzyOWL2Keyword.SINGLE_CLOSE_TAG.get_value().suppress()
|
|
164
|
+
|
|
165
|
+
digits = pp.Word(pp.nums)
|
|
166
|
+
numbers = (
|
|
167
|
+
(
|
|
168
|
+
pp.Opt(pp.one_of(['"', "'"])).suppress()
|
|
169
|
+
+ pp.Combine(
|
|
170
|
+
pp.Opt(pp.one_of(["+", "-"])) + digits + pp.Opt("." + digits)
|
|
171
|
+
)
|
|
172
|
+
+ pp.Opt(pp.one_of(['"', "'"])).suppress()
|
|
173
|
+
)
|
|
174
|
+
.set_results_name("number")
|
|
175
|
+
.set_parse_action(_to_number)
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
simple_string = pp.Word(
|
|
179
|
+
pp.alphas + "_", pp.alphanums + "_'"
|
|
180
|
+
) # pp.Regex(r"[a-zA-Z_][a-zA-Z0-9_]*")
|
|
181
|
+
strings = (
|
|
182
|
+
pp.Opt(pp.one_of(['"', "'"])).suppress()
|
|
183
|
+
+ simple_string.set_results_name("string")
|
|
184
|
+
+ pp.Opt(pp.one_of(['"', "'"])).suppress()
|
|
185
|
+
)
|
|
186
|
+
variables = strings | simple_string.set_results_name("variable")
|
|
187
|
+
|
|
188
|
+
common_start = (
|
|
189
|
+
open_tag
|
|
190
|
+
+ FuzzyOWL2Keyword.FUZZY_OWL_2.get_value().suppress()
|
|
191
|
+
+ FuzzyOWL2Keyword.FUZZY_TYPE.get_value().suppress()
|
|
192
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
193
|
+
)
|
|
194
|
+
common_end = (
|
|
195
|
+
open_tag
|
|
196
|
+
+ slash
|
|
197
|
+
+ FuzzyOWL2Keyword.FUZZY_OWL_2.get_value().suppress()
|
|
198
|
+
+ close_tag
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
fuzzy_logic = (
|
|
202
|
+
common_start
|
|
203
|
+
+ FuzzyOWL2Keyword.ONTOLOGY.get_value().suppress()
|
|
204
|
+
+ close_tag
|
|
205
|
+
+ open_tag
|
|
206
|
+
+ FuzzyOWL2Keyword.FUZZY_LOGIC.get_value().suppress()
|
|
207
|
+
+ FuzzyOWL2Keyword.LOGIC.get_value().suppress()
|
|
208
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
209
|
+
+ (
|
|
210
|
+
FuzzyOWL2Keyword.LUKASIEWICZ.get_value()
|
|
211
|
+
| FuzzyOWL2Keyword.ZADEH.get_value()
|
|
212
|
+
).set_results_name("fuzzy_logic")
|
|
213
|
+
+ single_close_tag
|
|
214
|
+
+ common_end
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
comment_line = (
|
|
218
|
+
pp.Literal("<!--") + pp.Regex(".*") + pp.Literal("-->")
|
|
219
|
+
).suppress()
|
|
220
|
+
|
|
221
|
+
concept = pp.Forward()
|
|
222
|
+
|
|
223
|
+
modified_role_concept = (
|
|
224
|
+
FuzzyOWL2Keyword.MODIFIED.get_value().suppress()
|
|
225
|
+
+ FuzzyOWL2Keyword.MODIFIER.get_value().suppress()
|
|
226
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
227
|
+
+ variables
|
|
228
|
+
+ FuzzyOWL2Keyword.BASE.get_value().suppress()
|
|
229
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
230
|
+
+ variables
|
|
231
|
+
).add_parse_action(_parse_modified_concept)
|
|
232
|
+
|
|
233
|
+
weighted_concept = (
|
|
234
|
+
FuzzyOWL2Keyword.WEIGHTED.get_value().suppress()
|
|
235
|
+
+ FuzzyOWL2Keyword.DEGREE_VALUE.get_value().suppress()
|
|
236
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
237
|
+
+ numbers
|
|
238
|
+
+ FuzzyOWL2Keyword.BASE.get_value().suppress()
|
|
239
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
240
|
+
+ variables
|
|
241
|
+
).add_parse_action(_parse_weighted_concept)
|
|
242
|
+
|
|
243
|
+
weights = (
|
|
244
|
+
open_tag
|
|
245
|
+
+ FuzzyOWL2Keyword.WEIGHTS.get_value().suppress()
|
|
246
|
+
+ close_tag
|
|
247
|
+
+ (
|
|
248
|
+
open_tag
|
|
249
|
+
+ FuzzyOWL2Keyword.WEIGHT.get_value().suppress()
|
|
250
|
+
+ close_tag
|
|
251
|
+
+ numbers
|
|
252
|
+
+ open_tag
|
|
253
|
+
+ slash
|
|
254
|
+
+ FuzzyOWL2Keyword.WEIGHT.get_value().suppress()
|
|
255
|
+
+ close_tag
|
|
256
|
+
)[1, ...]
|
|
257
|
+
+ open_tag
|
|
258
|
+
+ slash
|
|
259
|
+
+ FuzzyOWL2Keyword.WEIGHTS.get_value().suppress()
|
|
260
|
+
+ close_tag
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
concepts = (
|
|
264
|
+
open_tag
|
|
265
|
+
+ FuzzyOWL2Keyword.CONCEPT_NAMES.get_value().suppress()
|
|
266
|
+
+ close_tag
|
|
267
|
+
+ (
|
|
268
|
+
open_tag
|
|
269
|
+
+ FuzzyOWL2Keyword.NAME.get_value().suppress()
|
|
270
|
+
+ close_tag
|
|
271
|
+
+ variables
|
|
272
|
+
+ open_tag
|
|
273
|
+
+ slash
|
|
274
|
+
+ FuzzyOWL2Keyword.NAME.get_value().suppress()
|
|
275
|
+
+ close_tag
|
|
276
|
+
)[1, ...]
|
|
277
|
+
+ open_tag
|
|
278
|
+
+ slash
|
|
279
|
+
+ FuzzyOWL2Keyword.CONCEPT_NAMES.get_value().suppress()
|
|
280
|
+
+ close_tag
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
weighted_list_concept = close_tag + weights + concepts
|
|
284
|
+
q_owa_concept = (
|
|
285
|
+
FuzzyOWL2Keyword.QUANTIFIER.get_value().suppress()
|
|
286
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
287
|
+
+ variables
|
|
288
|
+
+ close_tag
|
|
289
|
+
+ concepts
|
|
290
|
+
).add_parse_action(_parse_q_owa_concept)
|
|
291
|
+
|
|
292
|
+
concept <<= (
|
|
293
|
+
common_start
|
|
294
|
+
+ FuzzyOWL2Keyword.CONCEPT.get_value().suppress()
|
|
295
|
+
+ close_tag
|
|
296
|
+
+ (
|
|
297
|
+
open_tag
|
|
298
|
+
+ FuzzyOWL2Keyword.CONCEPT.get_value().suppress()
|
|
299
|
+
+ FuzzyOWL2Keyword.TYPE.get_value().suppress()
|
|
300
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
301
|
+
+ (
|
|
302
|
+
(
|
|
303
|
+
modified_role_concept + single_close_tag
|
|
304
|
+
| (
|
|
305
|
+
(
|
|
306
|
+
FuzzyOWL2Keyword.WEIGHTED_MAXIMUM.get_value()
|
|
307
|
+
| FuzzyOWL2Keyword.WEIGHTED_MINIMUM.get_value()
|
|
308
|
+
| FuzzyOWL2Keyword.WEIGHTED_SUM.get_value()
|
|
309
|
+
| FuzzyOWL2Keyword.WEIGHTED_SUMZERO.get_value()
|
|
310
|
+
)
|
|
311
|
+
+ close_tag
|
|
312
|
+
+ weighted_concept[1, ...]
|
|
313
|
+
).add_parse_action(_parse_weighted_complex_concept)
|
|
314
|
+
| (
|
|
315
|
+
(
|
|
316
|
+
FuzzyOWL2Keyword.OWA.get_value()
|
|
317
|
+
| FuzzyOWL2Keyword.CHOQUET.get_value()
|
|
318
|
+
| FuzzyOWL2Keyword.SUGENO.get_value()
|
|
319
|
+
| FuzzyOWL2Keyword.QUASI_SUGENO.get_value()
|
|
320
|
+
)
|
|
321
|
+
+ weighted_list_concept
|
|
322
|
+
).add_parse_action(_parse_integral_concept)
|
|
323
|
+
| FuzzyOWL2Keyword.Q_OWA.get_value().suppress() + q_owa_concept
|
|
324
|
+
)
|
|
325
|
+
+ open_tag
|
|
326
|
+
+ slash
|
|
327
|
+
+ FuzzyOWL2Keyword.CONCEPT.get_value().suppress()
|
|
328
|
+
+ close_tag
|
|
329
|
+
| weighted_concept + single_close_tag
|
|
330
|
+
| (
|
|
331
|
+
FuzzyOWL2Keyword.NOMINAL.get_value().suppress()
|
|
332
|
+
+ FuzzyOWL2Keyword.DEGREE_DEF.get_value().suppress()
|
|
333
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
334
|
+
+ numbers
|
|
335
|
+
+ FuzzyOWL2Keyword.INDIVIDUAL.get_value().suppress()
|
|
336
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
337
|
+
+ variables
|
|
338
|
+
+ single_close_tag
|
|
339
|
+
).add_parse_action(_parse_fuzzy_nominal)
|
|
340
|
+
)
|
|
341
|
+
)
|
|
342
|
+
+ common_end
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
property = (
|
|
346
|
+
common_start
|
|
347
|
+
+ FuzzyOWL2Keyword.ROLE.get_value().suppress()
|
|
348
|
+
+ close_tag
|
|
349
|
+
+ open_tag
|
|
350
|
+
+ FuzzyOWL2Keyword.ROLE.get_value().suppress()
|
|
351
|
+
+ FuzzyOWL2Keyword.TYPE.get_value().suppress()
|
|
352
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
353
|
+
+ modified_role_concept
|
|
354
|
+
+ slash
|
|
355
|
+
+ close_tag
|
|
356
|
+
+ common_end
|
|
357
|
+
).add_parse_action(_parse_property)
|
|
358
|
+
|
|
359
|
+
fuzzy_datatype = (
|
|
360
|
+
(
|
|
361
|
+
(
|
|
362
|
+
FuzzyOWL2Keyword.LEFT_SHOULDER.get_value()
|
|
363
|
+
| FuzzyOWL2Keyword.RIGHT_SHOULDER.get_value()
|
|
364
|
+
| FuzzyOWL2Keyword.LINEAR.get_value()
|
|
365
|
+
)
|
|
366
|
+
+ FuzzyOWL2Keyword.A.get_value().suppress()
|
|
367
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
368
|
+
+ numbers
|
|
369
|
+
+ FuzzyOWL2Keyword.B.get_value().suppress()
|
|
370
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
371
|
+
+ numbers
|
|
372
|
+
)
|
|
373
|
+
| (
|
|
374
|
+
FuzzyOWL2Keyword.TRIANGULAR.get_value()
|
|
375
|
+
+ FuzzyOWL2Keyword.A.get_value().suppress()
|
|
376
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
377
|
+
+ numbers
|
|
378
|
+
+ FuzzyOWL2Keyword.B.get_value().suppress()
|
|
379
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
380
|
+
+ numbers
|
|
381
|
+
+ FuzzyOWL2Keyword.C.get_value().suppress()
|
|
382
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
383
|
+
+ numbers
|
|
384
|
+
)
|
|
385
|
+
| (
|
|
386
|
+
FuzzyOWL2Keyword.TRAPEZOIDAL.get_value()
|
|
387
|
+
+ FuzzyOWL2Keyword.A.get_value().suppress()
|
|
388
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
389
|
+
+ numbers
|
|
390
|
+
+ FuzzyOWL2Keyword.B.get_value().suppress()
|
|
391
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
392
|
+
+ numbers
|
|
393
|
+
+ FuzzyOWL2Keyword.C.get_value().suppress()
|
|
394
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
395
|
+
+ numbers
|
|
396
|
+
+ FuzzyOWL2Keyword.D.get_value().suppress()
|
|
397
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
398
|
+
+ numbers
|
|
399
|
+
)
|
|
400
|
+
| modified_role_concept
|
|
401
|
+
).add_parse_action(_parse_fuzzy_datatype)
|
|
402
|
+
|
|
403
|
+
modifier = (
|
|
404
|
+
(
|
|
405
|
+
FuzzyOWL2Keyword.TRIANGULAR.get_value()
|
|
406
|
+
+ FuzzyOWL2Keyword.A.get_value().suppress()
|
|
407
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
408
|
+
+ numbers
|
|
409
|
+
+ FuzzyOWL2Keyword.B.get_value().suppress()
|
|
410
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
411
|
+
+ numbers
|
|
412
|
+
+ FuzzyOWL2Keyword.C.get_value().suppress()
|
|
413
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
414
|
+
+ numbers
|
|
415
|
+
)
|
|
416
|
+
| (
|
|
417
|
+
FuzzyOWL2Keyword.LINEAR.get_value()
|
|
418
|
+
+ FuzzyOWL2Keyword.C.get_value().suppress()
|
|
419
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
420
|
+
+ numbers
|
|
421
|
+
)
|
|
422
|
+
).add_parse_action(_parse_modifier_function)
|
|
423
|
+
|
|
424
|
+
datatype = (
|
|
425
|
+
common_start
|
|
426
|
+
+ (
|
|
427
|
+
FuzzyOWL2Keyword.DATATYPE.get_value().suppress()
|
|
428
|
+
+ close_tag
|
|
429
|
+
+ open_tag
|
|
430
|
+
+ FuzzyOWL2Keyword.DATATYPE.get_value().suppress()
|
|
431
|
+
+ FuzzyOWL2Keyword.TYPE.get_value().suppress()
|
|
432
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
433
|
+
+ fuzzy_datatype
|
|
434
|
+
+ slash
|
|
435
|
+
+ close_tag
|
|
436
|
+
| FuzzyOWL2Keyword.MODIFIER.get_value().suppress()
|
|
437
|
+
+ close_tag
|
|
438
|
+
+ open_tag
|
|
439
|
+
+ FuzzyOWL2Keyword.MODIFIER.get_value().suppress()
|
|
440
|
+
+ FuzzyOWL2Keyword.TYPE.get_value().suppress()
|
|
441
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
442
|
+
+ modifier
|
|
443
|
+
+ slash
|
|
444
|
+
+ close_tag
|
|
445
|
+
)
|
|
446
|
+
+ common_end
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
axiom = (
|
|
450
|
+
common_start
|
|
451
|
+
+ FuzzyOWL2Keyword.AXIOM.get_value().suppress()
|
|
452
|
+
+ close_tag
|
|
453
|
+
+ open_tag
|
|
454
|
+
+ FuzzyOWL2Keyword.DEGREE_DEF.get_value().suppress()
|
|
455
|
+
+ FuzzyOWL2Keyword.DEGREE_VALUE.get_value().suppress()
|
|
456
|
+
+ FuzzyOWL2Keyword.EQUAL.get_value().suppress()
|
|
457
|
+
+ numbers
|
|
458
|
+
+ slash
|
|
459
|
+
+ close_tag
|
|
460
|
+
+ common_end
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
gformula = comment_line | fuzzy_logic | concept | property | datatype | axiom
|
|
464
|
+
return gformula
|
|
465
|
+
|
|
466
|
+
@staticmethod
|
|
467
|
+
@utils.recursion_unlimited
|
|
468
|
+
def parse_string(
|
|
469
|
+
instring: str,
|
|
470
|
+
parse_all: bool = False,
|
|
471
|
+
*,
|
|
472
|
+
parseAll: bool = False,
|
|
473
|
+
) -> pp.ParseResults:
|
|
474
|
+
return FuzzyOwl2Parser.get_grammatics().parse_string(
|
|
475
|
+
instring, parse_all=parse_all, parseAll=parseAll
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
@staticmethod
|
|
479
|
+
def load_config(*args) -> None:
|
|
480
|
+
ConfigReader.load_parameters(os.path.join(os.getcwd(), "CONFIG.ini"), args)
|
|
481
|
+
|
|
482
|
+
@staticmethod
|
|
483
|
+
def main(annotation: str, *args) -> tuple[KnowledgeBase, list[Query]]:
|
|
484
|
+
try:
|
|
485
|
+
FuzzyOwl2Parser.load_config(*args)
|
|
486
|
+
return FuzzyOwl2Parser.parse_string(annotation)
|
|
487
|
+
except FileNotFoundError as e:
|
|
488
|
+
Util.error(f"Error: File {args[0]} not found.")
|
|
489
|
+
except Exception as e:
|
|
490
|
+
Util.error(e)
|
|
491
|
+
Util.error(traceback.format_exc())
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .constants import *
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import re
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import pyparsing as pp
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ConceptType(enum.StrEnum):
|
|
9
|
+
CHOQUET = enum.auto()
|
|
10
|
+
FUZZY_NOMINAL = enum.auto()
|
|
11
|
+
MODIFIED_CONCEPT = enum.auto()
|
|
12
|
+
OWA = enum.auto()
|
|
13
|
+
QUANTIFIED_OWA = enum.auto()
|
|
14
|
+
QUASI_SUGENO = enum.auto()
|
|
15
|
+
SUGENO = enum.auto()
|
|
16
|
+
WEIGHTED_CONCEPT = enum.auto()
|
|
17
|
+
WEIGHTED_MAX = enum.auto()
|
|
18
|
+
WEIGHTED_MIN = enum.auto()
|
|
19
|
+
WEIGHTED_SUM = enum.auto()
|
|
20
|
+
WEIGHTED_SUM_ZERO = enum.auto()
|
|
21
|
+
|
|
22
|
+
def __repr__(self) -> str:
|
|
23
|
+
return self.name
|
|
24
|
+
|
|
25
|
+
def __str__(self) -> str:
|
|
26
|
+
return self.name
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class FuzzyOWL2Keyword(enum.Enum):
|
|
30
|
+
OPEN_TAG = pp.Word("<")
|
|
31
|
+
CLOSE_TAG = pp.Word(">")
|
|
32
|
+
SINGLE_CLOSE_TAG = pp.Word("/>")
|
|
33
|
+
SLASH = pp.Word("/")
|
|
34
|
+
ONTOLOGY = pp.CaselessKeyword("ontology")
|
|
35
|
+
FUZZY_OWL_2 = pp.CaselessKeyword("fuzzyOwl2")
|
|
36
|
+
FUZZY_LABEL = pp.CaselessKeyword("fuzzyLabel")
|
|
37
|
+
FUZZY_TYPE = pp.CaselessKeyword("fuzzytype")
|
|
38
|
+
FUZZY_LOGIC = pp.CaselessKeyword("FuzzyLogic")
|
|
39
|
+
TYPE = pp.CaselessKeyword("type")
|
|
40
|
+
LOGIC = pp.CaselessKeyword("logic")
|
|
41
|
+
DATATYPE = pp.CaselessKeyword("datatype")
|
|
42
|
+
CONCEPT = pp.CaselessKeyword("concept")
|
|
43
|
+
ROLE = pp.CaselessKeyword("role")
|
|
44
|
+
AXIOM = pp.CaselessKeyword("axiom")
|
|
45
|
+
DEGREE_DEF = pp.CaselessKeyword("degree")
|
|
46
|
+
DEGREE_VALUE = pp.CaselessKeyword("value")
|
|
47
|
+
MODIFIED = pp.CaselessKeyword("modified")
|
|
48
|
+
WEIGHTED = pp.CaselessKeyword("weighted")
|
|
49
|
+
NOMINAL = pp.CaselessKeyword("nominal")
|
|
50
|
+
INDIVIDUAL = pp.CaselessKeyword("individual")
|
|
51
|
+
WEIGHTED_MAXIMUM = pp.CaselessKeyword("weightedMaximum")
|
|
52
|
+
WEIGHTED_MINIMUM = pp.CaselessKeyword("weightedMinimum")
|
|
53
|
+
WEIGHTED_SUM = pp.CaselessKeyword("weightedSum")
|
|
54
|
+
WEIGHTED_SUMZERO = pp.CaselessKeyword("weightedSumZero")
|
|
55
|
+
OWA = pp.CaselessKeyword("owa")
|
|
56
|
+
Q_OWA = pp.CaselessKeyword("qowa")
|
|
57
|
+
CHOQUET = pp.CaselessKeyword("choquet")
|
|
58
|
+
SUGENO = pp.CaselessKeyword("sugeno")
|
|
59
|
+
QUASI_SUGENO = pp.CaselessKeyword("quasisugeno")
|
|
60
|
+
MODIFIER = pp.CaselessKeyword("modifier")
|
|
61
|
+
BASE = pp.CaselessKeyword("base")
|
|
62
|
+
CONCEPT_NAMES = pp.CaselessKeyword("names")
|
|
63
|
+
NAME = pp.CaselessKeyword("name")
|
|
64
|
+
WEIGHT = pp.CaselessKeyword("weight")
|
|
65
|
+
WEIGHTS = pp.CaselessKeyword("weights")
|
|
66
|
+
QUANTIFIER = pp.CaselessKeyword("quantifier")
|
|
67
|
+
CRISP = pp.CaselessKeyword("crisp")
|
|
68
|
+
LEFT_SHOULDER = pp.CaselessKeyword("leftshoulder")
|
|
69
|
+
RIGHT_SHOULDER = pp.CaselessKeyword("rightshoulder")
|
|
70
|
+
TRIANGULAR = pp.CaselessKeyword("triangular")
|
|
71
|
+
TRAPEZOIDAL = pp.CaselessKeyword("trapezoidal")
|
|
72
|
+
LINEAR = pp.CaselessKeyword("linear")
|
|
73
|
+
A = pp.CaselessKeyword("a")
|
|
74
|
+
B = pp.CaselessKeyword("b")
|
|
75
|
+
C = pp.CaselessKeyword("c")
|
|
76
|
+
D = pp.CaselessKeyword("d")
|
|
77
|
+
LUKASIEWICZ = pp.CaselessKeyword("lukasiewicz")
|
|
78
|
+
GOEDEL = pp.CaselessKeyword("goedel")
|
|
79
|
+
ZADEH = pp.CaselessKeyword("zadeh")
|
|
80
|
+
PRODUCT = pp.CaselessKeyword("product")
|
|
81
|
+
EQUAL = pp.Word("=")
|
|
82
|
+
LES = pp.CaselessKeyword("les")
|
|
83
|
+
LEQ = pp.CaselessKeyword("leq")
|
|
84
|
+
GEQ = pp.CaselessKeyword("geq")
|
|
85
|
+
GRE = pp.CaselessKeyword("gre")
|
|
86
|
+
|
|
87
|
+
def get_name(self) -> str:
|
|
88
|
+
return re.sub(r"[\"\']+", "", self.value.name.lower())
|
|
89
|
+
|
|
90
|
+
def get_value(self) -> typing.Union[pp.CaselessKeyword, pp.Word]:
|
|
91
|
+
return self.value
|
|
92
|
+
|
|
93
|
+
def get_str_value(self) -> str:
|
|
94
|
+
return str(self.value).replace('"', "").replace("'", "")
|
|
95
|
+
|
|
96
|
+
def get_tag_name(self) -> str:
|
|
97
|
+
return self.get_str_value().capitalize()
|
|
98
|
+
|
|
99
|
+
def __eq__(self, value: object) -> bool:
|
|
100
|
+
if isinstance(value, str):
|
|
101
|
+
return self.get_name() == value.lower()
|
|
102
|
+
elif isinstance(value, pp.CaselessKeyword):
|
|
103
|
+
return self.get_name() == value.name.lower()
|
|
104
|
+
elif isinstance(value, FuzzyOWL2Keyword):
|
|
105
|
+
return self.get_name() == value.get_name()
|
|
106
|
+
raise NotImplementedError
|
|
107
|
+
|
|
108
|
+
def __repr__(self) -> str:
|
|
109
|
+
return self.name
|
|
110
|
+
|
|
111
|
+
def __str__(self) -> str:
|
|
112
|
+
return self.name
|