diff options
Diffstat (limited to 'src/main/scala/rsacomb/RSAComb.scala')
| -rw-r--r-- | src/main/scala/rsacomb/RSAComb.scala | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/main/scala/rsacomb/RSAComb.scala b/src/main/scala/rsacomb/RSAComb.scala index 16d7a04..62414e9 100644 --- a/src/main/scala/rsacomb/RSAComb.scala +++ b/src/main/scala/rsacomb/RSAComb.scala | |||
| @@ -10,7 +10,9 @@ import org.semanticweb.owlapi.model.{OWLAxiom, OWLSubClassOfAxiom, OWLEquivalent | |||
| 10 | import org.semanticweb.owlapi.model.OWLClassExpression | 10 | import org.semanticweb.owlapi.model.OWLClassExpression |
| 11 | import org.semanticweb.owlapi.model.OWLOntology | 11 | import org.semanticweb.owlapi.model.OWLOntology |
| 12 | import org.semanticweb.owlapi.model.OWLOntologyManager | 12 | import org.semanticweb.owlapi.model.OWLOntologyManager |
| 13 | import org.semanticweb.owlapi.model.IRI | ||
| 13 | import org.semanticweb.owlapi.model.parameters.Imports | 14 | import org.semanticweb.owlapi.model.parameters.Imports |
| 15 | import uk.ac.manchester.cs.owl.owlapi.OWLObjectPropertyImpl | ||
| 14 | 16 | ||
| 15 | import tech.oxfordsemantic.jrdfox.Prefixes | 17 | import tech.oxfordsemantic.jrdfox.Prefixes |
| 16 | import tech.oxfordsemantic.jrdfox.client.{ConnectionFactory, ServerConnection, DataStoreConnection} | 18 | import tech.oxfordsemantic.jrdfox.client.{ConnectionFactory, ServerConnection, DataStoreConnection} |
| @@ -22,6 +24,7 @@ import tech.oxfordsemantic.jrdfox.logic.{LogicFormat} | |||
| 22 | import scala.collection.JavaConverters._ | 24 | import scala.collection.JavaConverters._ |
| 23 | 25 | ||
| 24 | import rsacomb.SkolemStrategy | 26 | import rsacomb.SkolemStrategy |
| 27 | import org.semanticweb.owlapi.dlsyntax.renderer.DLSyntaxObjectRenderer | ||
| 25 | 28 | ||
| 26 | class RSA(ontology : OWLOntology) { | 29 | class RSA(ontology : OWLOntology) { |
| 27 | 30 | ||
| @@ -52,12 +55,34 @@ object RSA { | |||
| 52 | * step of approximation of an Horn-ALCHOIQ to RSA | 55 | * step of approximation of an Horn-ALCHOIQ to RSA |
| 53 | */ | 56 | */ |
| 54 | 57 | ||
| 58 | val renderer = new DLSyntaxObjectRenderer() | ||
| 59 | |||
| 60 | // Here we need to compute the unsafe roles. This is hardcoded for now. | ||
| 61 | val unsafe = List( | ||
| 62 | new OWLObjectPropertyImpl(IRI.create("http://example.com/rsa_example.owl#S")).getInverseProperty() | ||
| 63 | ) | ||
| 64 | |||
| 65 | /* Print TBox axioms */ | ||
| 66 | println("TBox/RBox:") | ||
| 67 | for { | ||
| 68 | axiom <- onto.tboxAxioms(Imports.EXCLUDED).collect(Collectors.toList()).asScala | ||
| 69 | } yield println(renderer.render(axiom)) | ||
| 70 | for { | ||
| 71 | axiom <- onto.rboxAxioms(Imports.EXCLUDED).collect(Collectors.toList()).asScala | ||
| 72 | } yield println(renderer.render(axiom)) | ||
| 73 | |||
| 55 | /* Ontology axiom convertion into LP rules */ | 74 | /* Ontology axiom convertion into LP rules */ |
| 56 | for { | 75 | println("Logic rules:") |
| 76 | for { | ||
| 57 | axiom <- onto.tboxAxioms(Imports.EXCLUDED).collect(Collectors.toList()).asScala | 77 | axiom <- onto.tboxAxioms(Imports.EXCLUDED).collect(Collectors.toList()).asScala |
| 58 | visitor = new RDFoxAxiomConverter(Variable.create("x"), SkolemStrategy.Constant(axiom.toString)) | 78 | visitor = new RDFoxAxiomConverter(Variable.create("x"), SkolemStrategy.ConstantRSA(axiom.toString), unsafe) |
| 79 | rule <- axiom.accept(visitor) | ||
| 80 | } yield println(rule) | ||
| 81 | for { | ||
| 82 | axiom <- onto.rboxAxioms(Imports.EXCLUDED).collect(Collectors.toList()).asScala | ||
| 83 | visitor = new RDFoxAxiomConverter(Variable.create("x"), SkolemStrategy.ConstantRSA(axiom.toString), unsafe) | ||
| 59 | rule <- axiom.accept(visitor) | 84 | rule <- axiom.accept(visitor) |
| 60 | } yield println(rule) | 85 | } yield println(rule) |
| 61 | 86 | ||
| 62 | /* Return true for now... */ | 87 | /* Return true for now... */ |
| 63 | true | 88 | true |
