Refine search
public EnrichmentServlet() { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology ont = null; try { ont = man.createOntology(); } catch (OWLOntologyCreationException e1) { e1.printStackTrace(); } sparul = new OWL2SPARULConverter(ont, false); dataFactory = man.getOWLDataFactory(); }
/*** * @param manager The ontology manager to use * @param ontology A string representing the ontology to load. This can be an URI or a file path * @return The loaded ontology * @throws OWLOntologyCreationException */ public static OWLOntology loadOntology(OWLOntologyManager manager, String ontology) throws OWLOntologyCreationException { logger.info(String.format("Loading ontology with owlapi: %s", ontology)); String origThreadName = Thread.currentThread().getName(); Thread.currentThread().setName("read - " + ontology); OWLOntology ont; if (validator.isValid(ontology)) { ont = manager.loadOntology(IRI.create(ontology)); } else if (new File(ontology).exists()){ ont = manager.loadOntologyFromOntologyDocument(new File(ontology)); } else { try { ont = manager.loadOntologyFromOntologyDocument(Resources.getResource(ontology).openStream()); } catch (Exception e) { throw new OWLOntologyCreationException("Failed to find ontology: " + ontology); } } logger.info(String.format("Finished loading ontology with owlapi: %s", ontology)); Thread.currentThread().setName(origThreadName); return ont; }
protected void loadOntology(String ontologyPath) { try { // Try ontologyPath as the path of a local file File f = new File(ontologyPath); IRI iri = IRI.create(f); ontology = manager.loadOntologyFromOntologyDocument(iri); } catch (Exception e) { // Try ontologyPath as an IRI IRI iri = IRI.create(ontologyPath); try { ontology = manager.loadOntologyFromOntologyDocument(iri); } catch (OWLOntologyCreationException ex) { printError("Could not load ontology: " + ex.getMessage()); } } }
public RLOntology(String directory, String ontologyName, boolean flag) { removeBottomRule = flag; manager = OWLManager.createOWLOntologyManager(); factory = manager.getOWLDataFactory(); inputOntology = manager.loadOntologyFromOntologyDocument(new File(documentIRI = directory + "/" + ontologyName)); ontologyIRI = inputOntology.getOntologyID().getOntologyIRI().toString(); manager.clearIRIMappers(); TOP = factory.getOWLClass(IRI.create(ontologyIRI + "#TOP")); outputOntology = manager.createOntology(IRI.create(rlOntologyIRI)); manager.setOntologyDocumentIRI(outputOntology, IRI.create(rlDocumentIRI)); restOntology = manager.createOntology(); } catch (OWLOntologyCreationException e) { e.printStackTrace();
if (willRedirectTotheWrongPlace(catalogManager, importedOntologyDocumentIRI, physicalLocation)) { OWLOntology activeOntology = editorKit.getModelManager().getActiveOntology(); addImportMapping(activeOntology, importedOntologyDocumentIRI, IRI.create(physicalLocation)); OWLImportsDeclaration decl = man.getOWLDataFactory().getOWLImportsDeclaration(importedOntologyDocumentIRI); if (!man.contains(importParameters.getOntologyID())) { try { OWLOntologyManager loadingManager = OWLManager.createConcurrentOWLOntologyManager(); loadingManager.getIRIMappers() .add(man.getIRIMappers()); ProgressDialogOntologyLoaderListener listener = new ProgressDialogOntologyLoaderListener(dlg, logger); loadingManager.addOntologyLoaderListener(listener); loadingManager.loadOntologyFromOntologyDocument( new IRIDocumentSource(IRI.create(physicalLocation)), new OWLOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT)); loadingManager.removeOntologyLoaderListener(listener); logger.error("There was a problem loading the ontology from {}. Error: {}", importedOntologyDocumentIRI, e.getMessage(), e); JOptionPane.showMessageDialog(editorKit.getOWLWorkspace(), "An error occurred whilst the ontology at " + importedOntologyDocumentIRI + " was being loaded.", "Error loading ontology", JOptionPane.ERROR_MESSAGE);
public static void main(String[] args) { try { UnparsableOntologyException.setIncludeStackTraceInMessage(true); OWLOntologyManager man = OWLManager.createOWLOntologyManager(); long t0 = System.currentTimeMillis(); // OWLOntology ont = man.loadOntologyFromOntologyDocument(URI.create("file:/Users/matthewhorridge/ontologies/Thesaurus.08.02d.owl.zip")); // OWLOntology ont = man.loadOntologyFromOntologyDocument(URI.create("file:/Users/matthewhorridge/Desktop/SNOMED-20090731.owl.zip")); OWLOntology ont = man.loadOntologyFromOntologyDocument(IRI.create("http://www.loa-cnr.it/ontologies/DUL.owl")); long t1 = System.currentTimeMillis(); dumpMemStats(); System.out.println("TIME: " + (t1 - t0)); System.gc(); System.gc(); System.gc(); dumpMemStats(); // for(OWLAnnotationAssertionAxiom ax : ont.getAxioms(AxiomType.ANNOTATION_ASSERTION)) { // System.out.println(ax); // } } catch (OWLOntologyCreationException e) { e.printStackTrace(); } }
factory = manager.getOWLDataFactory(); ontologyIRI = inputOntology.getOntologyID().getOntologyIRI().toString(); manager.clearIRIMappers(); TOP = factory.getOWLClass(IRI.create(ontologyIRI + "#TOP")); outputOntology = manager.createOntology(IRI.create(rlOntologyIRI)); interOntology = manager.createOntology(); restOntology = manager.createOntology(); } catch (OWLOntologyCreationException e) { e.printStackTrace();
/** * Serialize classifiation results as an OWL file * @param results Set of inferred subsumptions * @param man OWL Ontology Manager * @param ontDir Ontology directory * @param reasonerName Reasoner name * @return The file path to where the OWL file was saved */ @SuppressWarnings("unchecked") public static String serializeClassificationResults(Set<? extends OWLAxiom> results, OWLOntologyManager man, String outFile) { File output = new File(outFile); output.getParentFile().mkdirs(); IRI iri = IRI.create("file:" + output.getAbsolutePath()); try { man.saveOntology(man.createOntology((Set<OWLAxiom>) results, iri), new OWLFunctionalSyntaxOntologyFormat(), iri); } catch (OWLOntologyStorageException e) { e.printStackTrace(); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return iri.toString(); }
public OWLAPIOntologyCollector(String ontologyIRI, String physicalIRI){ this.ontologyIRI = IRI.create(ontologyIRI); this.physicalIRI = IRI.create(new File(physicalIRI)); SimpleIRIMapper mapper = new SimpleIRIMapper(this.ontologyIRI, this.physicalIRI); this.manager.getIRIMappers().add(mapper); try{ this.currentOntology = manager.createOntology(this.ontologyIRI); }catch(OWLOntologyCreationException e){ logger.error("FATAL failed to create Ontology " + this.ontologyIRI); e.printStackTrace(); } this.factory = manager.getOWLDataFactory(); }
public OWLGenericTools(final OWLGroup group, final OWLOntologyID ontologyID, final boolean isVolatile) throws OWLOntologyCreationException throw new OWLOntologyCreationException("Illegal character ' ' in name on [" + ontologyID.getOntologyIRI() + "]"); else if (ontologyID.getVersionIRI() != null && ontologyID.getVersionIRI().toString().indexOf(' ') != -1) throw new OWLOntologyCreationException("Illegal character ' ' in version on [" + ontologyID.getVersionIRI() + "]"); try _ontology = manager.loadOntologyFromOntologyDocument(file); _ontology = manager.createOntology(ontologyID);// Maybe we should create it.
public boolean isParseable(String ontFile) { boolean isParseable = false; File f = new File(ontFile); if(!f.exists()) System.err.println("\tThe given ontology filepath '" + ontFile + "' does not point to a valid file"); else { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); try{ ont = man.loadOntologyFromOntologyDocument(f); } catch(OWLOntologyCreationException e) { System.err.println("\tError parsing ontology file '" + ontFile + "' using the OWL API v" + VersionInfo.getVersionInfo().getVersion() + ":"); e.printStackTrace(); } if(ont != null) isParseable = true; } return isParseable; }
public static void main(@NonNull String[] args) { if (args.length > 1) Usage(); Optional<@NonNull String> owlFilename = args.length == 0 ? Optional.<@NonNull String>empty() : Optional.of(args[0]); Optional<@NonNull File> owlFile = (owlFilename != null && owlFilename.isPresent()) ? Optional.of(new File(owlFilename.get())) : Optional.<@NonNull File>empty(); try { OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = owlFile.isPresent() ? ontologyManager.loadOntologyFromOntologyDocument(owlFile.get()) : ontologyManager.createOntology(); SWRLRuleEngine ruleEngine = SWRLAPIFactory.createSWRLRuleEngine(ontology); ruleEngine.infer(); } catch (OWLOntologyCreationException e) { if (owlFile.isPresent()) System.err.println("Error creating OWL ontology from file " + owlFile.get().getAbsolutePath() + ": " + ( e.getMessage() != null ? e.getMessage() : "")); else System.err.println("Error creating OWL ontology: " + (e.getMessage() != null ? e.getMessage() : "")); System.exit(-1); } catch (SWRLAPIException e) { System.err.println("SWRLAPI error: " + (e.getMessage() != null ? e.getMessage() : "")); System.exit(-1); } }
public OWLOntology getGeneratedOntology(){ OWLOntology ontology = null; try { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); ontology = man.createOntology(learnedOWLAxioms); } catch (OWLOntologyCreationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ontology; }
manager = OWLManager.createOWLOntologyManager(); ontology = manager.loadOntologyFromOntologyDocument(file); factory = manager.getOWLDataFactory(); } catch (OWLOntologyCreationException e) { e.printStackTrace();
OWLNamedIndividual jean = NamedIndividual("Jean", pm); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ont = Ontology( manager, ObjectPropertyDomain(hasMother, person) ); manager.saveOntology(ont, System.out); manager.saveOntology(ont, IRI.create("file:/tmp/out.txt")); e.printStackTrace();
compmodule_onto = manager.createOntology(botModExtractor.extract(compSignature),IRI.create(iri_compmodule_ontology)); e.printStackTrace();
boolean stateImportsHandling = manager.isSilentMissingImportsHandling(); manager.setSilentMissingImportsHandling(true); manager.addMissingImportListener(missingImportListener); owlontology=manager.loadOntology(IRI.create(location)); } catch (OWLOntologyCreationException e) { throw e; String[] missuris = new String[missing.size()]; missuris = missing.toArray(missuris); throw new OWLOntologyCreationException( "There are missing imports: " + Arrays.toString(missuris));
public static OWLOntology loadOntology(String fileName) { AutoIRIMapper mapper = new AutoIRIMapper(new File(fileName.substring(0, fileName.lastIndexOf('/'))), false); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); manager.addIRIMapper(mapper); //System.out.println(mapper.getDocumentIRI(IRI.create("http://semantics.crl.ibm.com/univ-bench-dl.owl"))); OWLOntology ontology = null; try { ontology = manager.loadOntologyFromOntologyDocument(new File(fileName)); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } // manager.removeIRIMapper(mapper); return ontology; }
@Override public void run(Reasoner hermit,StatusOutput status,PrintWriter output,boolean ignoreOntologyPrefixes) { status.log(2,"Checking whether the loaded ontology entails the conclusion ontology"); OWLOntologyManager m=OWLManager.createOWLOntologyManager(); try { OWLOntology conclusions = m.loadOntology(conclusionIRI); status.log(2,"Conclusion ontology loaded."); EntailmentChecker checker=new EntailmentChecker(hermit, m.getOWLDataFactory()); boolean isEntailed=checker.entails(conclusions.getLogicalAxioms()); status.log(2,"Conclusion ontology is "+(isEntailed?"":"not ")+"entailed."); output.println(isEntailed); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } output.flush(); } }
OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology allOntology = manager.createOntology(IRI.generateDocumentIRI(), new HashSet<OWLOntology>(owlAPIOntologies)); addImports.add(new AddImport(allOntology, i)); manager.applyChanges(addImports); logger.info("Ontologies merged. Complete ontology created"); return allOntology; } catch (OWLOntologyCreationException e1) { String message = "OWLOntologyCreationException complete ontology NOT created. "; logger.error(message + e1.getMessage()); throw new ComponentInitException(message);