/** * Stores the _current state of the incremental classifier to a file (the file name is determined automatically based on ontology's IRI). * * @param incrementalClassifier the incremental classifier to be stored * @param ontology the ontology */ private void persistIncrementalClassifier(final IncrementalClassifier incrementalClassifier, final OWLOntology ontology) { final File saveFile = determineSaveFile(ontology); try { verbose("Saving the state of the classifier to " + saveFile); final FileOutputStream outputStream = new FileOutputStream(saveFile); IncrementalClassifierPersistence.save(incrementalClassifier, outputStream); } catch (final IOException e) { _logger.log(Level.WARNING, "Unable to persist the current classifier state.", e); } }
/** * Creates incremental classifier by either creating it from scratch or by reading its state from file (if there exists such a state) * * @param ontology the ontology (the _current state of it) * @return the incremental classifier */ private IncrementalClassifier createIncrementalClassifier(final OWLOntology ontology) { final File saveFile = determineSaveFile(ontology); IncrementalClassifier result = null; // first try to restore the classifier from the file (if one exists) if (saveFile.exists()) result = loadIncrementalClassifier(ontology, saveFile); // if it was not possible to restore the classifier, create one from scratch if (result == null) result = new IncrementalClassifier(ontology); result.getReasoner().getKB().setTaxonomyBuilderProgressMonitor(OpenlletOptions.USE_CLASSIFICATION_MONITOR.create()); return result; }