@Override public Collection<OWLOntology> loadOntologies() { Collection<OWLOntology> ontologies = new ArrayList<>(); int i = 0; for (File file : directory.listFiles()) { try { OWLOntology ontology = man.loadOntologyFromOntologyDocument(file); ontologies.add(ontology); if(i == 10) break; } catch (OWLOntologyCreationException e) { e.printStackTrace(); } } return ontologies; } }
public void importMissing(MissingImportEvent event) { if (!ignoreImports) { IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } });
@Override public void importMissing(final MissingImportEvent event) { if (!_ignoreImports) { final IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } });
@Override public void importMissing(MissingImportEvent event) { if (!ignoreImports) { IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } });
@Override public void importMissing(final MissingImportEvent event) { if (!_ignoreImports) { final IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } });
@Override public void importMissing(final MissingImportEvent event) { if (!_ignoreImports) { final IRI importURI = event.getImportedOntologyURI(); System.err.println("WARNING: Cannot import " + importURI); event.getCreationException().printStackTrace(); } } });
OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology localOntology=null; File file=new File("ontology/pizza.owl"); if (file == null) return; //loading the ontology try { localOntology = manager.loadOntologyFromOntologyDocument(file); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } //get logical axioms Set<OWLLogicalAxiom> ax = localOntology.getLogicalAxioms();
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; }
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; }
private void printNTriplesSyntax(List<OWLAxiom> axioms){ try { System.out.println("ENRICHMENT["); Model model = OwlApiJenaUtils.getModel(OWLManager.createOWLOntologyManager().createOntology(new HashSet<>(axioms))); model.write(System.out, "N-TRIPLES"); System.out.println("]"); } catch (OWLOntologyCreationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void printTurtleSyntax(List<OWLAxiom> axioms){ try { System.out.println("ENRICHMENT["); Model model = OwlApiJenaUtils.getModel(OWLManager.createOWLOntologyManager().createOntology(new HashSet<>(axioms))); model.write(System.out, "TURTLE"); System.out.println("]"); } catch (OWLOntologyCreationException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
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; }
Model getModel(List<OWLAxiom> axioms) { try { OWLOntology ontology = OWLManager.createOWLOntologyManager().createOntology(new HashSet<>(axioms)); Model model = OwlApiJenaUtils.getModel(ontology); model.setNsPrefix("enr", "http://www.dl-learner.org/enrichment.owl#"); return model; } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return null; }
private String render(OWLAxiom axiom){ try { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology ontology = man.createOntology(); man.addAxiom(ontology, axiom); StringWriter sw = new StringWriter(); FunctionalSyntaxObjectRenderer r = new FunctionalSyntaxObjectRenderer(ontology, sw); axiom.accept(r); return sw.toString(); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return null; }
public OWLXMLRenderer() { try { OWLOntology ont = OWLManager.createOWLOntologyManager().createOntology(IRI.create("http://dl-learner.org/ontology/")); sw = new StringWriter(); OWLXMLWriter oxw = new OWLXMLWriter(sw, ont); delegate = new OWLXMLObjectRenderer(oxw); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } }
@Override public void flush() { super.flush(); try { reasoner = factory.createReasoner(configurationManager.buildOntopSQLOWLAPIConfiguration(getRootOntology())); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } }
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(); }
/** * Converts an OWL API object to an OWL/XML syntax string. * * @param obj Input OWL object. * @return OWL/XML syntax string. */ public static String toOWLXMLSyntax(OWLObject obj) { StringWriter sw = new StringWriter(); try { OWLXMLWriter oxw = new OWLXMLWriter(sw, OWLManager.createOWLOntologyManager().createOntology(IRI.create("http://example.com/"))); OWLXMLObjectRenderer renderer = new OWLXMLObjectRenderer(oxw); obj.accept(renderer); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return sw.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(); }
protected void loadOntology() { // clear status // System.out.print("Clearing before loading."); clearStatus(); try { if (normalizeAxioms) processInputOntology(); else filterOntology(); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } // include lost signature includeLostSignature(); }