diff options
author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-26 18:46:47 +0000 |
---|---|---|
committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2020-11-26 18:46:47 +0000 |
commit | 51a43d32ec64f9b2382890b0a452be6920a3c900 (patch) | |
tree | 2bf01dcd229bd39409b78790b32b95e5bacc6f22 | |
parent | 33431758891fcc3e455fb292067114ca3a546507 (diff) | |
download | RSAComb-51a43d32ec64f9b2382890b0a452be6920a3c900.tar.gz RSAComb-51a43d32ec64f9b2382890b0a452be6920a3c900.zip |
Add ability to convert domain/range axioms for object properties
They have a straightforward translation into the supported normal form
proposed in the paper.
-rw-r--r-- | src/main/scala/uk/ac/ox/cs/rsacomb/converter/RDFoxAxiomConverter.scala | 32 |
1 files changed, 29 insertions, 3 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 a8d1ffd..6f85893 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 | |||
@@ -4,7 +4,12 @@ import org.semanticweb.owlapi.model.{ | |||
4 | OWLAxiom, | 4 | OWLAxiom, |
5 | OWLSubClassOfAxiom, | 5 | OWLSubClassOfAxiom, |
6 | OWLEquivalentClassesAxiom, | 6 | OWLEquivalentClassesAxiom, |
7 | OWLObjectPropertyExpression | 7 | OWLObjectPropertyExpression, |
8 | OWLObjectPropertyDomainAxiom, | ||
9 | OWLObjectPropertyRangeAxiom, | ||
10 | OWLDataPropertyDomainAxiom, | ||
11 | OWLDataPropertyRangeAxiom, | ||
12 | OWLInverseObjectPropertiesAxiom | ||
8 | } | 13 | } |
9 | import org.semanticweb.owlapi.model.OWLAxiomVisitorEx | 14 | import org.semanticweb.owlapi.model.OWLAxiomVisitorEx |
10 | 15 | ||
@@ -16,7 +21,7 @@ import tech.oxfordsemantic.jrdfox.logic.datalog.{ | |||
16 | } | 21 | } |
17 | import tech.oxfordsemantic.jrdfox.logic.expression.{ | 22 | import tech.oxfordsemantic.jrdfox.logic.expression.{ |
18 | Term, | 23 | Term, |
19 | IRI, | 24 | IRI => RDFoxIRI, |
20 | Variable, | 25 | Variable, |
21 | Literal | 26 | Literal |
22 | } | 27 | } |
@@ -29,6 +34,10 @@ import org.semanticweb.owlapi.model.OWLClassAssertionAxiom | |||
29 | 34 | ||
30 | import uk.ac.ox.cs.rsacomb.RSAOntology | 35 | import uk.ac.ox.cs.rsacomb.RSAOntology |
31 | import uk.ac.ox.cs.rsacomb.suffix.{RSASuffix, Empty} | 36 | import uk.ac.ox.cs.rsacomb.suffix.{RSASuffix, Empty} |
37 | import uk.ac.manchester.cs.owl.owlapi.OWLSubClassOfAxiomImpl | ||
38 | import uk.ac.manchester.cs.owl.owlapi.OWLObjectSomeValuesFromImpl | ||
39 | import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl | ||
40 | import org.semanticweb.owlapi.model.IRI | ||
32 | 41 | ||
33 | object RDFoxAxiomConverter { | 42 | object RDFoxAxiomConverter { |
34 | 43 | ||
@@ -49,6 +58,8 @@ class RDFoxAxiomConverter( | |||
49 | suffix: RSASuffix | 58 | suffix: RSASuffix |
50 | ) extends OWLAxiomVisitorEx[List[Rule]] { | 59 | ) extends OWLAxiomVisitorEx[List[Rule]] { |
51 | 60 | ||
61 | import uk.ac.ox.cs.rsacomb.implicits.JavaCollections._ | ||
62 | |||
52 | override def visit(axiom: OWLSubClassOfAxiom): List[Rule] = { | 63 | override def visit(axiom: OWLSubClassOfAxiom): List[Rule] = { |
53 | // Skolemization is needed only for the head of an axiom | 64 | // Skolemization is needed only for the head of an axiom |
54 | val subVisitor = | 65 | val subVisitor = |
@@ -86,10 +97,25 @@ class RDFoxAxiomConverter( | |||
86 | List(Rule.create(head.asJava, body.asJava)) | 97 | List(Rule.create(head.asJava, body.asJava)) |
87 | } | 98 | } |
88 | 99 | ||
100 | override def visit(axiom: OWLObjectPropertyDomainAxiom): List[Rule] = | ||
101 | axiom.asOWLSubClassOfAxiom.accept(this) | ||
102 | |||
103 | override def visit(axiom: OWLObjectPropertyRangeAxiom): List[Rule] = { | ||
104 | val term1 = RSAOntology.genFreshVariable() | ||
105 | val rangeVisitor = new RDFoxClassExprConverter(term, unsafe, skolem, suffix) | ||
106 | val range = axiom.getRange.accept(rangeVisitor) | ||
107 | val propertyVisitor = new RDFoxPropertyExprConverter(term1, term, suffix) | ||
108 | val prop = axiom.getProperty.accept(propertyVisitor) | ||
109 | List(Rule.create(range.res, range.ext ::: prop)) | ||
110 | } | ||
111 | |||
112 | override def visit(axiom: OWLInverseObjectPropertiesAxiom): List[Rule] = | ||
113 | axiom.asSubObjectPropertyOfAxioms.asScala.toList.flatMap(_.accept(this)) | ||
114 | |||
89 | override def visit(axiom: OWLClassAssertionAxiom): List[Rule] = { | 115 | override def visit(axiom: OWLClassAssertionAxiom): List[Rule] = { |
90 | val ind = axiom.getIndividual | 116 | val ind = axiom.getIndividual |
91 | if (ind.isNamed) { | 117 | if (ind.isNamed) { |
92 | val term = IRI.create(ind.asOWLNamedIndividual().getIRI.getIRIString) | 118 | val term = RDFoxIRI.create(ind.asOWLNamedIndividual().getIRI.getIRIString) |
93 | val cls = axiom.getClassExpression | 119 | val cls = axiom.getClassExpression |
94 | val visitor = | 120 | val visitor = |
95 | new RDFoxClassExprConverter(term, unsafe, SkolemStrategy.None, suffix) | 121 | new RDFoxClassExprConverter(term, unsafe, SkolemStrategy.None, suffix) |