本文整理匯總了Java中org.semanticweb.owlapi.model.OWLOntologyManager.addAxiom方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLOntologyManager.addAxiom方法的具體用法?Java OWLOntologyManager.addAxiom怎麽用?Java OWLOntologyManager.addAxiom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLOntologyManager
的用法示例。
在下文中一共展示了OWLOntologyManager.addAxiom方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testUnsatifiabilityDueToClashInABoxAssertions
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Atomic clash
*/
public void testUnsatifiabilityDueToClashInABoxAssertions() {
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLClassExpression expr1 = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
OWLClassExpression expr2 = factory.getOWLObjectComplementOf(expr1);
OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(expr1, indiv);
OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(expr2, indiv);
try {
OWLOntology ontology = manager.createOntology();
manager.addAxiom(ontology, fact1);
manager.addAxiom(ontology, fact2);
Wolpertinger wolpertinger = new Wolpertinger(ontology);
assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
fail();
}
}
示例2: applyChanges
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Override
public void applyChanges(final Iterable<OWLAxiom> changes,
final IncrementalChangeType type) {
// the changes are applied indirectly by modifying the ontology
final OWLOntologyManager manager = testOntology_
.getOWLOntologyManager();
for (OWLAxiom axiom : changes) {
switch (type) {
case ADD:
manager.addAxiom(testOntology_, axiom);
break;
case DELETE:
manager.removeAxiom(testOntology_, axiom);
break;
}
}
standardReasoner_.flush();
incrementalReasoner_.flush();
}
示例3: synonym
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Add an synonym annotation, plus an annotation on that annotation
* that specified the type of synonym. The second annotation has the
* property oio:hasSynonymType.
*
* @param ontology the current ontology
* @param subject the subject of the annotation
* @param type the IRI of the type of synonym
* @param property the IRI of the annotation property.
* @param value the literal value of the synonym
* @return the synonym annotation axiom
*/
protected static OWLAnnotationAssertionAxiom synonym(
OWLOntology ontology, OWLEntity subject,
OWLAnnotationValue type,
OWLAnnotationProperty property,
OWLAnnotationValue value) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLAnnotationProperty hasSynonymType =
dataFactory.getOWLAnnotationProperty(
format.getIRI("oio:hasSynonymType"));
OWLAnnotation annotation =
dataFactory.getOWLAnnotation(hasSynonymType, type);
Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
annotations.add(annotation);
OWLAnnotationAssertionAxiom axiom =
dataFactory.getOWLAnnotationAssertionAxiom(
property, subject.getIRI(), value,
annotations);
manager.addAxiom(ontology, axiom);
return axiom;
}
示例4: inconsistentIndividual
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void inconsistentIndividual() throws Exception {
OWLOntologyManager owlManager = OWLManager
.createConcurrentOWLOntologyManager();
// creating an ontology
final OWLOntology ontology = owlManager.createOntology();
OWLNamedIndividual ind = factory
.getOWLNamedIndividual(IRI.create("http://example.org/i"));
OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
// ind instance of bottom => inconsistent
owlManager.addAxiom(ontology, factory
.getOWLClassAssertionAxiom(factory.getOWLNothing(), ind));
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: emptyDisjointUnion
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void emptyDisjointUnion() 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"));
// DisjointUnion(A ) = EquivalentClasses(A owl:Nothing)
owlManager.addAxiom(ontology, factory.getOWLDisjointUnionAxiom(a,
Collections.<OWLClassExpression> emptySet()));
owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(b, b));
final OWLProver prover = OWLAPITestUtils.createProver(ontology);
prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);
ProofTestUtils.provabilityTest(prover,
factory.getOWLSubClassOfAxiom(a, b));
}
示例6: parseRow
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private void parseRow(String[] row) {
OWLDataFactory df = graph.getDataFactory();
OWLOntologyManager mgr = graph.getManager();
String geneSetId = row[0];
IRI geneSetIRI = IRI.create(prefix + geneSetId);
String desc = row[1];
OWLClass geneSetCls = df.getOWLClass(geneSetIRI);
OWLAxiom ax = df.getOWLAnnotationAssertionAxiom(df.getRDFSLabel(),geneSetIRI, literal(desc));
mgr.addAxiom(graph.getSourceOntology(), ax);
// assume each value is an entity, e.g. gene
for (int i=2; i < row.length; i++) {
OWLNamedIndividual individual = df.getOWLNamedIndividual(IRI.create(prefix + row[i]));
mgr.addAxiom(graph.getSourceOntology(), df.getOWLClassAssertionAxiom(geneSetCls, individual));
}
}
示例7: addElementLabels
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public static void addElementLabels(OWLOntology ont, File file) throws IOException {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLDataFactory df = m.getOWLDataFactory();
List<String> lines = FileUtils.readLines(file);
for (String line : lines) {
if (line.startsWith("#"))
continue;
String[] colVals = line.split("\t");
if (colVals.length != 2) {
throw new IOException("Incorrect number of value: "+line);
}
IRI i = getIRIById(colVals[0]);
OWLAnnotation ann = df.getOWLAnnotation(df.getRDFSLabel(), df.getOWLLiteral(colVals[1]));
m.addAxiom(ont, df.getOWLAnnotationAssertionAxiom(i, ann));
}
}
示例8: cacheInformationContentInOntology
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Override
public OWLOntology cacheInformationContentInOntology() throws OWLOntologyCreationException, UnknownOWLClassException {
OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager();
OWLDataFactory df = mgr.getOWLDataFactory();
OWLOntology o = mgr.createOntology();
OWLAnnotationProperty p = df.getOWLAnnotationProperty(IRI.create(icIRIString));
for (OWLClass c : getSourceOntology().getClassesInSignature()) {
Double ic = getInformationContentForAttribute(c);
if (ic != null) {
mgr.addAxiom(o,
df.getOWLAnnotationAssertionAxiom(p,
c.getIRI(),
df.getOWLLiteral(ic)));
}
}
return o;
}
示例9: annotate
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Convenience method for adding an annotation assertion to the
* ontology.
*
* @param ontology the current ontology
* @param subject the subject of the annotation
* @param property the annotation property
* @param value the annotation value
* @return the annotation axiom
*/
protected static OWLAnnotationAssertionAxiom annotate(
OWLOntology ontology,
OWLEntity subject,
OWLAnnotationProperty property,
OWLAnnotationValue value) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
OWLAnnotationAssertionAxiom axiom =
dataFactory.getOWLAnnotationAssertionAxiom(
property, subject.getIRI(), value);
manager.addAxiom(ontology, axiom);
return axiom;
}
示例10: executeDLQuery
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
* Execute the DL query on the given ontology graph. Uses the factory to create
* the {@link OWLReasoner} for an internal query ontology.
*
* @param dlQuery
* @param graph
* @param reasonerFactory
* @return set of {@link OWLClass} which
* @throws OWLParserException
* @throws OWLOntologyCreationException
*/
public static Set<OWLClass> executeDLQuery(String dlQuery, OWLGraphWrapper graph,
OWLReasonerFactory reasonerFactory) throws OWLParserException, OWLOntologyCreationException
{
// create parser and parse DL query string
ManchesterSyntaxTool parser = null;
OWLClassExpression ce;
try {
parser = new ManchesterSyntaxTool(graph.getSourceOntology(), graph.getSupportOntologySet());
ce = parser.parseManchesterExpression(dlQuery);
} finally {
// always dispose parser to avoid a memory leak
if (parser != null) {
parser.dispose();
}
}
// create query ontology
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology queryOntology = m.createOntology(IRI.generateDocumentIRI(), graph.getAllOntologies());
OWLDataFactory f = m.getOWLDataFactory();
OWLClass qc = f.getOWLClass(IRI.create("http://owltools.org/Q"));
OWLEquivalentClassesAxiom ax = f.getOWLEquivalentClassesAxiom(ce, qc);
m.addAxiom(queryOntology, ax);
Set<OWLClass> subset = executeQuery(ce, queryOntology, reasonerFactory);
if(subset.isEmpty()) {
LOG.warn("No classes found for query subclass of:"+dlQuery);
}
return subset;
}
示例11: 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();
}
}
示例12: modifyInferredAxiom
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private static OWLAxiom modifyInferredAxiom(OWLAxiom axiom, OWLOntology ontology, boolean add) {
final OWLOntologyManager manager = ontology.getOWLOntologyManager();
final OWLDataFactory factory = manager.getOWLDataFactory();
final OWLAxiom newAxiom = updateInferredAxiom(axiom, factory, add);
// update ontology
manager.removeAxiom(ontology, axiom);
manager.addAxiom(ontology, newAxiom);
return newAxiom;
}
示例13: 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));
}
示例14: addObjectProperty
import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private void addObjectProperty(OWLObjectProperty p, OWLOntology xOnt) {
if (xOnt.getDeclarationAxioms(p).size() > 0) {
return;
}
OWLOntologyManager m = ontology.getOWLOntologyManager();
OWLDataFactory df = m.getOWLDataFactory();
m.addAxiom(xOnt, df.getOWLDeclarationAxiom(p));
for (OWLAxiom ax : ontology.getAxioms(p, Imports.EXCLUDED)) {
m.addAxiom(xOnt, ax);
}
// TODO
}
示例15: 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));
}