From 6f4dda8c71e600ef55b8f6f90977d128481e3520 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 27 Nov 2020 10:29:04 +0000 Subject: Add support for data property domain axioms Also reintroduce data property axioms in LUBM --- .../cs/rsacomb/converter/RDFoxAxiomConverter.scala | 3 ++ .../converter/RDFoxClassExprConverter.scala | 41 ++++++++++++++++++++++ .../converter/RDFoxPropertyExprConverter.scala | 12 ++++++- 3 files changed, 55 insertions(+), 1 deletion(-) (limited to 'src/main/scala') diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxAxiomConverter.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxAxiomConverter.scala index 6f85893..93d8f8c 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxAxiomConverter.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxAxiomConverter.scala @@ -109,6 +109,9 @@ class RDFoxAxiomConverter( List(Rule.create(range.res, range.ext ::: prop)) } + override def visit(axiom: OWLDataPropertyDomainAxiom): List[Rule] = + axiom.asOWLSubClassOfAxiom.accept(this) + override def visit(axiom: OWLInverseObjectPropertiesAxiom): List[Rule] = axiom.asSubObjectPropertyOfAxioms.asScala.toList.flatMap(_.accept(this)) diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxClassExprConverter.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxClassExprConverter.scala index c151c9a..9b7a004 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxClassExprConverter.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxClassExprConverter.scala @@ -7,6 +7,7 @@ import org.semanticweb.owlapi.model.{ OWLClassExpression, OWLClass, OWLObjectSomeValuesFrom, + OWLDataSomeValuesFrom, OWLObjectIntersectionOf, OWLObjectOneOf, OWLObjectMaxCardinality @@ -133,6 +134,46 @@ class RDFoxClassExprConverter( ) } + /** Converts a [[org.semanticweb.owlapi.model.OWLDataSomeValuesFrom OWLDataSomeValuesFrom]] + * + * @note we assume the expression is "simple", meaning that the + * property involved is a role name or the inverse of a role name. + * This assumption will be lifted when we will deal with the + * normalization of the input ontology. + * + * @todo the "filler" of this OWL expression is currently ignored. We + * need to find a way (if any) to handle + * [[org.semanticweb.owlapi.model.OWLDataRange OWLDataRange]] + * in RDFox. + */ + override def visit(expr: OWLDataSomeValuesFrom): RDFoxRuleShards = { + val y = RSAOntology.genFreshVariable() + val prop = expr.getProperty() + // Computes the result of rule skolemization. Depending on the used + // technique it might involve the introduction of additional atoms, + // and/or fresh constants and variables. + val (head, body, term1) = skolem match { + case SkolemStrategy.None => (List(), List(), y) + case SkolemStrategy.Constant(c) => (List(), List(), c) + case SkolemStrategy.ConstantRSA(c) => { + if (unsafe.contains(prop)) + (List(RSA.PE(term, c), RSA.U(c)), List(), c) + else + (List(), List(), c) + } + case SkolemStrategy.Standard(f) => { + ( + List(), + List(BindAtom.create(FunctionCall.create("SKOLEM", f, term), y)), + y + ) + } + } + val propertyVisitor = new RDFoxPropertyExprConverter(term, term1, suffix) + val propertyResult = expr.getProperty.accept(propertyVisitor) + RDFoxRuleShards(head ::: propertyResult, body) + } + // OWLObjectMaxCardinality override def visit(expr: OWLObjectMaxCardinality): RDFoxRuleShards = { // TODO: again, no hardcoded variables diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxPropertyExprConverter.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxPropertyExprConverter.scala index 94c7887..d5a7384 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxPropertyExprConverter.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxPropertyExprConverter.scala @@ -1,6 +1,10 @@ package uk.ac.ox.cs.rsacomb.converter -import org.semanticweb.owlapi.model.{OWLPropertyExpression, OWLObjectProperty} +import org.semanticweb.owlapi.model.{ + OWLPropertyExpression, + OWLObjectProperty, + OWLDataProperty +} import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitorEx import tech.oxfordsemantic.jrdfox.logic.datalog.TupleTableAtom @@ -25,6 +29,12 @@ class RDFoxPropertyExprConverter( List(TupleTableAtom.rdf(term1, pred, term2)) } + override def visit(expr: OWLDataProperty): List[TupleTableAtom] = { + val base = expr.getIRI.getIRIString + val pred = IRI.create(base :: suffix) + List(TupleTableAtom.rdf(term1, pred, term2)) + } + override def visit(expr: OWLObjectInverseOf): List[TupleTableAtom] = { val visitor = new RDFoxPropertyExprConverter(term1, term2, suffix + Inverse) expr.getInverse.accept(visitor) -- cgit v1.2.3