fuzzy-dl-owl2 1.0.8__py3-none-any.whl → 1.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fuzzy_dl_owl2/fuzzydl/fuzzydl_to_owl2.py +190 -34
- fuzzy_dl_owl2/fuzzydl/knowledge_base.py +60 -78
- fuzzy_dl_owl2/fuzzydl/parser/dl_parser.py +1 -3
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2.py +75 -45
- fuzzy_dl_owl2/fuzzyowl2/fuzzyowl2_to_fuzzydl.py +73 -6
- fuzzy_dl_owl2/fuzzyowl2/owl_types/crisp_function.py +17 -0
- fuzzy_dl_owl2/fuzzyowl2/owl_types/fuzzy_nominal_concept.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/modified_concept.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/modified_function.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/modified_property.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_max_concept.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_min_concept.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_sum_concept.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/owl_types/weighted_sum_zero_concept.py +1 -1
- fuzzy_dl_owl2/fuzzyowl2/parser/owl2_xml_parser.py +8 -2
- {fuzzy_dl_owl2-1.0.8.dist-info → fuzzy_dl_owl2-1.0.10.dist-info}/METADATA +225 -192
- {fuzzy_dl_owl2-1.0.8.dist-info → fuzzy_dl_owl2-1.0.10.dist-info}/RECORD +19 -18
- {fuzzy_dl_owl2-1.0.8.dist-info → fuzzy_dl_owl2-1.0.10.dist-info}/WHEEL +1 -1
- {fuzzy_dl_owl2-1.0.8.dist-info → fuzzy_dl_owl2-1.0.10.dist-info/licenses}/LICENSE +0 -0
|
@@ -3,9 +3,11 @@ from __future__ import annotations
|
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
5
|
import typing
|
|
6
|
+
import urllib
|
|
7
|
+
import urllib.parse
|
|
6
8
|
from functools import partial
|
|
7
9
|
|
|
8
|
-
from rdflib import RDF, XSD, Literal, Namespace, URIRef
|
|
10
|
+
from rdflib import RDF, RDFS, XSD, Literal, Namespace, URIRef
|
|
9
11
|
|
|
10
12
|
from fuzzy_dl_owl2.fuzzydl.assertion.assertion import Assertion
|
|
11
13
|
from fuzzy_dl_owl2.fuzzydl.concept.all_some_concept import AllSomeConcept
|
|
@@ -61,6 +63,7 @@ from fuzzy_dl_owl2.fuzzydl.primitive_concept_definition import (
|
|
|
61
63
|
PrimitiveConceptDefinition,
|
|
62
64
|
)
|
|
63
65
|
from fuzzy_dl_owl2.fuzzydl.util import constants
|
|
66
|
+
from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
|
|
64
67
|
from fuzzy_dl_owl2.fuzzydl.util.constants import ConceptType, ConcreteFeatureType
|
|
65
68
|
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
66
69
|
from fuzzy_dl_owl2.fuzzyowl2.util.constants import FuzzyOWL2Keyword
|
|
@@ -129,8 +132,6 @@ from pyowl2.individual.named_individual import OWLNamedIndividual
|
|
|
129
132
|
from pyowl2.literal.literal import OWLLiteral
|
|
130
133
|
from pyowl2.ontology import OWLOntology
|
|
131
134
|
|
|
132
|
-
from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
|
|
133
|
-
|
|
134
135
|
|
|
135
136
|
# @utils.timer_decorator
|
|
136
137
|
class FuzzydlToOwl2:
|
|
@@ -143,10 +144,12 @@ class FuzzydlToOwl2:
|
|
|
143
144
|
# base_iri: str = "http://www.semanticweb.org/ontologies/fuzzydl_ontology.owl",
|
|
144
145
|
base_iri: str = "http://www.semanticweb.org/ontologies/fuzzydl_ontology#",
|
|
145
146
|
) -> None:
|
|
147
|
+
base_iri = urllib.parse.urlparse(base_iri).geturl().rstrip("/").rstrip("#")
|
|
148
|
+
|
|
146
149
|
self.num_classes: int = 0
|
|
147
150
|
self.kb, _ = DLParser.get_kb(input_file)
|
|
148
|
-
self.ontology_path: str = base_iri
|
|
149
|
-
self.ontology_iri: IRI = IRI(Namespace(URIRef(
|
|
151
|
+
self.ontology_path: str = f"{base_iri}#"
|
|
152
|
+
self.ontology_iri: IRI = IRI(Namespace(URIRef(self.ontology_path)))
|
|
150
153
|
self.ontology: OWLOntology = OWLOntology(
|
|
151
154
|
self.ontology_iri, OWL1_annotations=True
|
|
152
155
|
)
|
|
@@ -154,7 +157,19 @@ class FuzzydlToOwl2:
|
|
|
154
157
|
IRI(self.ontology_iri.namespace, ConfigReader.OWL_ANNOTATION_LABEL)
|
|
155
158
|
)
|
|
156
159
|
|
|
157
|
-
self.ontology.add_axiom(
|
|
160
|
+
self.ontology.add_axiom(
|
|
161
|
+
OWLDeclaration(
|
|
162
|
+
self.fuzzyLabel,
|
|
163
|
+
[
|
|
164
|
+
OWLAnnotation(
|
|
165
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
166
|
+
OWLLiteral(
|
|
167
|
+
Literal(ConfigReader.OWL_ANNOTATION_LABEL, lang="en")
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
],
|
|
171
|
+
)
|
|
172
|
+
)
|
|
158
173
|
|
|
159
174
|
self.concepts: dict[str, OWLClassExpression] = dict()
|
|
160
175
|
self.datatypes: dict[str, OWLDatatype] = dict()
|
|
@@ -162,9 +177,46 @@ class FuzzydlToOwl2:
|
|
|
162
177
|
self.input_FDL: str = input_file
|
|
163
178
|
self.output_FOWL: str = os.path.join(constants.RESULTS_PATH, output_file)
|
|
164
179
|
|
|
165
|
-
def iri(self, o: object) -> IRI:
|
|
180
|
+
def iri(self, o: object, iri_type: type = OWLClass) -> IRI:
|
|
166
181
|
"""Convert object to IRI string"""
|
|
167
|
-
|
|
182
|
+
namespace: URIRef = self.ontology_iri.namespace
|
|
183
|
+
if iri_type == OWLClass:
|
|
184
|
+
namespace = Namespace(f"{self.ontology_path[:-1]}/class#")
|
|
185
|
+
elif iri_type == OWLDataProperty:
|
|
186
|
+
namespace = Namespace(f"{self.ontology_path[:-1]}/data-property#")
|
|
187
|
+
elif iri_type == OWLObjectProperty:
|
|
188
|
+
namespace = Namespace(f"{self.ontology_path[:-1]}/object-property#")
|
|
189
|
+
elif iri_type == OWLNamedIndividual:
|
|
190
|
+
namespace = Namespace(f"{self.ontology_path[:-1]}/individual#")
|
|
191
|
+
elif iri_type == OWLDatatype:
|
|
192
|
+
namespace = Namespace(f"{self.ontology_path[:-1]}/datatype#")
|
|
193
|
+
elif iri_type == OWLAnnotationProperty:
|
|
194
|
+
namespace = Namespace(f"{self.ontology_path[:-1]}/annotation-property#")
|
|
195
|
+
return IRI(namespace, str(o))
|
|
196
|
+
|
|
197
|
+
def individual_iri(self, o: object) -> IRI:
|
|
198
|
+
"""Convert individual object to IRI string"""
|
|
199
|
+
return self.iri(o, OWLNamedIndividual)
|
|
200
|
+
|
|
201
|
+
def class_iri(self, o: object) -> IRI:
|
|
202
|
+
"""Convert class to IRI string"""
|
|
203
|
+
return self.iri(o, OWLClass)
|
|
204
|
+
|
|
205
|
+
def data_property_iri(self, o: object) -> IRI:
|
|
206
|
+
"""Convert data property to IRI string"""
|
|
207
|
+
return self.iri(o, OWLDataProperty)
|
|
208
|
+
|
|
209
|
+
def object_property_iri(self, o: object) -> IRI:
|
|
210
|
+
"""Convert object property to IRI string"""
|
|
211
|
+
return self.iri(o, OWLObjectProperty)
|
|
212
|
+
|
|
213
|
+
def datatype_iri(self, o: object) -> IRI:
|
|
214
|
+
"""Convert datatype to IRI string"""
|
|
215
|
+
return self.iri(o, OWLDatatype)
|
|
216
|
+
|
|
217
|
+
def annotation_property_iri(self, o: object) -> IRI:
|
|
218
|
+
"""Convert datatype to IRI string"""
|
|
219
|
+
return self.iri(o, OWLAnnotationProperty)
|
|
168
220
|
|
|
169
221
|
def get_base(self, c: Concept) -> OWLClassExpression:
|
|
170
222
|
"""Get the base class for a concept"""
|
|
@@ -189,8 +241,18 @@ class FuzzydlToOwl2:
|
|
|
189
241
|
|
|
190
242
|
def __get_class_1(self, name: str) -> OWLClassExpression:
|
|
191
243
|
"""Get or create an OWL class by name"""
|
|
192
|
-
cls = OWLClass(self.
|
|
193
|
-
self.ontology.add_axiom(
|
|
244
|
+
cls = OWLClass(self.class_iri(name))
|
|
245
|
+
self.ontology.add_axiom(
|
|
246
|
+
OWLDeclaration(
|
|
247
|
+
cls,
|
|
248
|
+
[
|
|
249
|
+
OWLAnnotation(
|
|
250
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
251
|
+
OWLLiteral(Literal(name, lang="en")),
|
|
252
|
+
)
|
|
253
|
+
],
|
|
254
|
+
)
|
|
255
|
+
)
|
|
194
256
|
return cls
|
|
195
257
|
|
|
196
258
|
def __get_class_2(self, c: Concept) -> OWLClassExpression:
|
|
@@ -199,7 +261,17 @@ class FuzzydlToOwl2:
|
|
|
199
261
|
c_type: ConceptType = c.type
|
|
200
262
|
if c_type in (ConceptType.ATOMIC, ConceptType.CONCRETE):
|
|
201
263
|
cls = self.get_class(str(c))
|
|
202
|
-
self.ontology.add_axiom(
|
|
264
|
+
self.ontology.add_axiom(
|
|
265
|
+
OWLDeclaration(
|
|
266
|
+
cls,
|
|
267
|
+
[
|
|
268
|
+
OWLAnnotation(
|
|
269
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
270
|
+
OWLLiteral(Literal(str(c), lang="en")),
|
|
271
|
+
)
|
|
272
|
+
],
|
|
273
|
+
)
|
|
274
|
+
)
|
|
203
275
|
return cls
|
|
204
276
|
elif c_type == ConceptType.TOP:
|
|
205
277
|
return OWLClass.thing()
|
|
@@ -277,17 +349,16 @@ class FuzzydlToOwl2:
|
|
|
277
349
|
if str(c) in self.concepts:
|
|
278
350
|
return self.concepts.get(str(c))
|
|
279
351
|
c4: OWLClassExpression = self.get_new_atomic_class(str(c))
|
|
280
|
-
c3: OWLClassExpression = self.get_base(c.
|
|
352
|
+
c3: OWLClassExpression = self.get_base(c.curr_concept)
|
|
281
353
|
self.concepts[str(c)] = c3
|
|
282
|
-
|
|
283
354
|
main_xml = FuzzyXML.build_main_xml(FuzzyOWL2Keyword.CONCEPT.get_str_value())
|
|
284
355
|
concept_xml = FuzzyXML.build_concept_xml(
|
|
285
356
|
FuzzyOWL2Keyword.MODIFIED.get_str_value(),
|
|
286
357
|
{
|
|
287
358
|
FuzzyOWL2Keyword.MODIFIER.get_str_value(): str(
|
|
288
|
-
self.modifiers[str(c)]
|
|
359
|
+
self.modifiers[str(c.modifier)].iri.value
|
|
289
360
|
),
|
|
290
|
-
FuzzyOWL2Keyword.BASE.get_str_value(): str(c3),
|
|
361
|
+
FuzzyOWL2Keyword.BASE.get_str_value(): str(c3.iri.value),
|
|
291
362
|
},
|
|
292
363
|
)
|
|
293
364
|
main_xml.append(concept_xml)
|
|
@@ -346,14 +417,14 @@ class FuzzydlToOwl2:
|
|
|
346
417
|
elif c_type == ConceptType.WEIGHTED:
|
|
347
418
|
c: WeightedConcept = typing.cast(WeightedConcept, c)
|
|
348
419
|
c4: OWLClassExpression = self.get_new_atomic_class(str(c))
|
|
349
|
-
c3: OWLClassExpression = self.get_base(c.
|
|
420
|
+
c3: OWLClassExpression = self.get_base(c.curr_concept)
|
|
350
421
|
|
|
351
422
|
main_xml = FuzzyXML.build_main_xml(FuzzyOWL2Keyword.CONCEPT.get_str_value())
|
|
352
423
|
concept_xml = FuzzyXML.build_concept_xml(
|
|
353
424
|
FuzzyOWL2Keyword.WEIGHTED.get_str_value(),
|
|
354
425
|
{
|
|
355
426
|
FuzzyOWL2Keyword.DEGREE_VALUE.get_str_value(): str(c.weight),
|
|
356
|
-
FuzzyOWL2Keyword.BASE.get_str_value(): str(c3),
|
|
427
|
+
FuzzyOWL2Keyword.BASE.get_str_value(): str(c3.iri.value),
|
|
357
428
|
},
|
|
358
429
|
)
|
|
359
430
|
main_xml.append(concept_xml)
|
|
@@ -382,8 +453,18 @@ class FuzzydlToOwl2:
|
|
|
382
453
|
return self.__get_class_weighted(c)
|
|
383
454
|
elif c_type == ConceptType.QUANTIFIED_OWA:
|
|
384
455
|
return self.__get_class_q_owa(c)
|
|
385
|
-
cls = OWLClass(self.
|
|
386
|
-
self.ontology.add_axiom(
|
|
456
|
+
cls = OWLClass(self.class_iri(str(c)))
|
|
457
|
+
self.ontology.add_axiom(
|
|
458
|
+
OWLDeclaration(
|
|
459
|
+
cls,
|
|
460
|
+
[
|
|
461
|
+
OWLAnnotation(
|
|
462
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
463
|
+
OWLLiteral(Literal(str(c), lang="en")),
|
|
464
|
+
)
|
|
465
|
+
],
|
|
466
|
+
)
|
|
467
|
+
)
|
|
387
468
|
return cls
|
|
388
469
|
|
|
389
470
|
def __get_class_weighted_min_max_sum(self, c: Concept) -> OWLClassExpression:
|
|
@@ -415,7 +496,7 @@ class FuzzydlToOwl2:
|
|
|
415
496
|
FuzzyOWL2Keyword.DEGREE_VALUE.get_str_value(): str(
|
|
416
497
|
curr_concept.weights[i]
|
|
417
498
|
),
|
|
418
|
-
FuzzyOWL2Keyword.BASE.get_str_value(): str(c5),
|
|
499
|
+
FuzzyOWL2Keyword.BASE.get_str_value(): str(c5.iri.value),
|
|
419
500
|
},
|
|
420
501
|
)
|
|
421
502
|
concept_xml.append(sub_concept_xml)
|
|
@@ -528,14 +609,24 @@ class FuzzydlToOwl2:
|
|
|
528
609
|
|
|
529
610
|
self.num_classes += 1
|
|
530
611
|
Util.debug(f"Creating new atomic concept -> {name}")
|
|
531
|
-
c2: OWLClass = OWLClass(self.
|
|
612
|
+
c2: OWLClass = OWLClass(self.class_iri(f"class__{self.num_classes}"))
|
|
532
613
|
self.concepts[name] = c2
|
|
533
|
-
self.ontology.add_axiom(
|
|
614
|
+
self.ontology.add_axiom(
|
|
615
|
+
OWLDeclaration(
|
|
616
|
+
c2,
|
|
617
|
+
[
|
|
618
|
+
OWLAnnotation(
|
|
619
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
620
|
+
OWLLiteral(Literal(name, lang="en")),
|
|
621
|
+
)
|
|
622
|
+
],
|
|
623
|
+
)
|
|
624
|
+
)
|
|
534
625
|
return c2
|
|
535
626
|
|
|
536
627
|
def exist_object_property(self, role: str) -> bool:
|
|
537
628
|
"""Check if an object property exists"""
|
|
538
|
-
iri: IRI = self.
|
|
629
|
+
iri: IRI = self.object_property_iri(role)
|
|
539
630
|
return self.ontology.getter.exists_object_property(iri.to_uriref())
|
|
540
631
|
# return any(
|
|
541
632
|
# typing.cast(OWLObjectProperty, typing.cast(OWLDeclaration, prop).entity).iri
|
|
@@ -545,7 +636,7 @@ class FuzzydlToOwl2:
|
|
|
545
636
|
|
|
546
637
|
def exist_data_property(self, role: str) -> bool:
|
|
547
638
|
"""Check if a data property exists"""
|
|
548
|
-
iri: IRI = self.
|
|
639
|
+
iri: IRI = self.data_property_iri(role)
|
|
549
640
|
return self.ontology.getter.exists_data_property(iri.to_uriref())
|
|
550
641
|
# return any(
|
|
551
642
|
# typing.cast(OWLDataProperty, typing.cast(OWLDeclaration, prop).entity).iri
|
|
@@ -560,8 +651,18 @@ class FuzzydlToOwl2:
|
|
|
560
651
|
Util.debug(f"Getting object property -> {role}")
|
|
561
652
|
if self.exist_data_property(role):
|
|
562
653
|
return self.get_data_property(role)
|
|
563
|
-
obj = OWLObjectProperty(self.
|
|
564
|
-
self.ontology.add_axiom(
|
|
654
|
+
obj = OWLObjectProperty(self.object_property_iri(role))
|
|
655
|
+
self.ontology.add_axiom(
|
|
656
|
+
OWLDeclaration(
|
|
657
|
+
obj,
|
|
658
|
+
[
|
|
659
|
+
OWLAnnotation(
|
|
660
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
661
|
+
OWLLiteral(Literal(role, lang="en")),
|
|
662
|
+
)
|
|
663
|
+
],
|
|
664
|
+
)
|
|
665
|
+
)
|
|
565
666
|
return obj
|
|
566
667
|
|
|
567
668
|
def get_data_property(
|
|
@@ -571,15 +672,35 @@ class FuzzydlToOwl2:
|
|
|
571
672
|
Util.debug(f"Getting data property -> {role}")
|
|
572
673
|
if self.exist_object_property(role):
|
|
573
674
|
return self.get_object_property(role)
|
|
574
|
-
data = OWLDataProperty(self.
|
|
575
|
-
self.ontology.add_axiom(
|
|
675
|
+
data = OWLDataProperty(self.data_property_iri(role))
|
|
676
|
+
self.ontology.add_axiom(
|
|
677
|
+
OWLDeclaration(
|
|
678
|
+
data,
|
|
679
|
+
[
|
|
680
|
+
OWLAnnotation(
|
|
681
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
682
|
+
OWLLiteral(Literal(role, lang="en")),
|
|
683
|
+
)
|
|
684
|
+
],
|
|
685
|
+
)
|
|
686
|
+
)
|
|
576
687
|
return data
|
|
577
688
|
|
|
578
689
|
def get_individual(self, name: str) -> OWLNamedIndividual:
|
|
579
690
|
"""Get or create a named individual"""
|
|
580
691
|
Util.debug(f"Getting individual -> {name}")
|
|
581
|
-
ind = OWLNamedIndividual(self.
|
|
582
|
-
self.ontology.add_axiom(
|
|
692
|
+
ind = OWLNamedIndividual(self.individual_iri(f"{name}"))
|
|
693
|
+
self.ontology.add_axiom(
|
|
694
|
+
OWLDeclaration(
|
|
695
|
+
ind,
|
|
696
|
+
[
|
|
697
|
+
OWLAnnotation(
|
|
698
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
699
|
+
OWLLiteral(Literal(name, lang="en")),
|
|
700
|
+
)
|
|
701
|
+
],
|
|
702
|
+
)
|
|
703
|
+
)
|
|
583
704
|
return ind
|
|
584
705
|
|
|
585
706
|
def to_owl_annotation(self, annotation: str) -> OWLAnnotation:
|
|
@@ -677,6 +798,21 @@ class FuzzydlToOwl2:
|
|
|
677
798
|
# )
|
|
678
799
|
self.add_ontology_annotation(annotation)
|
|
679
800
|
|
|
801
|
+
# Process atomic concepts
|
|
802
|
+
# TODO
|
|
803
|
+
for c in self.kb.atomic_concepts.values():
|
|
804
|
+
self.ontology.add_axiom(
|
|
805
|
+
OWLDeclaration(
|
|
806
|
+
self.get_class(str(c)),
|
|
807
|
+
[
|
|
808
|
+
OWLAnnotation(
|
|
809
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
810
|
+
OWLLiteral(Literal(str(c), lang="en")),
|
|
811
|
+
)
|
|
812
|
+
],
|
|
813
|
+
)
|
|
814
|
+
)
|
|
815
|
+
|
|
680
816
|
# Process concrete concepts
|
|
681
817
|
for c in self.kb.concrete_concepts.values():
|
|
682
818
|
self._process_concrete_concept(c)
|
|
@@ -890,7 +1026,7 @@ class FuzzydlToOwl2:
|
|
|
890
1026
|
def _process_concrete_concept(self, c: FuzzyConcreteConcept) -> None:
|
|
891
1027
|
"""Process a concrete concept"""
|
|
892
1028
|
Util.debug(f"Process concrete concept -> {c}")
|
|
893
|
-
current_datatype: OWLDatatype = OWLDatatype(self.
|
|
1029
|
+
current_datatype: OWLDatatype = OWLDatatype(self.datatype_iri(c))
|
|
894
1030
|
self.datatypes[str(c)] = current_datatype
|
|
895
1031
|
|
|
896
1032
|
# specific: str = self._get_concrete_concept_specifics(c)
|
|
@@ -921,7 +1057,17 @@ class FuzzydlToOwl2:
|
|
|
921
1057
|
definition: OWLDatatypeDefinition = OWLDatatypeDefinition(
|
|
922
1058
|
current_datatype, unit_interval
|
|
923
1059
|
)
|
|
924
|
-
self.ontology.add_axiom(
|
|
1060
|
+
self.ontology.add_axiom(
|
|
1061
|
+
OWLDeclaration(
|
|
1062
|
+
current_datatype,
|
|
1063
|
+
[
|
|
1064
|
+
OWLAnnotation(
|
|
1065
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
1066
|
+
OWLLiteral(Literal(str(c), lang="en")),
|
|
1067
|
+
)
|
|
1068
|
+
],
|
|
1069
|
+
)
|
|
1070
|
+
)
|
|
925
1071
|
self.ontology.add_axiom(definition)
|
|
926
1072
|
|
|
927
1073
|
main_xml = FuzzyXML.build_main_xml(FuzzyOWL2Keyword.DATATYPE.get_str_value())
|
|
@@ -1020,9 +1166,19 @@ class FuzzydlToOwl2:
|
|
|
1020
1166
|
main_xml.append(modifier_xml)
|
|
1021
1167
|
annotation: str = FuzzyXML.to_str(main_xml)
|
|
1022
1168
|
|
|
1023
|
-
current_datatype: OWLDatatype = OWLDatatype(self.
|
|
1169
|
+
current_datatype: OWLDatatype = OWLDatatype(self.datatype_iri(mod))
|
|
1024
1170
|
self.modifiers[str(mod)] = current_datatype
|
|
1025
|
-
self.ontology.add_axiom(
|
|
1171
|
+
self.ontology.add_axiom(
|
|
1172
|
+
OWLDeclaration(
|
|
1173
|
+
current_datatype,
|
|
1174
|
+
[
|
|
1175
|
+
OWLAnnotation(
|
|
1176
|
+
OWLAnnotationProperty(URIRef(RDFS.label)),
|
|
1177
|
+
OWLLiteral(Literal(str(mod), lang="en")),
|
|
1178
|
+
)
|
|
1179
|
+
],
|
|
1180
|
+
)
|
|
1181
|
+
)
|
|
1026
1182
|
self.add_entity_annotation(annotation, current_datatype)
|
|
1027
1183
|
|
|
1028
1184
|
def _process_assertion(self, ass: Assertion) -> None:
|
|
@@ -12,51 +12,43 @@ from sortedcontainers import SortedSet
|
|
|
12
12
|
from fuzzy_dl_owl2.fuzzydl.assertion.assertion import Assertion
|
|
13
13
|
from fuzzy_dl_owl2.fuzzydl.classification_node import ClassificationNode
|
|
14
14
|
from fuzzy_dl_owl2.fuzzydl.concept.all_some_concept import AllSomeConcept
|
|
15
|
-
from fuzzy_dl_owl2.fuzzydl.concept.approximation_concept import
|
|
15
|
+
from fuzzy_dl_owl2.fuzzydl.concept.approximation_concept import \
|
|
16
|
+
ApproximationConcept
|
|
16
17
|
from fuzzy_dl_owl2.fuzzydl.concept.atomic_concept import AtomicConcept
|
|
17
18
|
from fuzzy_dl_owl2.fuzzydl.concept.choquet_integral import ChoquetIntegral
|
|
18
19
|
from fuzzy_dl_owl2.fuzzydl.concept.concept import Concept
|
|
19
|
-
from fuzzy_dl_owl2.fuzzydl.concept.concrete.crisp_concrete_concept import
|
|
20
|
-
CrispConcreteConcept
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
from fuzzy_dl_owl2.fuzzydl.concept.concrete.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
from fuzzy_dl_owl2.fuzzydl.concept.concrete.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
from fuzzy_dl_owl2.fuzzydl.concept.
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
from fuzzy_dl_owl2.fuzzydl.concept.concrete.trapezoidal_concrete_concept import (
|
|
41
|
-
TrapezoidalConcreteConcept,
|
|
42
|
-
)
|
|
43
|
-
from fuzzy_dl_owl2.fuzzydl.concept.concrete.triangular_concrete_concept import (
|
|
44
|
-
TriangularConcreteConcept,
|
|
45
|
-
)
|
|
46
|
-
from fuzzy_dl_owl2.fuzzydl.concept.ext_threshold_concept import ExtThresholdConcept
|
|
20
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.crisp_concrete_concept import \
|
|
21
|
+
CrispConcreteConcept
|
|
22
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_concrete_concept import \
|
|
23
|
+
FuzzyConcreteConcept
|
|
24
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.fuzzy_number.triangular_fuzzy_number import \
|
|
25
|
+
TriangularFuzzyNumber
|
|
26
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.left_concrete_concept import \
|
|
27
|
+
LeftConcreteConcept
|
|
28
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.linear_concrete_concept import \
|
|
29
|
+
LinearConcreteConcept
|
|
30
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.modified_concrete_concept import \
|
|
31
|
+
ModifiedConcreteConcept
|
|
32
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.right_concrete_concept import \
|
|
33
|
+
RightConcreteConcept
|
|
34
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.trapezoidal_concrete_concept import \
|
|
35
|
+
TrapezoidalConcreteConcept
|
|
36
|
+
from fuzzy_dl_owl2.fuzzydl.concept.concrete.triangular_concrete_concept import \
|
|
37
|
+
TriangularConcreteConcept
|
|
38
|
+
from fuzzy_dl_owl2.fuzzydl.concept.ext_threshold_concept import \
|
|
39
|
+
ExtThresholdConcept
|
|
47
40
|
from fuzzy_dl_owl2.fuzzydl.concept.has_value_concept import HasValueConcept
|
|
48
41
|
from fuzzy_dl_owl2.fuzzydl.concept.implies_concept import ImpliesConcept
|
|
49
|
-
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_concepts_interface import
|
|
50
|
-
HasConceptsInterface
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_value_interface import
|
|
54
|
-
HasValueInterface
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
from fuzzy_dl_owl2.fuzzydl.concept.modified.triangularly_modified_concept import
|
|
58
|
-
TriangularlyModifiedConcept
|
|
59
|
-
)
|
|
42
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_concepts_interface import \
|
|
43
|
+
HasConceptsInterface
|
|
44
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_role_interface import \
|
|
45
|
+
HasRoleInterface
|
|
46
|
+
from fuzzy_dl_owl2.fuzzydl.concept.interface.has_value_interface import \
|
|
47
|
+
HasValueInterface
|
|
48
|
+
from fuzzy_dl_owl2.fuzzydl.concept.modified.modified_concept import \
|
|
49
|
+
ModifiedConcept
|
|
50
|
+
from fuzzy_dl_owl2.fuzzydl.concept.modified.triangularly_modified_concept import \
|
|
51
|
+
TriangularlyModifiedConcept
|
|
60
52
|
from fuzzy_dl_owl2.fuzzydl.concept.negated_nominal import NegatedNominal
|
|
61
53
|
from fuzzy_dl_owl2.fuzzydl.concept.operator_concept import OperatorConcept
|
|
62
54
|
from fuzzy_dl_owl2.fuzzydl.concept.owa_concept import OwaConcept
|
|
@@ -70,28 +62,30 @@ from fuzzy_dl_owl2.fuzzydl.concept.threshold_concept import ThresholdConcept
|
|
|
70
62
|
from fuzzy_dl_owl2.fuzzydl.concept.truth_concept import TruthConcept
|
|
71
63
|
from fuzzy_dl_owl2.fuzzydl.concept.value_concept import ValueConcept
|
|
72
64
|
from fuzzy_dl_owl2.fuzzydl.concept.weighted_concept import WeightedConcept
|
|
73
|
-
from fuzzy_dl_owl2.fuzzydl.concept.weighted_max_concept import
|
|
74
|
-
|
|
75
|
-
from fuzzy_dl_owl2.fuzzydl.concept.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
from fuzzy_dl_owl2.fuzzydl.concept.weighted_max_concept import \
|
|
66
|
+
WeightedMaxConcept
|
|
67
|
+
from fuzzy_dl_owl2.fuzzydl.concept.weighted_min_concept import \
|
|
68
|
+
WeightedMinConcept
|
|
69
|
+
from fuzzy_dl_owl2.fuzzydl.concept.weighted_sum_concept import \
|
|
70
|
+
WeightedSumConcept
|
|
71
|
+
from fuzzy_dl_owl2.fuzzydl.concept.weighted_sum_zero_concept import \
|
|
72
|
+
WeightedSumZeroConcept
|
|
79
73
|
from fuzzy_dl_owl2.fuzzydl.concept_equivalence import ConceptEquivalence
|
|
80
74
|
from fuzzy_dl_owl2.fuzzydl.concrete_feature import ConcreteFeature
|
|
81
75
|
from fuzzy_dl_owl2.fuzzydl.degree.degree import Degree
|
|
82
76
|
from fuzzy_dl_owl2.fuzzydl.degree.degree_expression import DegreeExpression
|
|
83
77
|
from fuzzy_dl_owl2.fuzzydl.degree.degree_numeric import DegreeNumeric
|
|
84
78
|
from fuzzy_dl_owl2.fuzzydl.degree.degree_variable import DegreeVariable
|
|
85
|
-
from fuzzy_dl_owl2.fuzzydl.exception.inconsistent_ontology_exception import
|
|
86
|
-
InconsistentOntologyException
|
|
87
|
-
)
|
|
79
|
+
from fuzzy_dl_owl2.fuzzydl.exception.inconsistent_ontology_exception import \
|
|
80
|
+
InconsistentOntologyException
|
|
88
81
|
from fuzzy_dl_owl2.fuzzydl.feature_function import FeatureFunction
|
|
89
|
-
from fuzzy_dl_owl2.fuzzydl.general_concept_inclusion import
|
|
90
|
-
|
|
82
|
+
from fuzzy_dl_owl2.fuzzydl.general_concept_inclusion import \
|
|
83
|
+
GeneralConceptInclusion
|
|
84
|
+
from fuzzy_dl_owl2.fuzzydl.individual.created_individual import \
|
|
85
|
+
CreatedIndividual
|
|
91
86
|
from fuzzy_dl_owl2.fuzzydl.individual.individual import Individual
|
|
92
|
-
from fuzzy_dl_owl2.fuzzydl.individual.representative_individual import
|
|
93
|
-
RepresentativeIndividual
|
|
94
|
-
)
|
|
87
|
+
from fuzzy_dl_owl2.fuzzydl.individual.representative_individual import \
|
|
88
|
+
RepresentativeIndividual
|
|
95
89
|
from fuzzy_dl_owl2.fuzzydl.milp.expression import Expression
|
|
96
90
|
from fuzzy_dl_owl2.fuzzydl.milp.milp_helper import MILPHelper
|
|
97
91
|
from fuzzy_dl_owl2.fuzzydl.milp.solution import Solution
|
|
@@ -99,29 +93,21 @@ from fuzzy_dl_owl2.fuzzydl.milp.term import Term
|
|
|
99
93
|
from fuzzy_dl_owl2.fuzzydl.milp.variable import Variable
|
|
100
94
|
from fuzzy_dl_owl2.fuzzydl.modifier.linear_modifier import LinearModifier
|
|
101
95
|
from fuzzy_dl_owl2.fuzzydl.modifier.modifier import Modifier
|
|
102
|
-
from fuzzy_dl_owl2.fuzzydl.modifier.triangular_modifier import
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
from fuzzy_dl_owl2.fuzzydl.modifier.triangular_modifier import \
|
|
97
|
+
TriangularModifier
|
|
98
|
+
from fuzzy_dl_owl2.fuzzydl.primitive_concept_definition import \
|
|
99
|
+
PrimitiveConceptDefinition
|
|
106
100
|
from fuzzy_dl_owl2.fuzzydl.relation import Relation
|
|
107
|
-
from fuzzy_dl_owl2.fuzzydl.restriction.has_value_restriction import
|
|
101
|
+
from fuzzy_dl_owl2.fuzzydl.restriction.has_value_restriction import \
|
|
102
|
+
HasValueRestriction
|
|
108
103
|
from fuzzy_dl_owl2.fuzzydl.restriction.restriction import Restriction
|
|
109
104
|
from fuzzy_dl_owl2.fuzzydl.util import constants
|
|
110
105
|
from fuzzy_dl_owl2.fuzzydl.util.config_reader import ConfigReader
|
|
111
106
|
from fuzzy_dl_owl2.fuzzydl.util.constants import (
|
|
112
|
-
BlockingDynamicType,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
FeatureFunctionType,
|
|
117
|
-
FuzzyLogic,
|
|
118
|
-
InequalityType,
|
|
119
|
-
KnowledgeBaseRules,
|
|
120
|
-
LogicOperatorType,
|
|
121
|
-
RepresentativeIndividualType,
|
|
122
|
-
RestrictionType,
|
|
123
|
-
VariableType,
|
|
124
|
-
)
|
|
107
|
+
BlockingDynamicType, ConceptType, ConcreteFeatureType,
|
|
108
|
+
CreatedIndividualBlockingType, FeatureFunctionType, FuzzyLogic,
|
|
109
|
+
InequalityType, KnowledgeBaseRules, LogicOperatorType,
|
|
110
|
+
RepresentativeIndividualType, RestrictionType, VariableType)
|
|
125
111
|
from fuzzy_dl_owl2.fuzzydl.util.util import Util
|
|
126
112
|
from fuzzy_dl_owl2.fuzzydl.util.utils import class_debugging
|
|
127
113
|
|
|
@@ -10139,7 +10125,7 @@ class CreatedIndividualHandler:
|
|
|
10139
10125
|
) -> bool:
|
|
10140
10126
|
"""
|
|
10141
10127
|
Gets if the individual is indirectly blocked with respect to a fuzzy KB.
|
|
10142
|
-
|
|
10128
|
+
Case SUBSET or SET blocking.
|
|
10143
10129
|
A node v is indirectly blocked iff one of its ancestors are blocked.
|
|
10144
10130
|
"""
|
|
10145
10131
|
# Don't test if not deep enough in completion forest
|
|
@@ -10353,11 +10339,7 @@ class CreatedIndividualHandler:
|
|
|
10353
10339
|
) -> bool:
|
|
10354
10340
|
"""
|
|
10355
10341
|
Gets if the individual is directly blocked with respect to a fuzzy KB.
|
|
10356
|
-
|
|
10357
|
-
A node v is directly blocked iff none of its ancestors are blocked
|
|
10358
|
-
and there exists an ancestor w such that
|
|
10359
|
-
L(v) = L(w),
|
|
10360
|
-
where L(*) is the set of Concept's labels for a node.
|
|
10342
|
+
A node v is directly blocked iff none of its ancestors are blocked and there exists an ancestor w such that L(v) = L(w), where L(*) is the set of Concept's labels for a node.
|
|
10361
10343
|
In this case we say that w directly blocks v.
|
|
10362
10344
|
"""
|
|
10363
10345
|
type: BlockingDynamicType = kb.blocking_type
|
|
@@ -525,9 +525,7 @@ class DLParser(object):
|
|
|
525
525
|
if f is None:
|
|
526
526
|
Util.error(f"Error: Fuzzy concept {f} has to be defined before being used.")
|
|
527
527
|
if not isinstance(f, (RightConcreteConcept, LeftConcreteConcept)):
|
|
528
|
-
Util.error(
|
|
529
|
-
f"Error: Fuzzy concept {f} has to be a right or a linear function."
|
|
530
|
-
)
|
|
528
|
+
Util.error(f"Error: Fuzzy concept {f} has to be a right or left functions.")
|
|
531
529
|
concepts: list[Concept] = [
|
|
532
530
|
DLParser._to_concept(concept) for concept in list_tokens[1:]
|
|
533
531
|
]
|