aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-11 16:28:20 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-11 16:28:20 +0100
commit094a6e1211c96f174040b209d0c5e2e188bfa4ac (patch)
tree99450a5203aaa8a6474aff750393eaacf5261d48 /src
parent32fe8f94255b913c570275043a3c056eaa4ec07b (diff)
downloadACQuA-094a6e1211c96f174040b209d0c5e2e188bfa4ac.tar.gz
ACQuA-094a6e1211c96f174040b209d0c5e2e188bfa4ac.zip
Add RSA query reasoner to perform CQ answering over RSA
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/uk/ac/ox/cs/acqua/Main.scala25
-rw-r--r--src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala12
-rw-r--r--src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala34
3 files changed, 47 insertions, 24 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/Main.scala b/src/main/scala/uk/ac/ox/cs/acqua/Main.scala
index e8cfeb7..221c0e2 100644
--- a/src/main/scala/uk/ac/ox/cs/acqua/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/acqua/Main.scala
@@ -57,29 +57,20 @@ object Acqua extends App {
57 reasoner.loadOntology(ontology.origin) 57 reasoner.loadOntology(ontology.origin)
58 reasoner.importData(properties.getDataPath()) 58 reasoner.importData(properties.getDataPath())
59 if (reasoner.preprocess()) { 59 if (reasoner.preprocess()) {
60 Utility.logInfo("The ontology is consistent!"); 60 Utility logInfo "The ontology is consistent!"
61 } 61 }
62 else { 62 else {
63 Utility.logInfo("The ontology is inconsistent!"); 63 Utility logInfo "The ontology is inconsistent!"
64 reasoner.dispose(); 64 reasoner.dispose();
65 // Exit somehow
65 } 66 }
66 67
67 if (config contains 'queries) { 68 if (config contains 'queries) {
68 val queries = 69 val queryManager = reasoner.getQueryManager()
69 RDFoxUtil.loadQueriesFromFiles( 70 config('queries).get[List[os.Path]].map(path => {
70 config('queries).get[List[os.Path]], 71 val queries = queryManager collectQueryRecords path.toString
71 RSA.Prefixes 72 reasoner evaluate queries
72 ) 73 })
73 // for(String queryFile : properties.getQueryPath().split(";")) {
74 // Collection<QueryRecord> queryRecords = pagoda.getQueryManager().collectQueryRecords(queryFile);
75 // pagoda.evaluate(queryRecords);
76 } 74 }
77} 75}
78 76
79
80 // /* Perform query answering */
81 // val answers = rsa ask queries
82
83 // /* Perform logging */
84 // Logger write answers
85 // Logger.generateSimulationScripts(datapath, queries)
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala b/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala
index c7c582d..3663813 100644
--- a/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala
+++ b/src/main/scala/uk/ac/ox/cs/acqua/implicits/PagodaConverters.scala
@@ -16,14 +16,22 @@
16 16
17package uk.ac.ox.cs.acqua.implicits 17package uk.ac.ox.cs.acqua.implicits
18 18
19import java.util.Collection
20import scala.collection.JavaConverters._
21
19import uk.ac.ox.cs.rsacomb.sparql.ConjunctiveQuery 22import uk.ac.ox.cs.rsacomb.sparql.ConjunctiveQuery
23import uk.ac.ox.cs.rsacomb.util.RSA
20import uk.ac.ox.cs.pagoda.query.QueryRecord 24import uk.ac.ox.cs.pagoda.query.QueryRecord
21 25
22object PagodaConverters { 26object PagodaConverters {
23 27
24 implicit def queryRecord2conjuctiveQuery(q: QueryRecord): ConjunctiveQuery = ??? 28 implicit def queryRecord2conjuctiveQuery(q: QueryRecord): ConjunctiveQuery = {
29 // TODO: check whether `q.id` is correct
30 ConjunctiveQuery.parse(q.id,q.getQueryText(),RSA.Prefixes).get
31 }
25 32
26 implicit def conjunctiveQuery2queryRecord(q: ConjunctiveQuery): QueryRecord = ??? 33 implicit def queryRecords2conjuctiveQueries(qs: Collection[QueryRecord]): List[ConjunctiveQuery] =
34 qs.asScala.map(queryRecord2conjuctiveQuery).toList
27 35
28} 36}
29 37
diff --git a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala
index 6b98d79..ea84ca5 100644
--- a/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala
+++ b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala
@@ -16,6 +16,9 @@
16 16
17package uk.ac.ox.cs.acqua.reasoner 17package uk.ac.ox.cs.acqua.reasoner
18 18
19import java.util.Collection;
20import scala.collection.JavaConverters._
21
19import org.semanticweb.owlapi.model.OWLOntology 22import org.semanticweb.owlapi.model.OWLOntology
20import uk.ac.ox.cs.rsacomb.RSAOntology 23import uk.ac.ox.cs.rsacomb.RSAOntology
21import uk.ac.ox.cs.rsacomb.approximation.{Approximation,Lowerbound} 24import uk.ac.ox.cs.rsacomb.approximation.{Approximation,Lowerbound}
@@ -67,12 +70,33 @@ class RSAQueryReasoner(val origin: Ontology) extends QueryReasoner {
67 origin.isRSA 70 origin.isRSA
68 } 71 }
69 72
70 // TODO: probably need to override `evaluate` on multiple queries 73 /** Evaluates a collection of queries.
71 def evaluate(query: QueryRecord): Unit = { 74 *
72 rsa ask query 75 * Uses RSAComb internally to reuse part of the computation of
76 * multiple calls to [[uk.ac.ox.cs.rsacomb.RSAOntology.ask]].
77 *
78 * TODO: perform logging of answers
79 */
80 override def evaluate(queries: Collection[QueryRecord]): Unit = {
81 val answers = rsa ask queries
82 /* Perform logging */
83 // Logger write answers
84 // Logger.generateSimulationScripts(datapath, queries)
73 } 85 }
74 86
75 def evaluateUpper(record: QueryRecord): Unit= { 87 /** Evaluates a single query.
76 ??? 88 *
89 * Uses RSAComb internally to reuse part of the computation of
90 * multiple calls to [[uk.ac.ox.cs.rsacomb.RSAOntology.ask]].
91 *
92 * TODO: perform logging of answers
93 */
94 def evaluate(query: QueryRecord): Unit = {
95 val answers = rsa ask query
96 /* Perform logging */
97 // Logger write answers
98 // Logger.generateSimulationScripts(datapath, queries)
77 } 99 }
100
101 def evaluateUpper(record: QueryRecord): Unit= ???
78} 102}