/** * use {@link #create(ElkReasoner, OWLAxiom)} * * @param elkReasoner */ private ElkOwlProof(ElkReasoner elkReasoner, OWLAxiom elkEntailment) { this.elkReasoner_ = elkReasoner; this.owlEntailment_ = elkEntailment; elkReasoner.addListener(this); }
@Override public NodeSet<OWLDataProperty> getDisjointDataProperties( OWLDataPropertyExpression arg0) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { LOGGER_.trace("getDisjointDataProperties(OWLDataPropertyExpression)"); checkInterrupted(); // TODO Provide implementation throw unsupportedOwlApiMethod( "getDisjointDataProperties(OWLDataPropertyExpression)"); }
@Override public Node<OWLClass> getTopClassNode() { LOGGER_.trace("getTopClassNode()"); checkInterrupted(); try { return getClassNode(objectFactory_.getOwlThing()); } catch (ElkUnsupportedReasoningTaskException e) { throw unsupportedOwlApiMethod("getTopClassNode()", e.getMessage()); } catch (ElkException e) { throw elkConverter_.convert(e); } catch (ElkRuntimeException e) { throw elkConverter_.convert(e); } }
@Override public Node<OWLObjectPropertyExpression> getTopObjectPropertyNode() { LOGGER_.trace("getTopObjectPropertyNode()"); checkInterrupted(); try { return getObjectPropertyNode( objectFactory_.getOwlTopObjectProperty()); } catch (final ElkUnsupportedReasoningTaskException e) { throw unsupportedOwlApiMethod("getTopObjectPropertyNode()", e.getMessage()); } catch (final ElkException e) { throw elkConverter_.convert(e); } catch (final ElkRuntimeException e) { throw elkConverter_.convert(e); } }
@Override public Proof<? extends Inference<?>> computeProof(OWLAxiom entailment) { ElkReasoner elkReasoner = getCurrentElkReasoner(); if (elkReasoner == null) { return null; } // else return new OwlInternalProof(elkReasoner.getInternalReasoner(), entailment); }
initReasoner(new ReasonerFactory().createReasoner(reasoner_, objectFactory_, config_)); bufferedChangesLoader_ = new OwlChangesLoaderFactory(
@Override public void dispose() { super.dispose(); elkReasoner_.removeListener(this); }
@Override public Node<OWLNamedIndividual> getSameIndividuals(OWLNamedIndividual arg0) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { LOGGER_.trace("getSameIndividuals(OWLNamedIndividual)"); checkInterrupted(); // TODO This needs to be updated when we support nominals return new OWLNamedIndividualNode(arg0); }
@Override public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException { LOGGER_.trace("isConsistent()"); try { return !reasoner_.isInconsistent(); } catch (ElkUnsupportedReasoningTaskException e) { throw unsupportedOwlApiMethod("isConsistent()", e.getMessage()); } catch (ElkException e) { throw elkConverter_.convert(e); } catch (ElkRuntimeException e) { throw elkConverter_.convert(e); } }
@SuppressWarnings("static-method") ElkReasoner createElkReasoner(OWLOntology ontology, boolean isBufferingMode, OWLReasonerConfiguration config) throws IllegalConfigurationException { LOGGER_.trace("createElkReasoner(OWLOntology, boolean, OWLReasonerConfiguration)"); // here we check if the passed configuration also has ELK's parameters ElkReasonerConfiguration elkReasonerConfig; if (config != null) { if (config instanceof ElkReasonerConfiguration) { elkReasonerConfig = (ElkReasonerConfiguration) config; } else { elkReasonerConfig = new ElkReasonerConfiguration(config); } } else { elkReasonerConfig = new ElkReasonerConfiguration(); } return new ElkReasoner(ontology, isBufferingMode, elkReasonerConfig); } }
@Override public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { Set<OWLOntology> importClosure = null; for (OWLOntologyChange change : changes) { OWLOntology changedOntology = change.getOntology(); if (!changedOntology.equals(owlOntology_)) { if (importClosure == null) { importClosure = owlOntology_.getImportsClosure(); } if (!importClosure.contains(changedOntology)) { LOGGER_.trace( "Ignoring the change not applicable to the current ontology: {}" + change); continue; } } if (!change.isAxiomChange()) { LOGGER_.trace( "Non-axiom change: {}\n The ontology will be reloaded.", change); // cannot handle non-axiom changes incrementally ontologyReloadRequired_ = true; } else { bufferedChangesLoader_.registerChange(change); } } if (!isBufferingMode_) flush(); }
@Override public Node<OWLClass> getTopClassNode() { LOGGER_.trace("getTopClassNode()"); checkInterrupted(); try { return getClassNode(objectFactory_.getOwlThing()); } catch (ElkUnsupportedReasoningTaskException e) { throw unsupportedOwlApiMethod("getTopClassNode()", e.getMessage()); } catch (ElkException e) { throw elkConverter_.convert(e); } catch (ElkRuntimeException e) { throw elkConverter_.convert(e); } }
@Override public Node<OWLObjectPropertyExpression> getBottomObjectPropertyNode() { LOGGER_.trace("getBottomObjectPropertyNode()"); checkInterrupted(); try { return getObjectPropertyNode( objectFactory_.getOwlBottomObjectProperty()); } catch (final ElkUnsupportedReasoningTaskException e) { throw unsupportedOwlApiMethod("getBottomObjectPropertyNode()", e.getMessage()); } catch (final ElkException e) { throw elkConverter_.convert(e); } catch (final ElkRuntimeException e) { throw elkConverter_.convert(e); } }
private void generate() { final OwlConverter owlConverter = OwlConverter.getInstance(); final ElkConverter elkConverter = ElkConverter.getInstance(); try { final ElkAxiom elkAxiom = owlConverter.convert(owlEntailment_); final EntailmentQueryResult result = elkReasoner_ .getInternalReasoner().isEntailed(elkAxiom); result.accept(ENTAILMENT_QUERY_RESULT_VISITOR); } catch (final ElkException e) { throw elkConverter.convert(e); } catch (final ElkRuntimeException e) { throw elkConverter.convert(e); } }
initReasoner(new ReasonerFactory().createReasoner(reasoner_, objectFactory_, config_)); bufferedChangesLoader_ = new OwlChangesLoaderFactory(
@Override public void dispose() { super.dispose(); elkReasoner_.removeListener(this); }
@Override public Node<OWLNamedIndividual> getSameIndividuals(OWLNamedIndividual arg0) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { LOGGER_.trace("getSameIndividuals(OWLNamedIndividual)"); checkInterrupted(); // TODO This needs to be updated when we support nominals return new OWLNamedIndividualNode(arg0); }
@Override public boolean isConsistent() throws ReasonerInterruptedException, TimeOutException { LOGGER_.trace("isConsistent()"); try { return !reasoner_.isInconsistent(); } catch (ElkUnsupportedReasoningTaskException e) { throw unsupportedOwlApiMethod("isConsistent()", e.getMessage()); } catch (ElkException e) { throw elkConverter_.convert(e); } catch (ElkRuntimeException e) { throw elkConverter_.convert(e); } }
@SuppressWarnings("static-method") ElkReasoner createElkReasoner(OWLOntology ontology, boolean isBufferingMode, OWLReasonerConfiguration config) throws IllegalConfigurationException { LOGGER_.trace("createElkReasoner(OWLOntology, boolean, OWLReasonerConfiguration)"); // here we check if the passed configuration also has ELK's parameters ElkReasonerConfiguration elkReasonerConfig; if (config != null) { if (config instanceof ElkReasonerConfiguration) { elkReasonerConfig = (ElkReasonerConfiguration) config; } else { elkReasonerConfig = new ElkReasonerConfiguration(config); } } else { elkReasonerConfig = new ElkReasonerConfiguration(); } return new ElkReasoner(ontology, isBufferingMode, elkReasonerConfig); } }
@Override public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { Set<OWLOntology> importClosure = null; for (OWLOntologyChange change : changes) { OWLOntology changedOntology = change.getOntology(); if (!changedOntology.equals(owlOntology_)) { if (importClosure == null) { importClosure = owlOntology_.getImportsClosure(); } if (!importClosure.contains(changedOntology)) { LOGGER_.trace( "Ignoring the change not applicable to the current ontology: {}" + change); continue; } } if (!change.isAxiomChange()) { LOGGER_.trace( "Non-axiom change: {}\n The ontology will be reloaded.", change); // cannot handle non-axiom changes incrementally ontologyReloadRequired_ = true; } else { bufferedChangesLoader_.registerChange(change); } } if (!isBufferingMode_) flush(); }