aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala27
1 files changed, 15 insertions, 12 deletions
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 4693e04..24045de 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala
@@ -59,6 +59,9 @@ object RSAOntology {
59 // Counter used to implement a simple fresh variable generator 59 // Counter used to implement a simple fresh variable generator
60 private var counter = -1; 60 private var counter = -1;
61 61
62 /** Name of the RDFox data store used for CQ answering */
63 private val DataStore = "answer_computation"
64
62 def apply(ontology: OWLOntology): RSAOntology = new RSAOntology(ontology) 65 def apply(ontology: OWLOntology): RSAOntology = new RSAOntology(ontology)
63 66
64 def apply(ontology: File): RSAOntology = 67 def apply(ontology: File): RSAOntology =
@@ -119,7 +122,10 @@ class RSAOntology(val ontology: OWLOntology) extends RSAAxiom {
119 .flatMap(_.objectPropertyExpressionsInSignature) 122 .flatMap(_.objectPropertyExpressionsInSignature)
120 .distinct 123 .distinct
121 124
122 // OWLAPI reasoner for same easier tasks 125 /** OWLAPI reasoner
126 *
127 * Used to carry out some preliminary reasoning task.
128 */
123 private val reasoner = 129 private val reasoner =
124 (new StructuralReasonerFactory()).createReasoner(ontology) 130 (new StructuralReasonerFactory()).createReasoner(ontology)
125 131
@@ -300,7 +306,7 @@ class RSAOntology(val ontology: OWLOntology) extends RSAAxiom {
300 */ 306 */
301 def ask(query: ConjunctiveQuery): ConjunctiveQueryAnswers = { 307 def ask(query: ConjunctiveQuery): ConjunctiveQueryAnswers = {
302 import implicits.JavaCollections._ 308 import implicits.JavaCollections._
303 val (server, data) = RDFoxHelpers.openConnection("AnswerComputation") 309 val (server, data) = RDFoxHelpers.openConnection(RSAOntology.DataStore)
304 data.addRules(this.canonicalModel.rules) 310 data.addRules(this.canonicalModel.rules)
305 data.addRules(this.filteringProgram(query).rules) 311 data.addRules(this.filteringProgram(query).rules)
306 val answers = RDFoxHelpers 312 val answers = RDFoxHelpers
@@ -317,9 +323,12 @@ class RSAOntology(val ontology: OWLOntology) extends RSAAxiom {
317 answers 323 answers
318 } 324 }
319 325
320 /** Query the logic program used to compute answers to a given CQ. 326 /** Query the RDFox data store used for query answering.
321 * 327 *
322 * This method has been introduced mostly for debugging purposes. 328 * @note This method does not add any facts or rules to the data
329 * store. It is most useful after the execution of a query using
330 * [[uk.ac.ox.cs.rsacomb.RSAOntology.ask RSAOntology.ask]].
331 * @note This method has been introduced mostly for debugging purposes.
323 * 332 *
324 * @param cq a CQ used to compute the environment. 333 * @param cq a CQ used to compute the environment.
325 * @param query query to be executed against the environment 334 * @param query query to be executed against the environment
@@ -327,20 +336,14 @@ class RSAOntology(val ontology: OWLOntology) extends RSAAxiom {
327 * an empty set. 336 * an empty set.
328 * @param opts additional options to RDFox. 337 * @param opts additional options to RDFox.
329 * @return a collection of answers to the input query. 338 * @return a collection of answers to the input query.
330 *
331 * @todo this function currently fails because RDFox reports a
332 * datastore duplication.
333 */ 339 */
334 def queryEnvironment( 340 def queryDataStore(
335 cq: ConjunctiveQuery, 341 cq: ConjunctiveQuery,
336 query: String, 342 query: String,
337 prefixes: Prefixes = new Prefixes(), 343 prefixes: Prefixes = new Prefixes(),
338 opts: ju.Map[String, String] = new ju.HashMap[String, String]() 344 opts: ju.Map[String, String] = new ju.HashMap[String, String]()
339 ): Option[Seq[Seq[Resource]]] = { 345 ): Option[Seq[Seq[Resource]]] = {
340 import implicits.JavaCollections._ 346 val (server, data) = RDFoxHelpers.openConnection(RSAOntology.DataStore)
341 val (server, data) = RDFoxHelpers.openConnection("AnswerComputation")
342 data.addRules(this.canonicalModel.rules)
343 data.addRules(this.filteringProgram(cq).rules)
344 val answers = RDFoxHelpers.submitQuery(data, query, prefixes, opts) 347 val answers = RDFoxHelpers.submitQuery(data, query, prefixes, opts)
345 RDFoxHelpers.closeConnection(server, data) 348 RDFoxHelpers.closeConnection(server, data)
346 answers 349 answers