/** * Loads a previously stored explanation from the specified input stream * @param is The input stream from where to read the explanation * @return The explanation that was read * @throws IllegalStateException if the input stream does not appear to contain a serialisation of an explanation. */ public static Explanation<OWLAxiom> load(InputStream is, Supplier<OWLOntologyManager> m) { try { OWLOntology ontology = m.get().loadOntologyFromOntologyDocument(new BufferedInputStream(is)); OWLDataFactory df = ontology.getOWLOntologyManager().getOWLDataFactory(); OWLAnnotationProperty entailmentMarkerAnnotationProperty = df.getOWLAnnotationProperty(ENTAILMENT_MARKER_IRI); Set<OWLAxiom> justificationAxioms = asSet(ontology.axioms().filter(ax -> isNotEntailment(entailmentMarkerAnnotationProperty, ax))); // Expected one and only one entailment axiom OWLAxiom entailment = ontology.axioms().filter(ax->isEntailment(entailmentMarkerAnnotationProperty, ax)).findAny() .orElseThrow(() -> new IllegalStateException("Not a serialisation of an Explanation")); return new Explanation<>(entailment, justificationAxioms); } catch (OWLOntologyCreationException e) { throw new RuntimeException(e); } }