Skip to content

Commit

Permalink
Merge pull request #122 from dice-group/owlapi_mapper_tests
Browse files Browse the repository at this point in the history
Added mapping for OWLObjectInverseOf
  • Loading branch information
Demirrr authored Dec 2, 2024
2 parents 5bb557a + c753328 commit e4f59b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions owlapy/owlapi_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_owlapi_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down

0 comments on commit e4f59b7

Please sign in to comment.