本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntologyManager.createOntology方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntologyManager.createOntology方法的具體用法?Java OWLOntologyManager.createOntology怎麽用?Java OWLOntologyManager.createOntology使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntologyManager
的用法示例。
在下文中一共展示了OWLOntologyManager.createOntology方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: translate
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
*
* @param gaf
* @return lego ontology
* @throws OWLException
* @throws UnknownIdentifierException
*/
public OWLOntology translate(GafDocument gaf) throws OWLException, UnknownIdentifierException {
final OWLOntologyManager m = graph.getManager();
OWLOntology lego = m.createOntology(IRI.generateDocumentIRI());
OWLOntology sourceOntology = graph.getSourceOntology();
OWLOntologyID ontologyID = sourceOntology.getOntologyID();
if (ontologyID != null) {
Optional<IRI> ontologyIRI = ontologyID.getOntologyIRI();
if (ontologyIRI.isPresent()) {
OWLDataFactory f = m.getOWLDataFactory();
OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(ontologyIRI.get());
m.applyChange(new AddImport(lego, importDeclaration ));
}
}
translate(gaf.getGeneAnnotations(), lego);
return lego;
}
示例2: inconsistentClass
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void inconsistentClass() throws Exception {
OWLOntologyManager owlManager = OWLManager
.createConcurrentOWLOntologyManager();
// creating an ontology
final OWLOntology ontology = owlManager.createOntology();
OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
// A subclass of bottom => A is inconsistent
owlManager.addAxiom(ontology,
factory.getOWLSubClassOfAxiom(a, factory.getOWLNothing()));
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, b));
}
示例3: getModuleFromAxioms
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Necessary toi construct a module for an arbitriary set of axioms
* @param moduleAxioms
* @param moduleUri
* @return
*/
public OWLOntology getModuleFromAxioms(Set<OWLAxiom> moduleAxioms, IRI moduleIri) {
OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
OWLOntology module=null;
try {
module = ontologyManager.createOntology(moduleIri);
List<OWLOntologyChange> ontoChanges = new ArrayList<OWLOntologyChange>();
for(OWLAxiom axiom : moduleAxioms) {
ontoChanges.add(new AddAxiom(module, axiom));
}
ontologyManager.applyChanges(ontoChanges);
}
catch(Exception e) {
System.out.println("Error creating module ontology from extende set of axioms.");
}
//System.out.println("Time create OWLOntology for module (s): " + (double)((double)fin-(double)init)/1000.0);
return module;
}
示例4: inconsistentOwlThing
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void inconsistentOwlThing() throws Exception {
OWLOntologyManager owlManager = OWLManager
.createConcurrentOWLOntologyManager();
// creating an ontology
final OWLOntology ontology = owlManager.createOntology();
OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
// top subclass bottom => inconsistent
owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(
factory.getOWLThing(), factory.getOWLNothing()));
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, b));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(
factory.getOWLObjectIntersectionOf(a, b),
factory.getOWLNothing()));
}
示例5: owlOntology
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Bean
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.INTERFACES)
public OWLMutableOntology owlOntology(PrefixManager prefixManager) throws OWLOntologyCreationException {
if (prefixManager.getDefaultPrefix() == null) {
throw new IllegalStateException("Default ontology prefix must not be null.");
}
OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
// Cast to a mutable ontology to pass OWLApi's strange checks
return (OWLMutableOntology) ontologyManager.createOntology(IRI.create(prefixManager.getDefaultPrefix()));
}
示例6: testTinyOntology4
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* <ol>
* <li>A \u2291 ⊥ ,</li>
* <li>B \u2291 A</li>
* </ol>
* ⊨
* <ul>
* <li>A ≡ B</li>
* <li>B ≡ ⊥</li>
* </ul>
*
* @throws OWLOntologyCreationException
* if something goes wrong with the ontology creation
*/
@Test
public void testTinyOntology4() throws OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
Set<OWLAxiom> axiomSet = new HashSet<>();
OWLClass a = createNewClass(factory, "A");
OWLClass b = createNewClass(factory, "B");
// 1
axiomSet.add(factory.getOWLSubClassOfAxiom(a, factory.getOWLNothing()));
// 2
axiomSet.add(factory.getOWLSubClassOfAxiom(b, a));
OWLOntology ontology = manager.createOntology(axiomSet);
JcelReasonerFactory reasonerFactory = new JcelReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
Set<OWLClass> equivalentsOfA = reasoner.getEquivalentClasses(a).getEntities();
Assert.assertTrue(equivalentsOfA.contains(b));
Set<OWLClass> equivalentsOfB = reasoner.getEquivalentClasses(b).getEntities();
Assert.assertTrue(equivalentsOfB.contains(a));
Assert.assertTrue(equivalentsOfB.contains(factory.getOWLNothing()));
Set<OWLClass> equivalentsOfBottom = reasoner.getEquivalentClasses(factory.getOWLNothing()).getEntities();
Assert.assertTrue(equivalentsOfBottom.contains(b));
verifyBottomAndTop(reasoner);
}
示例7: emptyEnumeration
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void emptyEnumeration() throws Exception {
OWLOntologyManager owlManager = OWLManager
.createConcurrentOWLOntologyManager();
// creating an ontology
final OWLOntology ontology = owlManager.createOntology();
OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
// ObjectOneOf() = owl:Nothing
owlManager.addAxiom(ontology,
factory.getOWLSubClassOfAxiom(a, factory.getOWLObjectOneOf()));
owlManager.addAxiom(ontology,
factory.getOWLSubClassOfAxiom(b, factory.getOWLNothing()));
owlManager.addAxiom(ontology,
factory.getOWLSubClassOfAxiom(factory.getOWLObjectOneOf(), c));
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, b));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(b, a));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, c));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(b, c));
}
示例8: saveToOntologyFile
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Saves a set of axioms to an OWL ontology file.
*
* @param axioms
* a set of OWLAxioms
* @param file
* the output destination
*/
public static void saveToOntologyFile(Set<OWLAxiom> axioms, File file) {
try {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology ontology = manager.createOntology();
manager.addAxioms(ontology, axioms);
saveToOntologyFile(ontology, file);
} catch (OWLOntologyCreationException e) {
throw new RuntimeException(e);
}
}
示例9: testUnsatisfiabilityDueToConflictingAxioms1
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Smth like:
* A subClassOf B
* A subClassOf C
* C disjoint with B
* ...
*/
public void testUnsatisfiabilityDueToConflictingAxioms1() {
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B")));
OWLClassExpression classC = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "C")));
OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indiv);
OWLSubClassOfAxiom axmAsubB = factory.getOWLSubClassOfAxiom(classA, classB);
OWLSubClassOfAxiom axmAsubC = factory.getOWLSubClassOfAxiom(classA, classC);
OWLDisjointClassesAxiom axmBdisC = factory.getOWLDisjointClassesAxiom(classB, classC);
try {
OWLOntology ontology = manager.createOntology();
manager.addAxiom(ontology, fact1);
manager.addAxiom(ontology, axmAsubB);
manager.addAxiom(ontology, axmAsubC);
manager.addAxiom(ontology, axmBdisC);
Wolpertinger wolpertinger = new Wolpertinger(ontology);
assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
fail();
}
}
示例10: emptyConjunction
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void emptyConjunction() throws Exception {
OWLOntologyManager owlManager = OWLManager
.createConcurrentOWLOntologyManager();
// creating an ontology
final OWLOntology ontology = owlManager.createOntology();
OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
// ObjectInteresectionOf() = owl:Thing
owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(a,
factory.getOWLObjectIntersectionOf()));
owlManager.addAxiom(ontology,
factory.getOWLSubClassOfAxiom(b, factory.getOWLThing()));
owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(
factory.getOWLObjectIntersectionOf(), c));
owlManager.addAxiom(ontology,
factory.getOWLSubClassOfAxiom(factory.getOWLThing(), d));
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, c));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, d));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(b, c));
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(b, d));
}
示例11: testDataProperyRenderer
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void testDataProperyRenderer() throws Exception {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
final IRI clsIRI = IRI.generateDocumentIRI();
final IRI propIRI = IRI.generateDocumentIRI();
// create a test ontology with one data property and one class
OWLDataFactory f = m.getOWLDataFactory();
OWLDataProperty prop = f.getOWLDataProperty(propIRI);
m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));
OWLClass cls = f.getOWLClass(clsIRI);
m.addAxiom(ontology, f.getOWLDeclarationAxiom(cls));
m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(clsIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-cls"))));
// graph and m3
OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
final UndoMetadata metadata = new UndoMetadata("foo-user");
UndoAwareMolecularModelManager m3 = createM3(graph);
final ModelContainer model = m3.generateBlankModel(metadata);
final OWLNamedIndividual individual = m3.createIndividual(model, cls, metadata);
m3.addDataProperty(model, individual, prop, f.getOWLLiteral(10), metadata);
MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(model, null, curieHandler);
final JsonModel jsonModel = r.renderModel();
assertEquals(1, jsonModel.individuals.length);
assertEquals(1, jsonModel.individuals[0].annotations.length);
{
JsonAnnotation ann = jsonModel.individuals[0].annotations[0];
assertEquals(propIRI.toString(), ann.key);
assertEquals("10", ann.value);
assertEquals("xsd:integer", ann.valueType);
}
}
示例12: testTinyOntology3
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* <ol>
* <li>\u22A4 \u2291 A ,</li>
* <li>A \u2291 B</li>
* </ol>
* ⊨
* <ul>
* <li>A ≡ B</li>
* <li>B ≡ \u22A4</li>
* </ul>
*
* @throws OWLOntologyCreationException
* if something goes wrong with the ontology creation
*/
@Test
public void testTinyOntology3() throws OWLOntologyCreationException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
Set<OWLAxiom> axiomSet = new HashSet<>();
OWLClass a = createNewClass(factory, "A");
OWLClass b = createNewClass(factory, "B");
// 1
axiomSet.add(factory.getOWLSubClassOfAxiom(factory.getOWLThing(), a));
// 2
axiomSet.add(factory.getOWLSubClassOfAxiom(a, b));
OWLOntology ontology = manager.createOntology(axiomSet);
JcelReasonerFactory reasonerFactory = new JcelReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
Set<OWLClass> equivalentsOfA = reasoner.getEquivalentClasses(a).getEntities();
Assert.assertTrue(equivalentsOfA.contains(b));
Set<OWLClass> equivalentsOfB = reasoner.getEquivalentClasses(b).getEntities();
Assert.assertTrue(equivalentsOfB.contains(a));
Assert.assertTrue(equivalentsOfB.contains(factory.getOWLThing()));
Set<OWLClass> equivalentsOfTop = reasoner.getEquivalentClasses(factory.getOWLThing()).getEntities();
Assert.assertTrue(equivalentsOfTop.contains(b));
verifyBottomAndTop(reasoner);
}
示例13: testUnsatisfiabilityDoToFixedDomain1
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Smth like
* A subClassOf r min 5 B
* But we have only a domain with 4 elements ...
*/
public void testUnsatisfiabilityDoToFixedDomain1() {
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B")));
OWLObjectPropertyExpression roleR = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "r")));
OWLNamedIndividual indA = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
OWLNamedIndividual indB = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "b")));
OWLNamedIndividual indC = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "c")));
OWLNamedIndividual indD = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "d")));
OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indA);
OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(classA, indB);
OWLIndividualAxiom fact3 = factory.getOWLClassAssertionAxiom(classA, indC);
OWLIndividualAxiom fact4 = factory.getOWLClassAssertionAxiom(classA, indD);
OWLObjectMinCardinality exprRmin5B = factory.getOWLObjectMinCardinality(5, roleR, classB);
OWLSubClassOfAxiom axmAsubRsomeB = factory.getOWLSubClassOfAxiom(classA, exprRmin5B);
try {
OWLOntology ontology = manager.createOntology();
manager.addAxiom(ontology, fact1);
manager.addAxiom(ontology, fact2);
manager.addAxiom(ontology, fact3);
manager.addAxiom(ontology, fact4);
manager.addAxiom(ontology, axmAsubRsomeB);
Wolpertinger wolpertinger = new Wolpertinger(ontology);
assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
fail();
}
}
示例14: setUpBeforeClass
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@BeforeClass
public static void setUpBeforeClass() throws Exception {
final URI ontologyUri = URI.create("http://krizik.felk.cvut.cz/ontologies/jopa/ConnectorFactoryTest");
final File targetFile = Files.createTempFile("connectortest", ".owl").toFile();
targetFile.deleteOnExit();
final OWLOntologyManager om = OWLManager.createOWLOntologyManager();
final OWLOntology o = om.createOntology(IRI.create(ontologyUri));
om.saveOntology(o, IRI.create(targetFile));
final URI physicalUri = targetFile.toURI();
storageProperties = OntologyStorageProperties.ontologyUri(ontologyUri).physicalUri(physicalUri).driver(
OwlapiDataSource.class.getCanonicalName()).build();
}
示例15: AnnotationCreator
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Constructs a new annotation creator.
*
* @param manager
* OWL ontology manager
* @param threshold
* threshold
* @param bayesianNetworkVariables
* variables of the input Bayesian network
* @throws OWLOntologyCreationException
* if something went wrong while creating the OWL ontology
*/
public AnnotationCreator(OWLOntologyManager manager, double threshold, Set<String> bayesianNetworkVariables)
throws OWLOntologyCreationException {
Objects.requireNonNull(manager);
Objects.requireNonNull(bayesianNetworkVariables);
this.owlOntology = manager.createOntology();
this.df = manager.getOWLDataFactory();
IRI probabilityIri = IRI.create(PROBABILITY_URI);
this.annotationProperty = manager.getOWLDataFactory().getOWLAnnotationProperty(probabilityIri);
this.threshold = threshold;
this.bayesianNetworkVariableSet.addAll(bayesianNetworkVariables);
this.bayesianNetworkVariableList.addAll(bayesianNetworkVariables);
}