From 5206a30afca88071ee731371c1d770f9bd8e8109 Mon Sep 17 00:00:00 2001 From: Alkid Date: Mon, 2 Dec 2024 20:39:55 +0100 Subject: [PATCH] added mapping for OWLObjectInverseOf --- owlapy/owlapi_mapper.py | 12 ++++++++++-- tests/test_owlapi_mapper.py | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/owlapy/owlapi_mapper.py b/owlapy/owlapi_mapper.py index 541aefa..5a700ae 100644 --- a/owlapy/owlapi_mapper.py +++ b/owlapy/owlapi_mapper.py @@ -25,7 +25,7 @@ from owlapy.owl_individual import OWLNamedIndividual from owlapy.owl_literal import OWLLiteral from owlapy.owl_ontology import OWLOntologyID -from owlapy.owl_property import OWLObjectProperty, OWLDataProperty +from owlapy.owl_property import OWLObjectProperty, OWLDataProperty, OWLObjectInverseOf from owlapy.static_funcs import startJVM from owlapy.vocab import OWLFacet @@ -36,7 +36,7 @@ from java.util import ArrayList, List, Set, LinkedHashSet, Optional, Collections from java.util.stream import Stream from uk.ac.manchester.cs.owl.owlapi import (OWLClassImpl, OWLDataAllValuesFromImpl, OWL2DatatypeImpl, - OWLDataExactCardinalityImpl,OWLDataHasValueImpl, + OWLDataExactCardinalityImpl,OWLDataHasValueImpl, OWLObjectInverseOfImpl, OWLDataMaxCardinalityImpl, OWLDataUnionOfImpl, OWLDataMinCardinalityImpl, OWLDataSomeValuesFromImpl, OWLObjectAllValuesFromImpl, OWLObjectComplementOfImpl, @@ -218,6 +218,14 @@ def _(self, e): def _(self, e: OWLLiteralImplInteger): return OWLLiteral(int(str(e.getLiteral()))) + @map_.register + def _(self, e: OWLObjectInverseOf): + return init(e)(self.map_(e.get_named_property())) + + @map_.register + def _(self, e: OWLObjectInverseOfImpl): + return init(e)(self.map_(e.getNamedProperty())) + @map_.register(OWLDataIntersectionOf) @map_.register(OWLDataOneOf) @map_.register(OWLDataUnionOf) diff --git a/tests/test_owlapi_mapper.py b/tests/test_owlapi_mapper.py index 63ac38d..6224bfc 100644 --- a/tests/test_owlapi_mapper.py +++ b/tests/test_owlapi_mapper.py @@ -24,7 +24,7 @@ from owlapy.owl_datatype import OWLDatatype from owlapy.owl_individual import OWLNamedIndividual from owlapy.owl_literal import OWLLiteral, IntegerOWLDatatype, BooleanOWLDatatype, DoubleOWLDatatype -from owlapy.owl_property import OWLDataProperty, OWLObjectProperty +from owlapy.owl_property import OWLDataProperty, OWLObjectProperty, OWLObjectInverseOf from owlapy.owlapi_mapper import OWLAPIMapper from owlapy.providers import owl_datatype_min_inclusive_restriction from owlapy.vocab import OWLFacet @@ -83,7 +83,8 @@ def test_random_complex_ce_mapping(self): def test_entity_mapping(self): iri = IRI.create(self.test_ns + "test") - + ip = OWLObjectInverseOf(self.op) + self.assertEqual(ip, self.mapper.map_(self.mapper.map_(ip))) self.assertEqual(iri, self.mapper.map_(self.mapper.map_(iri))) self.assertEqual(self.i, self.mapper.map_(self.mapper.map_(self.i))) self.assertEqual(self.c, self.mapper.map_(self.mapper.map_(self.c)))