Skip to content

Method: getReasonerName()

1: /*
2: * Copyright (C) 2023 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.ontodriver.owlapi.query;
16:
17: import org.semanticweb.owlapi.model.*;
18: import org.semanticweb.owlapi.reasoner.*;
19: import org.semanticweb.owlapi.reasoner.impl.OWLClassNode;
20: import org.semanticweb.owlapi.reasoner.impl.OWLDataPropertyNode;
21: import org.semanticweb.owlapi.reasoner.impl.OWLObjectPropertyNode;
22: import org.semanticweb.owlapi.reasoner.structural.StructuralReasonerFactory;
23: import org.semanticweb.owlapi.util.Version;
24:
25: import javax.annotation.Nonnull;
26: import java.util.List;
27: import java.util.Set;
28:
29: import static uk.ac.manchester.cs.owl.owlapi.InternalizedEntities.*;
30:
31: /**
32: * A naive implementation of a no-op reasoner that just returns axioms asserted in the underlying ontology.
33: * <p>
34: * This implementation wraps a {@link org.semanticweb.owlapi.reasoner.structural.StructuralReasoner} and passes {@code
35: * true} for direct whenever the called method allows it. All other calls are just forwarded to the underlying
36: * reasoner.
37: */
38: class NoOpReasoner implements OWLReasoner {
39:
40: private final OWLReasoner wrapped;
41:
42: public NoOpReasoner(OWLOntology rootOntology) {
43: this.wrapped = createReasoner(rootOntology);
44: }
45:
46: private static OWLReasoner createReasoner(OWLOntology rootOntology) {
47: final StructuralReasonerFactory factory = new StructuralReasonerFactory();
48: return factory.createReasoner(rootOntology);
49: }
50:
51: @Nonnull
52: public OWLOntology getRootOntology() {
53: return wrapped.getRootOntology();
54: }
55:
56: @Nonnull
57: public Set<OWLAxiom> getPendingAxiomAdditions() {
58: return wrapped.getPendingAxiomAdditions();
59: }
60:
61: @Nonnull
62: public Set<OWLAxiom> getPendingAxiomRemovals() {
63: return wrapped.getPendingAxiomRemovals();
64: }
65:
66: @Nonnull
67: public List<OWLOntologyChange> getPendingChanges() {
68: return wrapped.getPendingChanges();
69: }
70:
71: @Nonnull
72: public BufferingMode getBufferingMode() {
73: return wrapped.getBufferingMode();
74: }
75:
76: public long getTimeOut() {
77: return wrapped.getTimeOut();
78: }
79:
80: @Nonnull
81: public Set<InferenceType> getPrecomputableInferenceTypes() {
82: return wrapped.getPrecomputableInferenceTypes();
83: }
84:
85: public boolean isPrecomputed(@Nonnull InferenceType inferenceType) {
86: return wrapped.isPrecomputed(inferenceType);
87: }
88:
89: public void precomputeInferences(
90: @Nonnull InferenceType... inferenceTypes) throws ReasonerInterruptedException, TimeOutException, InconsistentOntologyException {
91: wrapped.precomputeInferences(inferenceTypes);
92: }
93:
94: public void interrupt() {
95: wrapped.interrupt();
96: }
97:
98: public void dispose() {
99: wrapped.dispose();
100: }
101:
102: public void flush() {
103: wrapped.flush();
104: }
105:
106: public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException {
107: return wrapped.isConsistent();
108: }
109:
110: @Nonnull
111: public NodeSet<OWLClass> getDataPropertyDomains(@Nonnull OWLDataProperty pe,
112: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
113: return wrapped.getDataPropertyDomains(pe, true);
114: }
115:
116: @Nonnull
117: public Set<OWLLiteral> getDataPropertyValues(@Nonnull OWLNamedIndividual ind,
118: @Nonnull OWLDataProperty pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
119: return wrapped.getDataPropertyValues(ind, pe);
120: }
121:
122: @Nonnull
123: public Node<OWLClass> getEquivalentClasses(
124: @Nonnull OWLClassExpression ce) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
125: return wrapped.getEquivalentClasses(ce);
126: }
127:
128: @Nonnull
129: public Node<OWLDataProperty> getEquivalentDataProperties(
130: @Nonnull OWLDataProperty pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
131: return wrapped.getEquivalentDataProperties(pe);
132: }
133:
134: @Nonnull
135: public Node<OWLObjectPropertyExpression> getEquivalentObjectProperties(
136: @Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
137: return wrapped.getEquivalentObjectProperties(pe);
138: }
139:
140: @Nonnull
141: public NodeSet<OWLNamedIndividual> getInstances(@Nonnull OWLClassExpression ce,
142: boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
143: return wrapped.getInstances(ce, true);
144: }
145:
146: @Nonnull
147: public Node<OWLObjectPropertyExpression> getInverseObjectProperties(
148: @Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
149: return wrapped.getInverseObjectProperties(pe);
150: }
151:
152: @Nonnull
153: public NodeSet<OWLClass> getObjectPropertyDomains(@Nonnull OWLObjectPropertyExpression pe,
154: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
155: return wrapped.getObjectPropertyDomains(pe, true);
156: }
157:
158: @Nonnull
159: public NodeSet<OWLClass> getObjectPropertyRanges(@Nonnull OWLObjectPropertyExpression pe,
160: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
161: return wrapped.getObjectPropertyRanges(pe, true);
162: }
163:
164: @Nonnull
165: public NodeSet<OWLNamedIndividual> getObjectPropertyValues(@Nonnull OWLNamedIndividual ind,
166: @Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
167: return wrapped.getObjectPropertyValues(ind, pe);
168: }
169:
170:
171: @Nonnull
172: public Node<OWLNamedIndividual> getSameIndividuals(
173: @Nonnull OWLNamedIndividual ind) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
174: return wrapped.getSameIndividuals(ind);
175: }
176:
177: @Nonnull
178: public NodeSet<OWLClass> getSubClasses(@Nonnull OWLClassExpression ce,
179: boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
180: return wrapped.getSubClasses(ce, true);
181: }
182:
183: @Nonnull
184: public NodeSet<OWLDataProperty> getSubDataProperties(@Nonnull OWLDataProperty pe,
185: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
186: return wrapped.getSubDataProperties(pe, true);
187: }
188:
189: @Nonnull
190: public NodeSet<OWLObjectPropertyExpression> getSubObjectProperties(@Nonnull OWLObjectPropertyExpression pe,
191: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
192: return wrapped.getSubObjectProperties(pe, true);
193: }
194:
195: @Nonnull
196: public NodeSet<OWLClass> getSuperClasses(@Nonnull OWLClassExpression ce,
197: boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, TimeOutException {
198: return wrapped.getSuperClasses(ce, true);
199: }
200:
201: @Nonnull
202: public NodeSet<OWLDataProperty> getSuperDataProperties(@Nonnull OWLDataProperty pe,
203: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
204: return wrapped.getSuperDataProperties(pe, true);
205: }
206:
207: @Nonnull
208: public NodeSet<OWLObjectPropertyExpression> getSuperObjectProperties(@Nonnull OWLObjectPropertyExpression pe,
209: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
210: return wrapped.getSuperObjectProperties(pe, true);
211: }
212:
213: @Nonnull
214: public NodeSet<OWLClass> getTypes(@Nonnull OWLNamedIndividual ind,
215: boolean direct) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
216: return wrapped.getTypes(ind, true);
217: }
218:
219: @Nonnull
220: public Node<OWLClass> getUnsatisfiableClasses() throws ReasonerInterruptedException, TimeOutException {
221: return wrapped.getUnsatisfiableClasses();
222: }
223:
224: public boolean isEntailed(
225: @Nonnull OWLAxiom axiom) throws ReasonerInterruptedException, UnsupportedEntailmentTypeException, TimeOutException, AxiomNotInProfileException, InconsistentOntologyException {
226: return wrapped.isEntailed(axiom);
227: }
228:
229: public boolean isEntailed(
230: @Nonnull Set<? extends OWLAxiom> axioms) throws ReasonerInterruptedException, UnsupportedEntailmentTypeException, TimeOutException, AxiomNotInProfileException, InconsistentOntologyException {
231: return wrapped.isEntailed(axioms);
232: }
233:
234: public boolean isEntailmentCheckingSupported(@Nonnull AxiomType<?> axiomType) {
235: return wrapped.isEntailmentCheckingSupported(axiomType);
236: }
237:
238: public boolean isSatisfiable(
239: @Nonnull OWLClassExpression ce) throws ReasonerInterruptedException, TimeOutException, ClassExpressionNotInProfileException, InconsistentOntologyException {
240: return wrapped.isSatisfiable(ce);
241: }
242:
243: @Nonnull
244: public Node<OWLClass> getBottomClassNode() {
245: return new OWLClassNode(OWL_NOTHING);
246: }
247:
248: @Nonnull
249: public Node<OWLDataProperty> getBottomDataPropertyNode() {
250: return new OWLDataPropertyNode(OWL_BOTTOM_DATA_PROPERTY);
251: }
252:
253: @Nonnull
254: public Node<OWLObjectPropertyExpression> getBottomObjectPropertyNode() {
255: return new OWLObjectPropertyNode(OWL_BOTTOM_OBJECT_PROPERTY);
256: }
257:
258: @Nonnull
259: public NodeSet<OWLNamedIndividual> getDifferentIndividuals(
260: @Nonnull OWLNamedIndividual ind) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
261: return wrapped.getDifferentIndividuals(ind);
262: }
263:
264: @Nonnull
265: public NodeSet<OWLClass> getDisjointClasses(@Nonnull OWLClassExpression ce) {
266: return wrapped.getDisjointClasses(ce);
267: }
268:
269: @Nonnull
270: public NodeSet<OWLDataProperty> getDisjointDataProperties(
271: @Nonnull OWLDataPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
272: return wrapped.getDisjointDataProperties(pe);
273: }
274:
275: @Nonnull
276: public NodeSet<OWLObjectPropertyExpression> getDisjointObjectProperties(
277: @Nonnull OWLObjectPropertyExpression pe) throws InconsistentOntologyException, ReasonerInterruptedException, TimeOutException {
278: return wrapped.getDisjointObjectProperties(pe);
279: }
280:
281: @Nonnull
282: public IndividualNodeSetPolicy getIndividualNodeSetPolicy() {
283: return wrapped.getIndividualNodeSetPolicy();
284: }
285:
286: @Nonnull
287: public String getReasonerName() {
288: return "Owlapi Driver No-op Reasoner";
289: }
290:
291: @Nonnull
292: public Version getReasonerVersion() {
293: return new Version(1, 0, 0, 0);
294: }
295:
296: @Nonnull
297: public Node<OWLClass> getTopClassNode() {
298: return new OWLClassNode(OWL_THING);
299: }
300:
301: @Nonnull
302: public Node<OWLDataProperty> getTopDataPropertyNode() {
303: return new OWLDataPropertyNode(OWL_TOP_DATA_PROPERTY);
304: }
305:
306: @Nonnull
307: public Node<OWLObjectPropertyExpression> getTopObjectPropertyNode() {
308: return new OWLObjectPropertyNode(OWL_TOP_OBJECT_PROPERTY);
309: }
310:
311: @Nonnull
312: public FreshEntityPolicy getFreshEntityPolicy() {
313: return wrapped.getFreshEntityPolicy();
314: }
315: }