From 733d962f27631cfb41de7b47d1fcec35b439537b Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 9 Oct 2020 19:15:27 +0200 Subject: Simplify ProgramGenerator constructor If we pass the whole ontology there is no need to also provide the set of unsafe roles. --- src/main/scala/rsacomb/CanonicalModel.scala | 25 ++++++++++++++----------- src/main/scala/rsacomb/RDFoxUtil.scala | 15 +++++++++++---- src/main/scala/rsacomb/RSA.scala | 6 ++++++ src/main/scala/rsacomb/RSAOntology.scala | 2 +- 4 files changed, 32 insertions(+), 16 deletions(-) (limited to 'src/main/scala/rsacomb') diff --git a/src/main/scala/rsacomb/CanonicalModel.scala b/src/main/scala/rsacomb/CanonicalModel.scala index 95eb556..a248d61 100644 --- a/src/main/scala/rsacomb/CanonicalModel.scala +++ b/src/main/scala/rsacomb/CanonicalModel.scala @@ -18,15 +18,15 @@ import tech.oxfordsemantic.jrdfox.logic.{ Variable } import scala.collection.JavaConverters._ +import rsacomb.RSA._ object ProgramGenerator { def apply( ontology: OWLOntology, - term: Term, - unsafe: List[OWLObjectPropertyExpression] = List() + term: Term ): RDFoxAxiomConverter = - new ProgramGenerator(ontology, term, unsafe) + new ProgramGenerator(ontology, term) def generateRoleRules( roles: Set[OWLObjectProperty] @@ -74,10 +74,13 @@ object ProgramGenerator { class ProgramGenerator( ontology: OWLOntology, - term: Term, - unsafe: List[OWLObjectPropertyExpression] -) extends RDFoxAxiomConverter(term, unsafe, SkolemStrategy.None, RSASuffix.None) - with RSAOntology + term: Term +) extends RDFoxAxiomConverter( + term, + ontology.unsafeRoles, + SkolemStrategy.None, + RSASuffix.None + ) with RSAAxiom { import RDFoxUtil._ @@ -206,11 +209,11 @@ class ProgramGenerator( // TODO: get role in T5 axiom // Assuming one role here val role = axiom.objectPropertyExpressionsInSignature(0) - if (unsafe.contains(role)) { + if (ontology.unsafeRoles.contains(role)) { val visitor = new RDFoxAxiomConverter( term, - unsafe, + ontology.unsafeRoles, SkolemStrategy.Standard(axiom.toString), RSASuffix.Forward ) @@ -229,13 +232,13 @@ class ProgramGenerator( val varY = Variable.create("Y") val visitorF = new RDFoxAxiomConverter( term, - unsafe, + ontology.unsafeRoles, SkolemStrategy.None, RSASuffix.Forward ) val visitorB = new RDFoxAxiomConverter( term, - unsafe, + ontology.unsafeRoles, SkolemStrategy.None, RSASuffix.Backward ) diff --git a/src/main/scala/rsacomb/RDFoxUtil.scala b/src/main/scala/rsacomb/RDFoxUtil.scala index b523d4e..8a144c6 100644 --- a/src/main/scala/rsacomb/RDFoxUtil.scala +++ b/src/main/scala/rsacomb/RDFoxUtil.scala @@ -12,14 +12,21 @@ import tech.oxfordsemantic.jrdfox.client.{ } import tech.oxfordsemantic.jrdfox.formats.SPARQLParser +import tech.oxfordsemantic.jrdfox.logic.{IRI => RDFox_IRI} +import org.semanticweb.owlapi.model.{IRI => OWL_IRI} + object RDFoxUtil { - implicit def owlapi2rdfox(iri: org.semanticweb.owlapi.model.IRI): IRI = { - IRI.create(iri.getIRIString()) + implicit def rdfox2owlapi(iri: RDFox_IRI): OWL_IRI = { + OWL_IRI.create(iri.getIRI) + } + + implicit def owlapi2rdfox(iri: OWL_IRI): RDFox_IRI = { + RDFox_IRI.create(iri.getIRIString()) } - implicit def owlapi2rdfox(iri: String): IRI = { - IRI.create(iri) + implicit def owlapi2rdfox(iri: String): RDFox_IRI = { + RDFox_IRI.create(iri) } def openConnection( diff --git a/src/main/scala/rsacomb/RSA.scala b/src/main/scala/rsacomb/RSA.scala index edabc6a..01982fc 100644 --- a/src/main/scala/rsacomb/RSA.scala +++ b/src/main/scala/rsacomb/RSA.scala @@ -39,6 +39,12 @@ object RSA extends RSAOntology { Variable.create(f"I$counter%03d") } + def base(name: Any): IRI = + IRI.create( + Prefixes.getPrefixIRIsByPrefixName.get(":").getIRI + + name.toString + ) + def internal(name: Any): IRI = IRI.create( Prefixes.getPrefixIRIsByPrefixName.get("internal:").getIRI diff --git a/src/main/scala/rsacomb/RSAOntology.scala b/src/main/scala/rsacomb/RSAOntology.scala index e4348d8..05b6218 100644 --- a/src/main/scala/rsacomb/RSAOntology.scala +++ b/src/main/scala/rsacomb/RSAOntology.scala @@ -216,7 +216,7 @@ trait RSAOntology { .toList val axioms = tbox ++ rbox val varX = Variable.create("X") - val visitor = ProgramGenerator(ontology, varX, unsafeRoles) + val visitor = ProgramGenerator(ontology, varX) val facts = ProgramGenerator.NIs(individuals) val rules1 = ProgramGenerator.generateRoleRules( axioms -- cgit v1.2.3