aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/rsacomb')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala17
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala16
2 files changed, 18 insertions, 15 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
index 016bb86..40fee79 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
@@ -19,11 +19,11 @@ object RSAComb extends App {
19 rsacomb - combined approach for CQ answering for RSA ontologies. 19 rsacomb - combined approach for CQ answering for RSA ontologies.
20 20
21 USAGE 21 USAGE
22 rsacomb <path/to/ontology.owl> <path/to/query.sparql> 22 rsacomb <query> <ontology> ...
23 23
24 where 24 where
25 the ontology is expected to be an OWL file and the (single) 25 - query: a (single) SPARQL query file.
26 query a SPARQL query file. 26 - ontology: one or more ontologies.
27 27
28 """ 28 """
29 29
@@ -32,15 +32,15 @@ object RSAComb extends App {
32 * TODO: use something better later on 32 * TODO: use something better later on
33 */ 33 */
34 34
35 if (args.length < 2) { 35 if (args.length < 3) {
36 println(help) 36 println(help)
37 sys.exit; 37 sys.exit;
38 } 38 }
39 39
40 val ontoPath = new File(args(0)) 40 val queryPath = new File(args(0))
41 val queryPath = new File(args(1)) 41 val ontoPaths = args.drop(1).map(new File(_))
42 42
43 if (!ontoPath.isFile || !queryPath.isFile) { 43 if (!queryPath.isFile || !ontoPaths.forall(_.isFile)) {
44 println("The provided arguments are not regular files.\n\n") 44 println("The provided arguments are not regular files.\n\n")
45 println(help) 45 println(help)
46 sys.exit; 46 sys.exit;
@@ -51,8 +51,9 @@ object RSAComb extends App {
51 * case. 51 * case.
52 */ 52 */
53 53
54 val ontology = RSAOntology(ontoPath) 54 val ontology = RSAOntology(ontoPaths: _*)
55 if (ontology.isRSA) { 55 if (ontology.isRSA) {
56 //println("ONTOLOGY IS RSA")
56 57
57 /** Read SPARQL query from file */ 58 /** Read SPARQL query from file */
58 val source = io.Source.fromFile(queryPath.getAbsoluteFile) 59 val source = io.Source.fromFile(queryPath.getAbsoluteFile)
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
index ceb24de..4dd554a 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
@@ -6,7 +6,7 @@ import java.util.HashMap
6import java.util.stream.{Collectors, Stream} 6import java.util.stream.{Collectors, Stream}
7import java.io.File 7import java.io.File
8import org.semanticweb.owlapi.apibinding.OWLManager 8import org.semanticweb.owlapi.apibinding.OWLManager
9 9import org.semanticweb.owlapi.util.OWLOntologyMerger
10import org.semanticweb.owlapi.model.{OWLOntology, OWLAxiom} 10import org.semanticweb.owlapi.model.{OWLOntology, OWLAxiom}
11import org.semanticweb.owlapi.model.{ 11import org.semanticweb.owlapi.model.{
12 OWLClass, 12 OWLClass,
@@ -63,17 +63,19 @@ object RSAOntology {
63 63
64 def apply(ontology: OWLOntology): RSAOntology = new RSAOntology(ontology) 64 def apply(ontology: OWLOntology): RSAOntology = new RSAOntology(ontology)
65 65
66 def apply(ontology: File): RSAOntology = 66 def apply(ontologies: File*): RSAOntology =
67 new RSAOntology(loadOntology(ontology)) 67 new RSAOntology(loadOntology(ontologies: _*))
68 68
69 def genFreshVariable(): Variable = { 69 def genFreshVariable(): Variable = {
70 counter += 1 70 counter += 1
71 Variable.create(f"I$counter%03d") 71 Variable.create(f"I$counter%03d")
72 } 72 }
73 73
74 private def loadOntology(onto: File): OWLOntology = { 74 private def loadOntology(ontologies: File*): OWLOntology = {
75 val manager = OWLManager.createOWLOntologyManager() 75 val manager = OWLManager.createOWLOntologyManager()
76 manager.loadOntologyFromOntologyDocument(onto) 76 ontologies.foreach { manager.loadOntologyFromOntologyDocument(_) }
77 val merger = new OWLOntologyMerger(manager)
78 merger.createMergedOntology(manager, OWLIRI.create("_:merged"))
77 } 79 }
78} 80}
79 81
@@ -163,8 +165,8 @@ class RSAOntology(val ontology: OWLOntology) {
163 } yield rule 165 } yield rule
164 166
165 /* DEBUG: print datalog rules */ 167 /* DEBUG: print datalog rules */
166 //println("\nDatalog roles:") 168 println("\nDatalog roles:")
167 //datalog.foreach(println) 169 datalog.foreach(println)
168 170
169 // Open connection with RDFox 171 // Open connection with RDFox
170 val (server, data) = RDFoxUtil.openConnection("RSACheck") 172 val (server, data) = RDFoxUtil.openConnection("RSACheck")