cz.cvut.kbss.ontodriver.owlapi.query.NoOpReasoner Maven / Gradle / Ivy
Show all versions of ontodriver-owlapi Show documentation
/*
* JOPA
* Copyright (C) 2024 Czech Technical University in Prague
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package cz.cvut.kbss.ontodriver.owlapi.query;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.reasoner.*;
import org.semanticweb.owlapi.reasoner.impl.OWLClassNode;
import org.semanticweb.owlapi.reasoner.impl.OWLDataPropertyNode;
import org.semanticweb.owlapi.reasoner.impl.OWLObjectPropertyNode;
import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory;
import org.semanticweb.owlapi.util.Version;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Set;
import static uk.ac.manchester.cs.owl.owlapi.InternalizedEntities.*;
/**
* A naive implementation of a no-op reasoner that just returns axioms asserted in the underlying ontology.
*
* This implementation wraps a {@link org.semanticweb.owlapi.reasoner.structural.StructuralReasoner} and passes {@code
* true} for direct whenever the called method allows it. All other calls are just forwarded to the underlying
* reasoner.
*/
public class NoOpReasoner implements OWLReasoner {
private final OWLReasoner wrapped;
public NoOpReasoner(OWLOntology rootOntology) {
this.wrapped = createReasoner(rootOntology);
}
private static OWLReasoner createReasoner(OWLOntology rootOntology) {
final StructuralReasonerFactory factory = new StructuralReasonerFactory();
return factory.createReasoner(rootOntology);
}
@Nonnull
public OWLOntology getRootOntology() {
return wrapped.getRootOntology();
}
@Nonnull
public Set getPendingAxiomAdditions() {
return wrapped.getPendingAxiomAdditions();
}
@Nonnull
public Set getPendingAxiomRemovals() {
return wrapped.getPendingAxiomRemovals();
}
@Nonnull
public List getPendingChanges() {
return wrapped.getPendingChanges();
}
@Nonnull
public BufferingMode getBufferingMode() {
return wrapped.getBufferingMode();
}
public long getTimeOut() {
return wrapped.getTimeOut();
}
@Nonnull
public Set getPrecomputableInferenceTypes() {
return wrapped.getPrecomputableInferenceTypes();
}
public boolean isPrecomputed(@Nonnull InferenceType inferenceType) {
return wrapped.isPrecomputed(inferenceType);
}
public void precomputeInferences(
@Nonnull InferenceType... inferenceTypes) throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException {
wrapped.precomputeInferences(inferenceTypes);
}
public void interrupt() {
wrapped.interrupt();
}
public void dispose() {
wrapped.dispose();
}
public void flush() {
wrapped.flush();
}
public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException {
return wrapped.isConsistent();
}
@Nonnull
public NodeSet getDataPropertyDomains(@Nonnull OWLDataProperty pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getDataPropertyDomains(pe, true);
}
@Nonnull
public Set getDataPropertyValues(@Nonnull OWLNamedIndividual ind,
@Nonnull OWLDataProperty pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getDataPropertyValues(ind, pe);
}
@Nonnull
public Node getEquivalentClasses(
@Nonnull OWLClassExpression ce) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
return wrapped.getEquivalentClasses(ce);
}
@Nonnull
public Node getEquivalentDataProperties(
@Nonnull OWLDataProperty pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getEquivalentDataProperties(pe);
}
@Nonnull
public Node getEquivalentObjectProperties(
@Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getEquivalentObjectProperties(pe);
}
@Nonnull
public NodeSet getInstances(@Nonnull OWLClassExpression ce,
boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
return wrapped.getInstances(ce, true);
}
@Nonnull
public Node getInverseObjectProperties(
@Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getInverseObjectProperties(pe);
}
@Nonnull
public NodeSet getObjectPropertyDomains(@Nonnull OWLObjectPropertyExpression pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getObjectPropertyDomains(pe, true);
}
@Nonnull
public NodeSet getObjectPropertyRanges(@Nonnull OWLObjectPropertyExpression pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getObjectPropertyRanges(pe, true);
}
@Nonnull
public NodeSet getObjectPropertyValues(@Nonnull OWLNamedIndividual ind,
@Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getObjectPropertyValues(ind, pe);
}
@Nonnull
public Node getSameIndividuals(
@Nonnull OWLNamedIndividual ind) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSameIndividuals(ind);
}
@Nonnull
public NodeSet getSubClasses(@Nonnull OWLClassExpression ce,
boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSubClasses(ce, true);
}
@Nonnull
public NodeSet getSubDataProperties(@Nonnull OWLDataProperty pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSubDataProperties(pe, true);
}
@Nonnull
public NodeSet getSubObjectProperties(@Nonnull OWLObjectPropertyExpression pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSubObjectProperties(pe, true);
}
@Nonnull
public NodeSet getSuperClasses(@Nonnull OWLClassExpression ce,
boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSuperClasses(ce, true);
}
@Nonnull
public NodeSet getSuperDataProperties(@Nonnull OWLDataProperty pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSuperDataProperties(pe, true);
}
@Nonnull
public NodeSet getSuperObjectProperties(@Nonnull OWLObjectPropertyExpression pe,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getSuperObjectProperties(pe, true);
}
@Nonnull
public NodeSet getTypes(@Nonnull OWLNamedIndividual ind,
boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getTypes(ind, true);
}
@Nonnull
public Node getUnsatisfiableClasses() throws ReasonerInterruptedException, TimeOutException {
return wrapped.getUnsatisfiableClasses();
}
public boolean isEntailed(
@Nonnull OWLAxiom axiom) throws ReasonerInterruptedException, UnsupportedEntailmentTypeException, TimeOutException, AxiomNotInProfileException, InconsistentOntologyException {
return wrapped.isEntailed(axiom);
}
public boolean isEntailed(
@Nonnull Set extends OWLAxiom> axioms) throws ReasonerInterruptedException, UnsupportedEntailmentTypeException, TimeOutException, AxiomNotInProfileException, InconsistentOntologyException {
return wrapped.isEntailed(axioms);
}
public boolean isEntailmentCheckingSupported(@Nonnull AxiomType> axiomType) {
return wrapped.isEntailmentCheckingSupported(axiomType);
}
public boolean isSatisfiable(
@Nonnull OWLClassExpression ce) throws ReasonerInterruptedException, TimeOutException, ClassExpressionNotInProfileException, InconsistentOntologyException {
return wrapped.isSatisfiable(ce);
}
@Nonnull
public Node getBottomClassNode() {
return new OWLClassNode(OWL_NOTHING);
}
@Nonnull
public Node getBottomDataPropertyNode() {
return new OWLDataPropertyNode(OWL_BOTTOM_DATA_PROPERTY);
}
@Nonnull
public Node getBottomObjectPropertyNode() {
return new OWLObjectPropertyNode(OWL_BOTTOM_OBJECT_PROPERTY);
}
@Nonnull
public NodeSet getDifferentIndividuals(
@Nonnull OWLNamedIndividual ind) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getDifferentIndividuals(ind);
}
@Nonnull
public NodeSet getDisjointClasses(@Nonnull OWLClassExpression ce) {
return wrapped.getDisjointClasses(ce);
}
@Nonnull
public NodeSet getDisjointDataProperties(
@Nonnull OWLDataPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getDisjointDataProperties(pe);
}
@Nonnull
public NodeSet getDisjointObjectProperties(
@Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
return wrapped.getDisjointObjectProperties(pe);
}
@Nonnull
public IndividualNodeSetPolicy getIndividualNodeSetPolicy() {
return wrapped.getIndividualNodeSetPolicy();
}
@Nonnull
public String getReasonerName() {
return "Owlapi Driver No-op Reasoner";
}
@Nonnull
public Version getReasonerVersion() {
return new Version(1, 0, 0, 0);
}
@Nonnull
public Node getTopClassNode() {
return new OWLClassNode(OWL_THING);
}
@Nonnull
public Node getTopDataPropertyNode() {
return new OWLDataPropertyNode(OWL_TOP_DATA_PROPERTY);
}
@Nonnull
public Node getTopObjectPropertyNode() {
return new OWLObjectPropertyNode(OWL_TOP_OBJECT_PROPERTY);
}
@Nonnull
public FreshEntityPolicy getFreshEntityPolicy() {
return wrapped.getFreshEntityPolicy();
}
}