/** * Returns the string value as a boolean. If no _value _exists returns <code>false</code> by default. * * @return returns the string _value as a boolean */ protected boolean getValueAsBoolean() { final String value = getValueAsString(); return Boolean.parseBoolean(value); }
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); }
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); } }
protected KBLoader getLoader() { if (_loader != null) { return _loader; } final String loaderName = _options.getOption("loader").getValueAsString(); return getLoader(loaderName); }
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 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(); }
/** * Returns the option _value as an integer and verifies that it is in the given range. * * @param minAllowed Minimum allowed _value for the integer (inclusive) * @param maxAllowed Maximum allowed _value for the integer (inclusive) * @return an integer _value in the specified range * @throws OpenlletCmdException If the option _value does not exist, is a not a valid integer _value, or not in the specified range */ private int getValueAsInteger(final int minAllowed, final int maxAllowed) throws OpenlletCmdException { final String value = getValueAsString(); if (value == null) throw new OpenlletCmdException(String.format("The _value for option <%s> does not exist%n", _longOption)); try { final int intValue = Integer.parseInt(value); if (intValue < minAllowed) throw new OpenlletCmdException(String.format("The _value for option <%s> should be greater than or equal to %d but was: %d%n", _longOption, minAllowed, intValue)); if (intValue > maxAllowed) throw new OpenlletCmdException(String.format("The _value for option <%s> should be less than or equal to %d but was: %d%n", _longOption, maxAllowed, intValue)); return intValue; } catch (final NumberFormatException e) { throw new OpenlletCmdException(String.format("The _value for option <%s> is not a valid integer: %s%n", _longOption, value), e); } }
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); } } }
if (option != null && option.getValueAsString() != null) final String inputFormat = option.getValueAsString().toUpperCase();
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()); }
/** * 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); }
@Override public void run() entailmentFile = _options.getOption("entailment-file").getValueAsString(); findAll = _options.getOption("all").getValueAsBoolean();
final String unsatisfiable = option.getValueAsString(); if (unsatisfiable != null) final String subclass = option.getValueAsString(); if (subclass != null) final String instance = option.getValueAsString(); if (instance != null) final String optionValue = option.getValueAsString(); if (optionValue != null)
@Override public void run() _propertyName = _options.getOption("property").getValueAsString(); final String filterName = _options.getOption("filter").getValueAsString(); final OWLEntity filterClass = OntologyUtils.findEntity(filterName, loader.allOntologies()); if (filterClass == null)