diff options
4 files changed, 116 insertions, 62 deletions
diff --git a/examples/lubm/univ-bench.ttl b/examples/lubm/univ-bench.ttl index 94241cc..346cd0d 100644 --- a/examples/lubm/univ-bench.ttl +++ b/examples/lubm/univ-bench.ttl | |||
@@ -324,67 +324,67 @@ | |||
324 | ################################################################# | 324 | ################################################################# |
325 | 325 | ||
326 | 326 | ||
327 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#age | 327 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#age |
328 | # | 328 | |
329 | #:age rdf:type owl:DatatypeProperty ; | 329 | :age rdf:type owl:DatatypeProperty ; |
330 | # | 330 | |
331 | # rdfs:label "is age" ; | 331 | rdfs:label "is age" ; |
332 | # | 332 | |
333 | # rdfs:domain :Person . | 333 | rdfs:domain :Person . |
334 | # | 334 | |
335 | # | 335 | |
336 | # | 336 | |
337 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#emailAddress | 337 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#emailAddress |
338 | # | 338 | |
339 | #:emailAddress rdf:type owl:DatatypeProperty ; | 339 | :emailAddress rdf:type owl:DatatypeProperty ; |
340 | # | 340 | |
341 | # rdfs:label "can be reached at" ; | 341 | rdfs:label "can be reached at" ; |
342 | # | 342 | |
343 | # rdfs:domain :Person . | 343 | rdfs:domain :Person . |
344 | # | 344 | |
345 | # | 345 | |
346 | # | 346 | |
347 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#name | 347 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#name |
348 | # | 348 | |
349 | #:name rdf:type owl:DatatypeProperty ; | 349 | :name rdf:type owl:DatatypeProperty ; |
350 | # | 350 | |
351 | # rdfs:label "name" . | 351 | rdfs:label "name" . |
352 | # | 352 | |
353 | # | 353 | |
354 | # | 354 | |
355 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#officeNumber | 355 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#officeNumber |
356 | # | 356 | |
357 | #:officeNumber rdf:type owl:DatatypeProperty ; | 357 | :officeNumber rdf:type owl:DatatypeProperty ; |
358 | # | 358 | |
359 | # rdfs:label "office room No." . | 359 | rdfs:label "office room No." . |
360 | # | 360 | |
361 | # | 361 | |
362 | # | 362 | |
363 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#researchInterest | 363 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#researchInterest |
364 | # | 364 | |
365 | #:researchInterest rdf:type owl:DatatypeProperty ; | 365 | :researchInterest rdf:type owl:DatatypeProperty ; |
366 | # | 366 | |
367 | # rdfs:label "is researching" . | 367 | rdfs:label "is researching" . |
368 | # | 368 | |
369 | # | 369 | |
370 | # | 370 | |
371 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#telephone | 371 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#telephone |
372 | # | 372 | |
373 | #:telephone rdf:type owl:DatatypeProperty ; | 373 | :telephone rdf:type owl:DatatypeProperty ; |
374 | # | 374 | |
375 | # rdfs:label "telephone number" ; | 375 | rdfs:label "telephone number" ; |
376 | # | 376 | |
377 | # rdfs:domain :Person . | 377 | rdfs:domain :Person . |
378 | # | 378 | |
379 | # | 379 | |
380 | # | 380 | |
381 | #### http://swat.cse.lehigh.edu/onto/univ-bench.owl#title | 381 | ### http://swat.cse.lehigh.edu/onto/univ-bench.owl#title |
382 | # | 382 | |
383 | #:title rdf:type owl:DatatypeProperty ; | 383 | :title rdf:type owl:DatatypeProperty ; |
384 | # | 384 | |
385 | # rdfs:label "title" ; | 385 | rdfs:label "title" ; |
386 | # | 386 | |
387 | # rdfs:domain :Person . | 387 | rdfs:domain :Person . |
388 | 388 | ||
389 | 389 | ||
390 | 390 | ||
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 @@ | |||
1 | package uk.ac.ox.cs.rsacomb.converter | 1 | package uk.ac.ox.cs.rsacomb.converter |
2 | 2 | ||
3 | import org.semanticweb.owlapi.model.{OWLPropertyExpression, OWLObjectProperty} | 3 | import org.semanticweb.owlapi.model.{ |
4 | OWLPropertyExpression, | ||
5 | OWLObjectProperty, | ||
6 | OWLDataProperty | ||
7 | } | ||
4 | import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitorEx | 8 | import org.semanticweb.owlapi.model.OWLPropertyExpressionVisitorEx |
5 | 9 | ||
6 | import tech.oxfordsemantic.jrdfox.logic.datalog.TupleTableAtom | 10 | import 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) |