From 6bd0b51aade6ad82dfa4e4d9c78db347bcaaa3a2 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Mon, 7 Dec 2020 20:04:15 +0000 Subject: Fix bug for data property translation --- src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala index 6c83caf..6193296 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxConverter.scala @@ -225,7 +225,7 @@ trait RDFoxConverter { * @see [[org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom OWLDataPropertyAssertionAxiom]] */ case a: OWLDataPropertyAssertionAxiom => - if (!a.getSubject.isNamed || !a.getObject.isNamed) + if (!a.getSubject.isNamed) Result() else { val subj = a.getSubject.asOWLNamedIndividual.getIRI -- cgit v1.2.3 From c3ff5305c30cdf31755972df4c3dc554d5246ae9 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Tue, 8 Dec 2020 12:22:56 +0000 Subject: Include literals in instances of `Named` internal predicate --- src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala | 12 ++++++++++-- .../uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala | 12 +++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala index 7b4b142..0fb6c96 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala @@ -11,6 +11,7 @@ import org.semanticweb.owlapi.model.{OWLOntology, OWLAxiom, OWLLogicalAxiom} import org.semanticweb.owlapi.model.{ OWLClass, OWLClassExpression, + OWLDataPropertyAssertionAxiom, OWLObjectProperty, OWLSubObjectPropertyOfAxiom, OWLObjectPropertyExpression, @@ -35,7 +36,8 @@ import tech.oxfordsemantic.jrdfox.logic.expression.{ Term, Variable, IRI, - Resource + Resource, + Literal } import tech.oxfordsemantic.jrdfox.logic.sparql.statement.SelectQuery @@ -117,6 +119,12 @@ class RSAOntology(val ontology: OWLOntology) { .map(implicits.RDFox.owlapiToRdfoxIri) .toList + val literals: List[Literal] = + abox + .collect { case a: OWLDataPropertyAssertionAxiom => a } + .map(_.getObject) + .map(implicits.RDFox.owlapiToRdfoxLiteral) + val concepts: List[OWLClass] = ontology.getClassesInSignature().asScala.toList @@ -288,7 +296,7 @@ class RSAOntology(val ontology: OWLOntology) { } def filteringProgram(query: ConjunctiveQuery): FilteringProgram = - new FilteringProgram(query, individuals) + new FilteringProgram(query, individuals ++ literals) lazy val canonicalModel = new CanonicalModel(this) diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala index 327ae8e..3db5500 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/sparql/ConjunctiveQueryAnswers.scala @@ -1,6 +1,11 @@ package uk.ac.ox.cs.rsacomb.sparql -import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Resource, Variable} +import tech.oxfordsemantic.jrdfox.logic.expression.{ + IRI, + Literal, + Resource, + Variable +} /** A collections of answers to a query. * @@ -27,8 +32,9 @@ class ConjunctiveQueryAnswers( val header = variables map (_.getName) mkString "\t" val body = answers .map(_.map { - case x: IRI => x.getIRI - case x => x.toString + case x: IRI => x.getIRI + case x: Literal => x.getLexicalForm + case x => x.toString }.mkString("\t")) .mkString("\n") s"$header\n$body" -- cgit v1.2.3 From f8e612288f3a604ee1bd60016b7320f00b763e6b Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Tue, 8 Dec 2020 13:16:30 +0000 Subject: Fix bug for OWLObjectSubPropertyOfAxiom A version of the rule with an empty suffix was missing. Note that this is not completely clear from the paper. --- src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala index c605e51..5001c8a 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/CanonicalModel.scala @@ -247,11 +247,10 @@ class CanonicalModel(val ontology: RSAOntology) { } case a: OWLSubObjectPropertyOfAxiom => { - val (factsF, rulesF) = - super.convert(a, term, unsafe, NoSkolem, Forward) - val (factsB, rulesB) = - super.convert(a, term, unsafe, NoSkolem, Backward) - (factsF ::: factsB, rulesF ::: rulesB) + val (facts, rules) = List(Empty, Forward, Backward) + .map(super.convert(a, term, unsafe, NoSkolem, _)) + .unzip + (facts.flatten, rules.flatten) } case a => super.convert(a, term, unsafe, skolem, suffix) -- cgit v1.2.3