From 91de03f187f298004d90708c5815e86134b10eae Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Wed, 2 Dec 2020 18:47:49 +0000 Subject: Make filtering program generate/load facts as facts --- .../scala/uk/ac/ox/cs/rsacomb/FilteringProgram.scala | 20 ++++++++++---------- src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala | 4 +++- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/main/scala/uk/ac/ox/cs') diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/FilteringProgram.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/FilteringProgram.scala index 52be937..4e533c6 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/FilteringProgram.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/FilteringProgram.scala @@ -76,6 +76,15 @@ class FilteringProgram(query: ConjunctiveQuery, constants: List[Term]) { val nis: Rule = Rule.create(RSA.NI(varX), RSA.Congruent(varX, varY), RSA.Named(varY)) + /** Initializes instances of `rsa:Named`. + * + * They represent the set of constants appearing in the original + * ontology. + * + * @note corresponds to rules 2 in Table 3. + */ + val facts = constants map RSA.Named + /** Collection of filtering program rules. */ val rules: List[Rule] = nis :: { @@ -89,15 +98,6 @@ class FilteringProgram(query: ConjunctiveQuery, constants: List[Term]) { */ val r1 = Rule.create(RSA.QM, query.atoms: _*) - /** Initializes instances of `rsa:Named`. - * - * They represent the set of constants appearing in the original - * ontology. - * - * @note corresponds to rules 2 in Table 3. - */ - val r2 = constants.map(c => Rule.create(RSA.Named(c))) - /** Initializes instances of `rsa:ID`. * * They are initialized as a minimal congruence relation over the @@ -307,7 +307,7 @@ class FilteringProgram(query: ConjunctiveQuery, constants: List[Term]) { */ val r9 = Rule.create(RSA.Ans, RSA.QM, not(RSA.SP)) - (r1 :: r2 ::: + (r1 :: r3a ::: r3b :: r3c :: r4a ::: r4b ::: r4c ::: r5a ::: r5b ::: r5c ::: 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 f90e3c1..a965ef9 100644 --- a/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala +++ b/src/main/scala/uk/ac/ox/cs/rsacomb/RSAOntology.scala @@ -327,9 +327,11 @@ class RSAOntology(val ontology: OWLOntology) { def ask(query: ConjunctiveQuery): ConjunctiveQueryAnswers = { import implicits.JavaCollections._ val (server, data) = RDFoxUtil.openConnection(RSAOntology.DataStore) + val filter = this.filteringProgram(query) RDFoxUtil.addRules(data, this.canonicalModel.rules) RDFoxUtil.addFacts(data, this.canonicalModel.facts) - data.addRules(this.filteringProgram(query).rules) + RDFoxUtil.addRules(data, filter.rules) + RDFoxUtil.addFacts(data, filter.facts) val answers = RDFoxUtil .submitQuery( data, -- cgit v1.2.3