diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/rsacomb/CanonicalModel.scala | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/main/scala/rsacomb/CanonicalModel.scala b/src/main/scala/rsacomb/CanonicalModel.scala index a3b0442..49c0c24 100644 --- a/src/main/scala/rsacomb/CanonicalModel.scala +++ b/src/main/scala/rsacomb/CanonicalModel.scala | |||
| @@ -3,9 +3,10 @@ package rsacomb | |||
| 3 | import org.semanticweb.owlapi.model.{ | 3 | import org.semanticweb.owlapi.model.{ |
| 4 | OWLSubObjectPropertyOfAxiom, | 4 | OWLSubObjectPropertyOfAxiom, |
| 5 | OWLSubClassOfAxiom, | 5 | OWLSubClassOfAxiom, |
| 6 | OWLObjectProperty, | ||
| 6 | OWLObjectPropertyExpression | 7 | OWLObjectPropertyExpression |
| 7 | } | 8 | } |
| 8 | import tech.oxfordsemantic.jrdfox.logic.{Rule, Term} | 9 | import tech.oxfordsemantic.jrdfox.logic.{IRI, Atom, Rule, Term, Variable} |
| 9 | 10 | ||
| 10 | object ProgramGenerator { | 11 | object ProgramGenerator { |
| 11 | 12 | ||
| @@ -18,9 +19,32 @@ object ProgramGenerator { | |||
| 18 | def generateRoleRules( | 19 | def generateRoleRules( |
| 19 | roles: List[OWLObjectPropertyExpression] | 20 | roles: List[OWLObjectPropertyExpression] |
| 20 | ): List[Rule] = { | 21 | ): List[Rule] = { |
| 21 | // TODO: Generate additional rules for each role | 22 | def additional(pred: String): Seq[Rule] = { |
| 22 | val additional = List() | 23 | val varX = Variable.create("X") |
| 23 | additional | 24 | val varY = Variable.create("Y") |
| 25 | Seq( | ||
| 26 | Rule.create( | ||
| 27 | Atom.rdf(varX, IRI.create(pred), varY), | ||
| 28 | Atom.rdf(varX, IRI.create(pred ++ "_f"), varY) | ||
| 29 | ), | ||
| 30 | Rule.create( | ||
| 31 | Atom.rdf(varX, IRI.create(pred), varY), | ||
| 32 | Atom.rdf(varX, IRI.create(pred ++ "_b"), varY) | ||
| 33 | ), | ||
| 34 | Rule.create( | ||
| 35 | Atom.rdf(varY, IRI.create(pred ++ "_b" ++ "_inv"), varX), | ||
| 36 | Atom.rdf(varX, IRI.create(pred ++ "_f"), varY) | ||
| 37 | ), | ||
| 38 | Rule.create( | ||
| 39 | Atom.rdf(varY, IRI.create(pred ++ "_f" ++ "_inv"), varX), | ||
| 40 | Atom.rdf(varX, IRI.create(pred ++ "_b"), varY) | ||
| 41 | ) | ||
| 42 | ) | ||
| 43 | } | ||
| 44 | roles | ||
| 45 | .filter(_.isInstanceOf[OWLObjectProperty]) // Can we avoid this? | ||
| 46 | .map(_.asInstanceOf[OWLObjectProperty].getIRI.getIRIString) | ||
| 47 | .flatMap(additional) | ||
| 24 | } | 48 | } |
| 25 | } | 49 | } |
| 26 | 50 | ||
| @@ -37,12 +61,17 @@ class ProgramGenerator( | |||
| 37 | val role = axiom.objectPropertyExpressionsInSignature(0) | 61 | val role = axiom.objectPropertyExpressionsInSignature(0) |
| 38 | if (unsafe.contains(role)) { | 62 | if (unsafe.contains(role)) { |
| 39 | val visitor = | 63 | val visitor = |
| 40 | new RDFoxAxiomConverter(term, SkolemStrategy.Standard("TODO"), unsafe) | 64 | new RDFoxAxiomConverter( |
| 65 | term, | ||
| 66 | SkolemStrategy.Standard(axiom.toString), | ||
| 67 | unsafe | ||
| 68 | ) | ||
| 41 | axiom.accept(visitor) | 69 | axiom.accept(visitor) |
| 42 | } else { | 70 | } else { |
| 43 | // TODO; Handle forks | 71 | // TODO; Handle forks |
| 44 | } | 72 | } |
| 45 | } else { | 73 | } else { |
| 74 | // Fallback to standard OWL to LP translation | ||
| 46 | super.visit(axiom) | 75 | super.visit(axiom) |
| 47 | } | 76 | } |
| 48 | List() | 77 | List() |
