aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2020-11-27 10:29:04 +0000
committerFederico Igne <federico.igne@cs.ox.ac.uk>2020-11-27 10:29:04 +0000
commit6f4dda8c71e600ef55b8f6f90977d128481e3520 (patch)
tree8279bcf43ada4f0515496ed0af21c699835c0889 /src/main/scala/uk/ac/ox
parent8bd3b5275a6d81f35cfd561e290156e9e8ecb6d5 (diff)
downloadRSAComb-6f4dda8c71e600ef55b8f6f90977d128481e3520.tar.gz
RSAComb-6f4dda8c71e600ef55b8f6f90977d128481e3520.zip
Add support for data property domain axioms
Also reintroduce data property axioms in LUBM
Diffstat (limited to 'src/main/scala/uk/ac/ox')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxAxiomConverter.scala3
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxClassExprConverter.scala41
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxPropertyExprConverter.scala12
3 files changed, 55 insertions, 1 deletions
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(
109 List(Rule.create(range.res, range.ext ::: prop)) 109 List(Rule.create(range.res, range.ext ::: prop))
110 } 110 }
111 111
112 override def visit(axiom: OWLDataPropertyDomainAxiom): List[Rule] =
113 axiom.asOWLSubClassOfAxiom.accept(this)
114
112 override def visit(axiom: OWLInverseObjectPropertiesAxiom): List[Rule] = 115 override def visit(axiom: OWLInverseObjectPropertiesAxiom): List[Rule] =
113 axiom.asSubObjectPropertyOfAxioms.asScala.toList.flatMap(_.accept(this)) 116 axiom.asSubObjectPropertyOfAxioms.asScala.toList.flatMap(_.accept(this))
114 117
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.{
7 OWLClassExpression, 7 OWLClassExpression,
8 OWLClass, 8 OWLClass,
9 OWLObjectSomeValuesFrom, 9 OWLObjectSomeValuesFrom,
10 OWLDataSomeValuesFrom,
10 OWLObjectIntersectionOf, 11 OWLObjectIntersectionOf,
11 OWLObjectOneOf, 12 OWLObjectOneOf,
12 OWLObjectMaxCardinality 13 OWLObjectMaxCardinality
@@ -133,6 +134,46 @@ class RDFoxClassExprConverter(
133 ) 134 )
134 } 135 }
135 136
137 /** Converts a [[org.semanticweb.owlapi.model.OWLDataSomeValuesFrom OWLDataSomeValuesFrom]]
138 *
139 * @note we assume the expression is "simple", meaning that the
140 * property involved is a role name or the inverse of a role name.
141 * This assumption will be lifted when we will deal with the
142 * normalization of the input ontology.
143 *
144 * @todo the "filler" of this OWL expression is currently ignored. We
145 * need to find a way (if any) to handle
146 * [[org.semanticweb.owlapi.model.OWLDataRange OWLDataRange]]
147 * in RDFox.
148 */
149 override def visit(expr: OWLDataSomeValuesFrom): RDFoxRuleShards = {
150 val y = RSAOntology.genFreshVariable()
151 val prop = expr.getProperty()
152 // Computes the result of rule skolemization. Depending on the used
153 // technique it might involve the introduction of additional atoms,
154 // and/or fresh constants and variables.
155 val (head, body, term1) = skolem match {
156 case SkolemStrategy.None => (List(), List(), y)
157 case SkolemStrategy.Constant(c) => (List(), List(), c)
158 case SkolemStrategy.ConstantRSA(c) => {
159 if (unsafe.contains(prop))
160 (List(RSA.PE(term, c), RSA.U(c)), List(), c)
161 else
162 (List(), List(), c)
163 }
164 case SkolemStrategy.Standard(f) => {
165 (
166 List(),
167 List(BindAtom.create(FunctionCall.create("SKOLEM", f, term), y)),
168 y
169 )
170 }
171 }
172 val propertyVisitor = new RDFoxPropertyExprConverter(term, term1, suffix)
173 val propertyResult = expr.getProperty.accept(propertyVisitor)
174 RDFoxRuleShards(head ::: propertyResult, body)
175 }
176
136 // OWLObjectMaxCardinality 177 // OWLObjectMaxCardinality
137 override def visit(expr: OWLObjectMaxCardinality): RDFoxRuleShards = { 178 override def visit(expr: OWLObjectMaxCardinality): RDFoxRuleShards = {
138 // TODO: again, no hardcoded variables 179 // 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 @@
1package uk.ac.ox.cs.rsacomb.converter 1package uk.ac.ox.cs.rsacomb.converter
2 2
3import org.semanticweb.owlapi.model.{OWLPropertyExpression, OWLObjectProperty} 3import org.semanticweb.owlapi.model.{
4 OWLPropertyExpression,
5 OWLObjectProperty,
6 OWLDataProperty
7}
4import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitorEx 8import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitorEx
5 9
6import tech.oxfordsemantic.jrdfox.logic.datalog.TupleTableAtom 10import tech.oxfordsemantic.jrdfox.logic.datalog.TupleTableAtom
@@ -25,6 +29,12 @@ class RDFoxPropertyExprConverter(
25 List(TupleTableAtom.rdf(term1, pred, term2)) 29 List(TupleTableAtom.rdf(term1, pred, term2))
26 } 30 }
27 31
32 override def visit(expr: OWLDataProperty): List[TupleTableAtom] = {
33 val base = expr.getIRI.getIRIString
34 val pred = IRI.create(base :: suffix)
35 List(TupleTableAtom.rdf(term1, pred, term2))
36 }
37
28 override def visit(expr: OWLObjectInverseOf): List[TupleTableAtom] = { 38 override def visit(expr: OWLObjectInverseOf): List[TupleTableAtom] = {
29 val visitor = new RDFoxPropertyExprConverter(term1, term2, suffix + Inverse) 39 val visitor = new RDFoxPropertyExprConverter(term1, term2, suffix + Inverse)
30 expr.getInverse.accept(visitor) 40 expr.getInverse.accept(visitor)