private void loadModuleType() { final String type = _options.getOption("type").getValueAsString(); if (type.equalsIgnoreCase("lower")) moduleType = ModuleType.TOP; else if (type.equalsIgnoreCase("upper")) moduleType = ModuleType.BOT; else if (type.equalsIgnoreCase("upper-of-lower")) moduleType = ModuleType.STAR; else if (type.equalsIgnoreCase("lower-of-upper")) moduleType = ModuleType.STAR; else throw new OpenlletCmdException("Unknown module type: " + type); }
protected KBLoader getLoader() { if (_loader != null) { return _loader; } final String loaderName = _options.getOption("loader").getValueAsString(); return getLoader(loaderName); }
private void loadMethod() { final String method = _options.getOption("method").getValueAsString(); if (method.equalsIgnoreCase("black")) { _useBlackBox = true; } else if (method.equalsIgnoreCase("glass")) { _useBlackBox = false; } else { throw new OpenlletCmdException("Unrecognized method: " + method); } }
@Override public void parseArgs(final String[] args) { super.parseArgs(args); setQueryFile(_options.getOption("query-file").getValueAsString()); setOutputFormat(_options.getOption("output-format").getValueAsString()); setQueryFormat(_options.getOption("query-format").getValueAsString()); setQueryEngine(_options.getOption("query-engine").getValueAsString()); OpenlletOptions.TREAT_ALL_VARS_DISTINGUISHED = !_options.getOption("bnode").getValueAsBoolean(); }
private void loadEntityNames() { final String signature = _options.getOption("signature").getValueAsString(); if (signature == null) throw new OpenlletCmdException("No signature provided"); entityNames = signature.split(" "); if (entityNames.length == 0) throw new OpenlletCmdException("No signature provided"); }
@Override public void run() { if (_options.getOption("persist").getValueAsBoolean()) runIncrementalClassify(); else runClassicClassify(); }
private void loadConfig() { final String configFile = _options.getOption("config").getValueAsString(); if (configFile != null) { try { final URL url = new URL("file:" + configFile); OpenlletOptions.load(url); } catch (final MalformedURLException e) { throw new OpenlletCmdException("Invalid URL given for the config file: " + configFile, e); } catch (final FileNotFoundException e) { throw new OpenlletCmdException("The specified configuration file cannot be found: " + configFile, e); } catch (final IOException e) { throw new OpenlletCmdException("I/O error while reading the configuration file : " + configFile, e); } } }
private void mapStatementTypes() final String statements = _options.getOption("statements").getValueAsString();
@Override public void parseArgs(final String[] args) { super.parseArgs(args); final String only = _options.getOption("only").getValueAsString(); if (only == null) { setDoRDF(true); setDoOWL(true); } else if (only.equalsIgnoreCase("RDF")) { setDoRDF(true); setDoOWL(false); } else if (only.equalsIgnoreCase("OWL")) { setDoRDF(false); setDoOWL(true); } else throw new OpenlletCmdException("Invalid argument to lint --only: " + only); setDoRootOnly(_options.getOption("root-only").getValueAsBoolean()); if (getInputFiles().length > 1) throw new OpenlletCmdException("lint doesn't handle multiple input files"); setInputOntologyPath(getInputFiles()[0]); setOutputOntologyPath(_options.getOption("fix").getValueAsString()); }
private TransactionAwareSingleExpGen getSingleExplanationGenerator() { if (_useBlackBox) { if (_options.getOption("inconsistent") != null) { if (!_options.getOption("inconsistent").getValueAsBoolean()) { return new BlackBoxExplanation(_reasoner.getRootOntology(), OpenlletReasonerFactory.getInstance(), _reasoner); } else { output("WARNING: black method cannot be used to explain inconsistency. Switching to glass."); return new GlassBoxExplanation(_reasoner); } } else { return new BlackBoxExplanation(_reasoner.getRootOntology(), OpenlletReasonerFactory.getInstance(), _reasoner); } } else { return new GlassBoxExplanation(_reasoner); } }
private void runLintForRDFXML() throws IOException { final RDFModelReader reader = new RDFModelReader(); RDFModel rootModel = null; try { rootModel = reader.read(_inputOntologyPath, !_doRootOnly); } catch (final Exception e) { throw new OpenlletCmdException(e); } final OWLSyntaxChecker checker = new OWLSyntaxChecker(); checker.setExcludeValidPunnings(_options.getOption("exclude-valid-punning").getValueAsBoolean()); final RDFLints lints = checker.validate(rootModel); output(lints.toString()); if (_outputOntologyPath != null && !_doOWL) { final List<Statement> missingStmts = lints.getMissingStatements(); rootModel.addAllStatementsWithExistingBNodesOnly(missingStmts); final RDFModelWriter writer = new RDFModelWriter(); writer.write(new FileOutputStream(new File(_outputOntologyPath)), rootModel); output("Saved to " + _outputOntologyPath); } }
@Override public void parseArgs(final String[] args) { super.parseArgs(args); _maxExplanations = _options.getOption("max").getValueAsNonNegativeInteger(); _owlApiLoader = (OWLAPILoader) getLoader("OWLAPI"); getKB(); _converter = new SatisfiabilityConverter(_owlApiLoader.getManager().getOWLDataFactory()); _reasoner = _owlApiLoader.getReasoner(); loadMethod(); loadNames(); }
/** * Performs classification using the incremental classifier (and persisted _data) */ private void runIncrementalClassify() { final String loaderName = _options.getOption("loader").getValueAsString(); if (!"OWLAPI".equals(loaderName)) _logger.log(Level.WARNING, "Ignoring -l " + loaderName + " option. When using --persist the only allowed loader is OWLAPI"); final OWLAPILoader loader = (OWLAPILoader) getLoader("OWLAPI"); loader.parse(getInputFiles()); final OWLOntology ontology = loader.getOntology(); final IncrementalClassifier incrementalClassifier = createIncrementalClassifier(ontology); if (!incrementalClassifier.isClassified()) { startTask("consistency check"); final boolean isConsistent = incrementalClassifier.isConsistent(); finishTask("consistency check"); if (!isConsistent) throw new OpenlletCmdException("Ontology is inconsistent, run \"openllet explain\" to get the reason"); startTask("classification"); incrementalClassifier.classify(); finishTask("classification"); } final TaxonomyPrinter<OWLClass> printer = new OWLClassTreePrinter(); printer.print(incrementalClassifier.getTaxonomy()); if (!_currentStateSaved) persistIncrementalClassifier(incrementalClassifier, ontology); }
_name3 = null; if ((option = _options.getOption("hierarchy")) != null) if ((option = _options.getOption("all-unsat")) != null) if ((option = _options.getOption("inconsistent")) != null) if ((option = _options.getOption("unsat")) != null) if ((option = _options.getOption("subclass")) != null) if ((option = _options.getOption("instance")) != null) if ((option = _options.getOption("property-value")) != null)
@Override public void run() _propertyName = _options.getOption("property").getValueAsString(); boolean filter = false; if (_options.getOption("filter").exists()) final String filterName = _options.getOption("filter").getValueAsString(); final OWLEntity filterClass = OntologyUtils.findEntity(filterName, loader.allOntologies()); if (filterClass == null) final boolean indParam = _options.getOption("individuals").getValueAsBoolean();
options.add(option); option = options.getOption("verbose"); option.setDescription("Print detailed exceptions and messages about the progress");