@Test public void complexInconsistent() { _kb = new OWLAPILoader().createKB(MiscTests._base + "one+one-inconsistent.owl"); assertFalse(_kb.isConsistent()); }
private static void testProperty(final String ontologyURI, final String propertyURI) { final OWLAPILoader loader = new OWLAPILoader(); final KnowledgeBase kb = loader.createKB(new String[] { ontologyURI }); final OWLEntity entity = OntologyUtils.findEntity(propertyURI, loader.allOntologies()); if (entity == null) throw new IllegalArgumentException("Property not found: " + propertyURI); if (!(entity instanceof OWLObjectProperty)) throw new IllegalArgumentException("Not an object property: " + propertyURI); if (!EntitySearcher.isTransitive((OWLObjectProperty) entity, loader.allOntologies())) throw new IllegalArgumentException("Not a transitive property: " + propertyURI); final ATermAppl p = ATermUtils.makeTermAppl(entity.getIRI().toString()); testDeprecatedTaxonomy(kb, p); }
public OWLAPILoader() { _manager.setOntologyLoaderConfiguration(_manager.getOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT)); _manager.addMissingImportListener(new MissingImportListener() { /** * TODO * * @since */ private static final long serialVersionUID = -1580704502184270618L; @Override public void importMissing(final MissingImportEvent event) { if (!_ignoreImports) { final IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } }); clear(); }
private void extractModule() { final Set<OWLEntity> entities = new HashSet<>(); for (final String entityName : entityNames) { final OWLEntity entity = OntologyUtils.findEntity(entityName, loader.allOntologies()); if (entity == null) throw new OpenlletCmdException("Entity not found in ontology: " + entityName); entities.add(entity); } final Set<OWLAxiom> module = ModularityUtils.extractModule(loader.getOntology(), entities, moduleType); try { final OWLOntology moduleOnt = loader.getManager().createOntology(module); loader.getManager().saveOntology(moduleOnt, new RDFXMLDocumentFormat(), new SystemOutDocumentTarget()); } catch (final OWLException e) { throw new OpenError(e); } } }
if (loaderName.equalsIgnoreCase("OWLAPI")) _loader = new OWLAPILoader();
@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); }
if (unsatisfiable != null) _name1 = OntologyUtils.findEntity(unsatisfiable, _owlApiLoader.allOntologies()); if (names.length != 2) { throw new OpenlletCmdException("Invalid format for subclass option: " + subclass); } _name1 = OntologyUtils.findEntity(names[0], _owlApiLoader.allOntologies()); _name2 = OntologyUtils.findEntity(names[1], _owlApiLoader.allOntologies()); if (names.length != 2) { throw new OpenlletCmdException("Invalid format for instance option: " + instance); } _name1 = OntologyUtils.findEntity(names[0], _owlApiLoader.allOntologies()); _name2 = OntologyUtils.findEntity(names[1], _owlApiLoader.allOntologies()); if (names.length != 3) { throw new OpenlletCmdException("Invalid format for property-value option: " + optionValue); } _name1 = OntologyUtils.findEntity(names[0], _owlApiLoader.allOntologies()); _name2 = OntologyUtils.findEntity(names[1], _owlApiLoader.allOntologies()); if (_name2.isOWLObjectProperty()) _name3 = OntologyUtils.findEntity(names[2], _owlApiLoader.allOntologies()); if (_name3 == null)
public Collection<Result<Task>> profile(final String... files) final KBLoader loader = (_loaderType == LoaderType.JENA) ? new JenaLoader() : new OWLAPILoader();
final OpenlletReasoner reasoner = loader.getReasoner(); verbose(entailmentFile); final IRI entailmentFileURI = IRI.create(FileUtils.toURI(entailmentFile)); entailmentOntology = loader.getManager().loadOntology(entailmentFileURI);
@Test public void complexAllInfSat() { _kb = new OWLAPILoader().createKB(MiscTests._base + "one+one-consistent-and-all-inf-sat.owl"); assertTrue(_kb.isConsistent()); assertTrue(_kb.getUnsatisfiableClasses().isEmpty()); }
final OWLAPILoader loader = new OWLAPILoader(); final KnowledgeBase kb = loader.createKB(getInputFiles()); final OWLEntity entity = OntologyUtils.findEntity(_propertyName, loader.allOntologies()); throw new OpenlletCmdException("Not an object property: " + _propertyName); if (!EntitySearcher.isTransitive((OWLObjectProperty) entity, loader.allOntologies())) throw new OpenlletCmdException("Not a transitive property: " + _propertyName); final OWLEntity filterClass = OntologyUtils.findEntity(filterName, loader.allOntologies()); if (filterClass == null) throw new OpenlletCmdException("Filter class not found: " + filterName);
public OWLAPILoader() { _manager.setOntologyLoaderConfiguration(_manager.getOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT)); _manager.addMissingImportListener(new MissingImportListener() { /** * TODO * * @since */ private static final long serialVersionUID = -1580704502184270618L; @Override public void importMissing(final MissingImportEvent event) { if (!_ignoreImports) { final IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } }); clear(); }
@Test public void complexAllUnsat() { _kb = new OWLAPILoader().createKB(MiscTests._base + "one+one-consistent-but-all-unsat.owl"); assertTrue(_kb.isConsistent()); assertEquals(_kb.getClasses(), _kb.getUnsatisfiableClasses()); }
public OWLAPILoader() { _manager.setOntologyLoaderConfiguration(_manager.getOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT)); _manager.addMissingImportListener(new MissingImportListener() { /** * TODO * * @since */ private static final long serialVersionUID = -1580704502184270618L; @Override public void importMissing(final MissingImportEvent event) { if (!_ignoreImports) { final IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } }); clear(); }
@Test public void testOWLAPILoader() { final KnowledgeBase kb = new OWLAPILoader().createKB(DATA1_RDF); final ATermAppl i = ATermUtils.makeTermAppl("http://example.org#i"); final ATermAppl label = ATermUtils.makeTermAppl(RDFS.label.getURI()); final ATermAppl o1 = ATermUtils.makeStringLiteral("o1"); final Set<ATermAppl> actual = kb.getAnnotations(i, label); kb.getAnnotationSubjects(); final Set<ATermAppl> expected = new HashSet<>(); expected.add(o1); assertEquals(expected, actual); }