From 32fe8f94255b913c570275043a3c056eaa4ec07b Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Wed, 11 May 2022 12:35:56 +0100 Subject: Implement stub for query answering procedure --- .../ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala (limited to 'src/main/scala/uk/ac/ox/cs/acqua/reasoner') 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 new file mode 100644 index 0000000..6b98d79 --- /dev/null +++ b/src/main/scala/uk/ac/ox/cs/acqua/reasoner/RSAQueryReasoner.scala @@ -0,0 +1,78 @@ +/* + * Copyright 2021,2022 KRR Oxford + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package uk.ac.ox.cs.acqua.reasoner + +import org.semanticweb.owlapi.model.OWLOntology +import uk.ac.ox.cs.rsacomb.RSAOntology +import uk.ac.ox.cs.rsacomb.approximation.{Approximation,Lowerbound} +import uk.ac.ox.cs.rsacomb.ontology.Ontology +import uk.ac.ox.cs.pagoda.query.QueryRecord +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner + +class RSAQueryReasoner(val origin: Ontology) extends QueryReasoner { + + /* Implicit compatibility between PAGOdA and RSAComb types */ + import uk.ac.ox.cs.acqua.implicits.PagodaConverters._ + + /** This class is instantiated when the input ontology is RSA. + * Approximation (via any algorithm with RSAOntology as target) + * doesn't perform anything, but is useful to turn a generic + * [[uk.ac.ox.cs.rsacomb.ontology.Ontology]] into an + * [[uk.ac.ox.cs.rsacomb.RSAOntology]]. + */ + private val toRSA: Approximation[RSAOntology] = new Lowerbound + val rsa: RSAOntology = origin approximate toRSA + + /** Doesn't perform any action. + * + * @note Implemented for compatibility with other reasoners. + */ + def loadOntology(ontology: OWLOntology): Unit = { + /* Nothing to do */ + } + + /** Check consistency and returns whether the ontology is RSA. + * + * Preprocessing is performed on instance creation, so no actual work + * is being done here. + * + * @note Implemented for compatibility with other reasoners. + */ + def preprocess(): Boolean = { + origin.isRSA + } + + /** Check consistency and returns whether the ontology is RSA. + * + * Preprocessing is performed on instance creation, along with + * consistency checking, so no actual work is being done here. + * + * @note Implemented for compatibility with other reasoners. + */ + def isConsistent(): Boolean = { + origin.isRSA + } + + // TODO: probably need to override `evaluate` on multiple queries + def evaluate(query: QueryRecord): Unit = { + rsa ask query + } + + def evaluateUpper(record: QueryRecord): Unit= { + ??? + } +} -- cgit v1.2.3