本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntologyManager.getOntology方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntologyManager.getOntology方法的具體用法?Java OWLOntologyManager.getOntology怎麽用?Java OWLOntologyManager.getOntology使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntologyManager
的用法示例。
在下文中一共展示了OWLOntologyManager.getOntology方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testChangesToOtherOntologies
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Testing correctness of the reasoner when changes are made to other, imported or not, ontologies
*
*/
@Test
public void testChangesToOtherOntologies() throws Exception {
OWLOntologyManager man = TestOWLManager.createOWLOntologyManager();
OWLDataFactory dataFactory = man.getOWLDataFactory();
// set up resolution of prefixes
PrefixManager pm = new DefaultPrefixManager();
pm.setDefaultPrefix("http://www.example.com/main#");
pm.setPrefix("A:", "http://www.example.com/A#");
pm.setPrefix("B:", "http://www.example.com/B#");
// define query classes
OWLClass mainY = dataFactory.getOWLClass(":Y", pm);
OWLClass extA = dataFactory.getOWLClass("A:A", pm);
OWLClass extB = dataFactory.getOWLClass("B:B", pm);
OWLClass extC = dataFactory.getOWLClass("B:C", pm);
// loading the root ontology
OWLOntology root = loadOntology(man, "root.owl");
// the imported ontologies must be loaded
OWLOntology ontoA = man.getOntology(IRI.create("http://www.example.com/A"));
OWLOntology ontoB = man.getOntology(IRI.create("http://www.example.com/B"));
// Create an ELK reasoner.
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(root);
try {
assertTrue(reasoner.getSuperClasses(extA, false).containsEntity(
extC));
assertTrue(reasoner.getSuperClasses(mainY, false).containsEntity(
extC));
// ************************************
// ** removing an axiom "A:A is-a B:B" from impA
// ************************************
OWLAxiom axiom = dataFactory.getOWLSubClassOfAxiom(extA, extB);
man.removeAxiom(ontoA, axiom);
reasoner.flush();
assertFalse(reasoner.getSuperClasses(extA, false).containsEntity(
extC));
// put it back
man.addAxiom(ontoA, axiom);
reasoner.flush();
assertTrue(reasoner.getSuperClasses(extA, false).containsEntity(
extC));
// ************************************
// ** removing an axiom "B:B is-a B:C" from impB
// ************************************
axiom = dataFactory.getOWLSubClassOfAxiom(extB, extC);
man.removeAxiom(ontoB, axiom);
reasoner.flush();
assertFalse(reasoner.getSuperClasses(mainY, false).containsEntity(
extC));
}
finally {
reasoner.dispose();
}
}