From 0ccecbe8718c90201700897ee33e9082b7bfce50 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Wed, 15 Jul 2020 17:48:11 +0100 Subject: Rename source code directory structure --- src/main/scala/example/RSAComb.scala | 138 ----------------------------------- 1 file changed, 138 deletions(-) delete mode 100644 src/main/scala/example/RSAComb.scala (limited to 'src/main/scala/example/RSAComb.scala') diff --git a/src/main/scala/example/RSAComb.scala b/src/main/scala/example/RSAComb.scala deleted file mode 100644 index bc94a8d..0000000 --- a/src/main/scala/example/RSAComb.scala +++ /dev/null @@ -1,138 +0,0 @@ -package rsacomb - -import java.io.File -import java.util.HashMap -import java.util.stream.{Stream,Collectors} - -import org.semanticweb.owlapi.apibinding.OWLManager -import org.semanticweb.owlapi.model.{AxiomType, ClassExpressionType, OWLObjectSomeValuesFrom} -import org.semanticweb.owlapi.model.{OWLAxiom, OWLSubClassOfAxiom, OWLEquivalentClassesAxiom} -import org.semanticweb.owlapi.model.OWLClassExpression -import org.semanticweb.owlapi.model.OWLOntology -import org.semanticweb.owlapi.model.OWLOntologyManager -import org.semanticweb.owlapi.model.parameters.Imports - -import tech.oxfordsemantic.jrdfox.Prefixes -import tech.oxfordsemantic.jrdfox.client.{ConnectionFactory, ServerConnection, DataStoreConnection} -import tech.oxfordsemantic.jrdfox.client.UpdateType -import tech.oxfordsemantic.jrdfox.logic.{Rule, Atom, Literal, Predicate, Term, Variable} -import tech.oxfordsemantic.jrdfox.logic.{Bind, BuiltinFunctionCall} - -import scala.collection.JavaConverters._ - -import rsacomb.SkolemStrategy - -class RSA(ontology : OWLOntology) { - - /* Alternative constructor(s) */ - def this(file : File) = this(RSA.loadOntology(file)) - - def getOntology : OWLOntology = ontology - -} // class RSA - -object RSA { - - def loadOntology( onto : File ) : OWLOntology = { - /* Retrieve ontology manager */ - val manager : OWLOntologyManager = OWLManager.createOWLOntologyManager() - /* Retrieve ontology */ - manager.loadOntologyFromOntologyDocument(onto) - } - - def isRSA( onto : OWLOntology ) : Boolean = { - /* TODO: Steps for RSA check - * 1) convert ontology axioms into LP rules - * 2) call RDFox on the onto and compute materialization - * 3) build graph from E(x,y) facts - * 4) check if the graph is tree-like - */ - - /* Ontology axiom convertion into LP rules */ - for { - axiom <- onto.tboxAxioms(Imports.EXCLUDED).collect(Collectors.toList()).asScala - visitor = new RDFoxAxiomConverter(Variable.create("x"), SkolemStrategy.Constant(axiom.toString)) - rule <- axiom.accept(visitor) - } yield println(rule) - - /* Return true for now... */ - true - } - -} // object RSA - -object RSAComb { - - val help : String = """ - rsacomb - combined approach for CQ answering for RSA ontologies. - - USAGE - rsacomb - - where - the ontology is expected to be an OWL file and the (single) - query a SPARQL query file. - """ - - def main( args : Array[String] ) : Unit = { - - /* Simple arguments handling - * - * TODO: use something better later on - */ - - if (args.length < 2) { - println(help) - return () - } - - val ontologyPath = new File(args(0)) - val queryPath = new File(args(1)) - - if (!ontologyPath.isFile || !queryPath.isFile) { - println("The provided arguments are not regular files.\n\n") - println(help) - return () - } - - /* Create RSA object from generic OWLOntology - * - * TODO: It might be required to check if the ontology in input is - * Horn-ALCHOIQ. At the moment we are assuming this is always the - * case. - */ - val rsa = new RSA(ontologyPath) - RSA.isRSA(rsa.getOntology) - - /* Build canonical model */ - //val tboxCanon = rsa.canonicalModel() - - /* Load query */ - //val query = ... - - /* Compute the filtering program from the given query */ - //val tboxFilter = rsa.filteringProgram(query) - - /* ... */ - - /* DEBUG ONLY */ - println("Ok!") - } -} - -/* Notes: - * - * To establish a connection with a local RDFox instance, do the - * following: - * - * ``` - * val serverConnection : ServerConnection = ConnectionFactory.newServerConnection("rdfox:local", "", "") - * serverConnection.createDataStore("test","seq",new HashMap()) - * val dataStoreConnection : DataStoreConnection = serverConnection.newDataStoreConnection("test") - * dataStoreConnection.importData( - * UpdateType.ADDITION, - * Prefixes.s_emptyPrefixes, - * new File("./path/to/file") - * ) - * ``` - */ -- cgit v1.2.3