@Override public OWLOntology loadOntology(IRI ontologyIRI) throws OWLOntologyCreationException { if (sealed) { throw new OntologyCreationNotAllowedException(); } return delegate.loadOntology(ontologyIRI); }
public RootOntologyIRISource(IRI rootPhysicalIri, OWLOntologyManager manager, boolean ignoreIriMappers) throws OWLOntologyCreationException { bindPhysicalIri(rootPhysicalIri); bindRootOntology(ignoreIriMappers ? manager.loadOntologyFromOntologyDocument(rootPhysicalIri) : manager.loadOntology(rootPhysicalIri)); bindTriplesProvider(manager); }
/** * Loads the ontology with given URI. * * @param uri the ontology uri * @return the ontology */ public static OWLOntology loadOntology( String uri ) { try { return manager.loadOntology( IRI.create( uri ) ); } catch( OWLOntologyCreationException e ) { throw new OWLRuntimeException( e ); } }
/** * Loads the ontology with given URI. * * @param uri the ontology uri * @return the ontology */ public static OWLOntology loadOntology( String uri ) { try { return manager.loadOntology( IRI.create( uri ) ); } catch( OWLOntologyCreationException e ) { throw new OWLRuntimeException( e ); } }
public static OWLOntology loadOntology(final OWLOntologyManager manager, final String uri) { try { return manager.loadOntology(IRI.create(uri)); } catch (final OWLOntologyCreationException e) { throw new OpenError(e); } }
public static OWLOntology loadOntology(final OWLOntologyManager manager, final String uri) { try { return manager.loadOntology(IRI.create(uri)); } catch (final OWLOntologyCreationException e) { throw new OpenError(e); } }
public static OWLOntology loadOntology(final OWLOntologyManager manager, final String uri) { try { return manager.loadOntology(IRI.create(uri)); } catch (final OWLOntologyCreationException e) { throw new OpenError(e); } }
public static void main(String[] argv) throws FileNotFoundException, OWLOntologyStorageException { String str_iri = "file:/usr/local/data/DataUMLS/fly_anatomy_XP.owl.zip"; OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); try { MOReRLrew MORe = new MOReRLrew(manager.loadOntology(IRI.create(str_iri))); //MOReReasoner MORe = new MOReReasoner(manager.loadOntology(IRI.create(str_iri))); long tClassification = System.currentTimeMillis(); MORe.precomputeInferences(InferenceType.CLASS_HIERARCHY); tClassification = System.currentTimeMillis() - tClassification; System.out.print("Time classification: " + tClassification); MORe.dispose(); } catch(Exception e){ e.printStackTrace(); } }
public static void main(String[] args) throws Exception { OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology schema = //man.loadOntology(IRI.create("http://downloads.dbpedia.org/2016-10/dbpedia_2016-10.nt")); man.loadOntology(IRI.create("file:///tmp/merged.ttl")); OWLOntologyKnowledgeSource sampleKS = new OWLAPIOntology(schema); sampleKS.init(); final long start = System.currentTimeMillis(); OWLAPIReasoner baseReasoner = new OWLAPIReasoner(sampleKS); baseReasoner.setReasonerImplementation(ReasonerImplementation.STRUCTURAL); baseReasoner.init(); ClosedWorldReasoner reasoner = new ClosedWorldReasoner(baseReasoner); reasoner.init(); System.out.println(PeriodFormat.getDefault().print(new Period(System.currentTimeMillis() - start))); }
@Override public void execute() throws Exception { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = manager.loadOntology(IRI.create(ontologyFile)); ClientRegistry registry = getClientRegistry(); if (registry.hasSuitableMetaData(ontology)) { Client client = registry.connectToServer(ontology); VersionedOntologyDocument vont = registry.getVersionedOntologyDocument(ontology); System.out.println("Server Location: " + vont.getServerDocument().getServerLocation()); System.out.println("Local Revision: " + vont.getRevision()); System.out.println("Latest server revision: " + client.evaluateRevisionPointer(vont.getServerDocument(), RevisionPointer.HEAD_REVISION)); } else { System.out.println("Could not connect to appropriate server - no known server metadata found."); } }
@Override public void execute() throws Exception { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = manager.loadOntology(IRI.create(ontologyFile)); ClientRegistry registry = getClientRegistry(); if (registry.hasSuitableMetaData(ontology)) { Client client = registry.connectToServer(ontology); VersionedOntologyDocument vont = registry.getVersionedOntologyDocument(ontology); ChangeMetaData metaData = getCommitComment(); ClientUtilities.commit(client, metaData, vont); System.out.println("Changes committed."); } else { System.out.println("Could not connect to appropriate server - no known server metadata found."); } }
public void createReasoner() { try { this.ontology.getOWLOntologyManager() .loadOntology(IRI.create(this.ontology.getOntologyID() .getOntologyIRI().toString())); } catch (OWLOntologyCreationException e) { throw new KlabRuntimeException(e); } }
@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(); } }
@Test public void circularOntologies_dontRecurseInfintely() throws Exception { OWLOntology ontology = manager.loadOntology(IRI.create("http://localhost:10000/circular_parent.owl")); producer.addOntologyStructure(manager, ontology); Optional<Long> parent = graph.getNode("http://example.org/ParentOntology"); Optional<Long> grandchild = graph.getNode("http://example.org/GrandChildOntology"); assertThat(graph.getRelationship(parent.get(), grandchild.get(), OwlRelationships.RDFS_IS_DEFINED_BY).isPresent(), is(true)); assertThat(graph.getRelationship(grandchild.get(), grandchild.get(), OwlRelationships.RDFS_IS_DEFINED_BY).isPresent(), is(true)); }
@Test public void ontologyStructure_isAdded() throws OWLOntologyCreationException { OWLOntology ontology = manager.loadOntology(IRI.create("http://localhost:10000/main.owl")); producer.addOntologyStructure(manager, ontology); Optional<Long> main = graph.getNode("http://example.org/MainOntology"); Optional<Long> child1 = graph.getNode("http://example.org/Child1"); Optional<Long> child2 = graph.getNode("http://example.org/Child2"); Optional<Long> grandchild = graph.getNode("http://example.org/GrandChild"); assertThat(main.isPresent(), is(true)); assertThat(child1.isPresent(), is(true)); assertThat(child2.isPresent(), is(true)); assertThat(grandchild.isPresent(), is(true)); assertThat(graph.getRelationship(child1.get(), main.get(), OwlRelationships.RDFS_IS_DEFINED_BY).isPresent(), is(true)); }
@Override public void execute() throws Exception { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLOntology ontology = manager.loadOntology(IRI.create(ontologyFile)); ClientRegistry registry = getClientRegistry(); if (registry.hasSuitableMetaData(ontology)) { Client client = registry.connectToServer(ontology); VersionedOntologyDocument vont = registry.getVersionedOntologyDocument(ontology); List<OWLOntologyChange> changes = ClientUtilities.getUncommittedChanges(client, vont); Console console = System.console(); new DiffRenderer().renderDiff(changes, client.getDocumentFactory().getOWLRenderer(), console.writer(), -1); } else { System.out.println("Could not connect to appropriate server - no known server metadata found."); } }
@Override public void testEntailment(final String entailmentFileURI, final boolean positiveEntailment) { try { final OWLOntology ont = _manager.loadOntology(IRI.create(entailmentFileURI)); ont.logicalAxioms().filter(axiom -> !_reasoner.isEntailed(axiom)).forEach(axiom -> assertFalse("Entailment failed for " + axiom, positiveEntailment)); assertTrue("All axioms entailed in negative entailment test", positiveEntailment); } catch (final OWLException e) { throw new OpenError(e); } }
public void testRenameOntology() throws OWLOntologyCreationException{ String ontologyURL = "http://protege.stanford.edu/plugins/owl/owl-library/koala.owl"; OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLDataFactory dataFactory = man.getOWLDataFactory(); OWLOntology ontology = man.loadOntology(IRI.create(ontologyURL)); OWLAxiomRenamer renamer = new OWLAxiomRenamer(dataFactory); Multiset<OWLAxiom> multiset = HashMultiset.create(); for (OWLAxiom axiom : ontology.getLogicalAxioms()) { OWLAxiom renamedAxiom = renamer.rename(axiom); multiset.add(renamedAxiom); // System.out.println(axiom + "-->" + renamedAxiom); } for (OWLAxiom owlAxiom : multiset.elementSet()) { System.out.println(owlAxiom + ": " + multiset.count(owlAxiom)); } }
private static void testOWLAPI(final String premiseURI, final String conclusionURI) { org.semanticweb.owlapi.model.OWLOntologyManager manager = null; try { manager = OWLManager.createOWLOntologyManager(); final OWLOntology premise = manager.loadOntology(IRI.create(premiseURI)); manager = OWLManager.createOWLOntologyManager(); final OWLOntology conclusion = manager.loadOntology(IRI.create(conclusionURI)); final OpenlletReasoner reasoner = new openllet.owlapi.OpenlletReasonerFactory().createReasoner(premise); assertTrue(reasoner.isEntailed(conclusion.axioms())); } catch (final OWLOntologyCreationException e) { throw new OpenError(e); } }
public void testLuigiFamilyOWLApi() throws Exception { final OWLOntologyManager manager = OWL._manager; final OWLOntology familyRef = manager.loadOntology(IRI.create(_base + "basicFamilyReference.owl")); final OWLOntology familyRules = manager.loadOntology(IRI.create(_base + "basicFamilyRules.owl")); final OWLOntology mergedOntology = OWL.Ontology(Stream.concat(familyRef.axioms(), familyRules.axioms())); final OpenlletReasoner reasoner = openllet.owlapi.OpenlletReasonerFactory.getInstance().createReasoner(mergedOntology); final OWLIndividual nella = OWL.Individual(_luigiFamily.resolve("#Nella")); final OWLObjectProperty hasUncle = OWL.ObjectProperty(_luigiFamily.resolve("#hasUncle")); final OWLIndividual dino = OWL.Individual(_luigiFamily.resolve("#Dino")); assertFalse(reasoner.isEntailed(OWL.propertyAssertion(nella, hasUncle, dino))); }