本文整理了Java中openllet.owlapi.OWL
类的一些代码示例,展示了OWL
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OWL
类的具体详情如下:
包路径:openllet.owlapi.OWL
类名称:OWL
[英]Description: Utility class to generate OWL concepts in a concise and readable way.
Copyright: Copyright (c) 2007
Company: Clark & Parsia, LLC.
[中]描述:实用类以简洁易读的方式生成OWL概念。
版权所有:版权所有(c)2007
公司:Clark&Parsia有限责任公司。
代码示例来源:origin: Galigator/openllet
@Test
public void datatypeDefinition()
{
final OWLDatatype between5and10 = OWL.Datatype("between5and10");
final OWLDatatype between6and8 = OWL.Datatype("between6and8");
createReasoner(OWL.datatypeDefinition(between5and10, OWL.restrict(XSD.INTEGER, OWL.minInclusive(5), OWL.maxInclusive(10))), OWL.datatypeDefinition(between6and8, OWL.restrict(XSD.INTEGER, OWL.minInclusive(6), OWL.maxInclusive(8))), OWL.equivalentClasses(_A, OWL.some(_dp, between5and10)), OWL.equivalentClasses(_B, OWL.some(_dp, between6and8)), OWL.propertyAssertion(_a, _dp, OWL.constant(9)), OWL.propertyAssertion(_b, _dp, OWL.constant(7)));
assertTrue(_reasoner.isEntailed(OWL.subClassOf(_B, _A)));
assertTrue(_reasoner.isEntailed(OWL.classAssertion(_a, _A)));
assertFalse(_reasoner.isEntailed(OWL.classAssertion(_a, _B)));
assertTrue(_reasoner.isEntailed(OWL.classAssertion(_b, _A)));
assertTrue(_reasoner.isEntailed(OWL.classAssertion(_b, _B)));
}
代码示例来源:origin: Galigator/openllet
private static OWLEntity createEntity(final String type, final String entityIRI)
{
if (CLASS_KEYWORD.equals(type))
return OWL.Class(entityIRI);
else
if (DATA_TYPE_KEYWORD.equals(type))
return OWL.Datatype(entityIRI);
else
if (INDIVIDUAL_KEYWORD.equals(type))
return OWL.Individual(entityIRI);
else
if (DATA_PROPERTY_KEYWORD.equals(type))
return OWL.DataProperty(entityIRI);
else
if (OBJECT_PROPERTY_KEYWORD.equals(type))
return OWL.ObjectProperty(entityIRI);
throw new IllegalArgumentException("Unrecognized type of OWLEntity in module " + type);
}
代码示例来源:origin: Galigator/openllet
@Test
public void userDefinedDatatype2() throws Exception
{
final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.subClassOf(_A, OWL.and(OWL.max(dp, 1), OWL.some(dp, OWL.restrict(XSD.INTEGER, OWL.minExclusive(10))))), OWL.equivalentClasses(_B, OWL.and(OWL.min(dp, 1), OWL.all(dp, OWL.restrict(XSD.INTEGER, OWL.minExclusive(5))))) };
setupGenerators(Stream.of(axioms));
testExplanations(OWL.classAssertion(_a, _B), 0, axioms);
}
代码示例来源:origin: com.github.galigator.openllet/openllet-owlapi
/**
* @param property is the property that support the given range. In fact can be all 'simple' DataProperty you may want.
* @param range like [1..3] or more complex if you want.
* @param literal to check, 2 is include [1..3], 4 isn't include in [1..3].
* @return true if the literal is in the range.
* @since 2.6.1
*/
default public boolean isLiteralIncludeInRange(final OWLDataProperty property, final OWLDataRange range, final OWLLiteral literal)
{
return getReasoner().isSatisfiable(//
OWL.and(// You must be of all the following class
OWL.some(property, OWL.oneOf(literal)), // The class of the 'literal'
OWL.some(property, range), // The class of the range.
OWL.max(property, 1))// But you can have the property only once.
);
}
代码示例来源:origin: Galigator/openllet
private static Set<OWLClassAxiom> fixEquivalentAxioms(final OWLClass classToFix, final Set<OWLEquivalentClassesAxiom> axioms)
{
final Set<OWLClassAxiom> fixes = new HashSet<>();
for (final OWLEquivalentClassesAxiom axiom : axioms)
{
final Set<OWLClassExpression> descs = axiom.classExpressions().collect(Collectors.toSet());
descs.remove(classToFix);
if (descs.size() == 1)
fixes.add(OWL.subClassOf(classToFix, descs.iterator().next()));
else
{
fixes.add(OWL.equivalentClasses(descs));
fixes.add(OWL.subClassOf(classToFix, OWL.and(descs)));
}
}
return fixes;
}
}
代码示例来源:origin: com.github.galigator.openllet/openllet-owlapi
@Test
public void testAddAndRemove() throws OWLOntologyCreationException
{
try (final OWLManagerGroup group = new OWLManagerGroup())
{
final OWLOntologyID ontId = OWLHelper.getVersion(IRI.create(NS + "owlapi.add.remove"), 1.0);
final OWLHelper owl = new OWLGenericTools(group, ontId, true);
owl.addAxiom(OWL.declaration(OWL.DataProperty(NS + "propA")));
owl.addAxiom(OWL.declaration(OWL.Class(NS + "clsA")));
owl.addAxiom(OWL.equivalentClasses(OWL.Class(NS + "clsA"), //
OWL.value(OWL.DataProperty(NS + "propA"), OWL.constant(12))//
));
assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 0);
final OWLNamedIndividual x1 = OWL.Individual(NS + "I1");
owl.addAxiom(OWL.classAssertion(x1, OWL.Class(NS + "clsA")));
assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 1);
owl.removeAxiom(OWL.classAssertion(x1, OWL.Class(NS + "clsA")));
assertTrue(owl.getReasoner().instances(OWL.Class(NS + "clsA")).count() == 0);
} // The test is just about not crash.
}
代码示例来源:origin: Galigator/openllet
@Test
public void userDefinedDatatype3() throws Exception
{
final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.propertyAssertion(_a, dp, OWL.constant(9)), OWL.equivalentClasses(_B, OWL.and(_A, OWL.some(dp, _dt))), OWL.datatypeDefinition(_dt, OWL.restrict(XSD.INTEGER, OWL.maxExclusive(10))) };
setupGenerators(Stream.of(axioms));
testExplanations(OWL.classAssertion(_a, _B), 0, axioms);
}
代码示例来源:origin: Galigator/openllet
@Test
public void testPunningOneOf()
{
final OWLClass A = OWL.Class("A");
final OWLIndividual a = OWL.Individual("A");
final OWLIndividual b = OWL.Individual("b");
final Set<OWLAxiom> axioms = new HashSet<>();
axioms.add(OWL.equivalentClasses(A, OWL.oneOf(a, b)));
final OWLOntology ontology = OWL.Ontology(axioms);
final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ontology);
final PelletExplanation explain = new PelletExplanation(reasoner);
assertEquals(axioms, explain.getEntailmentExplanation(OWL.classAssertion(a, A)));
}
代码示例来源:origin: com.github.galigator.openllet/openllet-owlapi
final OWLHelper owl = new OWLGenericTools(group, ontId, true);
final OWLDataProperty dpA = OWL.DataProperty(NS + "dpA");
final OWLDataProperty dpB = OWL.DataProperty(NS + "dpB");
final OWLNamedIndividual a = OWL.Individual(NS + "A");
final OWLNamedIndividual b = OWL.Individual(NS + "B");
final SWRLIndividualArgument swrlIndA = SWRL.individual(a);
final OWLLiteral ten = OWL.constant(10.);
final OWLLiteral eleven = OWL.constant(11.);
final SWRLVariable varX = SWRL.variable(NS + "x");
final SWRLLiteralArgument sup = SWRL.constant("sup");
final SWRLLiteralArgument inf = SWRL.constant("inf");
owl.addAxiom(OWL.propertyAssertion(a, dpA, ten));
owl.addAxiom(OWL.propertyAssertion(b, dpA, eleven));
assertFalse(reasoner.isEntailed(OWL.propertyAssertion(a, dpB, OWL.constant("sup"))));
assertTrue(reasoner.isEntailed(OWL.propertyAssertion(a, dpB, OWL.constant("inf"))));
代码示例来源:origin: Galigator/openllet
@Test
public void datatypeEnumeration() throws Exception
{
final OWLAxiom[] axioms = { OWL.propertyAssertion(_a, dp, OWL.constant(1)), OWL.propertyAssertion(_a, dp, OWL.constant(2)), OWL.equivalentClasses(_A, OWL.some(dp, _dt)), OWL.datatypeDefinition(_dt, OWL.oneOf(OWL.constant(1), OWL.constant(2), OWL.constant(3))) };
setupGenerators(Stream.of(axioms));
testExplanations(OWL.classAssertion(_a, _A), 0, new OWLAxiom[] { axioms[0], axioms[2], axioms[3] }, new OWLAxiom[] { axioms[1], axioms[2], axioms[3] });
}
代码示例来源:origin: Galigator/openllet
@SuppressWarnings("unused")
@Test
public void testPunning3() throws Exception
{
final OWLClass A = OWL.Class("A");
final OWLIndividual i = OWL.Individual("A");
final OWLClass B = OWL.Class("B");
final OWLIndividual j = OWL.Individual("B");
final Set<OWLAxiom> axioms = new HashSet<>();
axioms.add(OWL.disjointClasses(A, B));
axioms.add(OWL.classAssertion(i, A));
axioms.add(OWL.classAssertion(j, B));
axioms.add(OWL.sameAs(i, j));
final OWLOntology ontology = OWL.Ontology(axioms);
final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ontology);
final PelletExplanation explain = new PelletExplanation(reasoner);
assertFalse(explain.getInconsistencyExplanations().isEmpty());
}
代码示例来源:origin: com.github.galigator.openllet/openllet-owlapi
final OWLHelper owl = new OWLGenericTools(group, ontId, true);
final OWLDataProperty property = OWL.DataProperty(NS + "property");
final OWLNamedIndividual individual = OWL.Individual(NS + "individual");
final OWLClass clazz = OWL.Class(NS + "clazz");
owl.addAxiom(OWL.classAssertion(individual, clazz));
代码示例来源:origin: Galigator/openllet
/**
* Test that in all circumstances where the role of an object existential is not in a signature, the axiom is non-local (Known to fail prior to r99)
*/
@Test
public void objectExistentialSuperClsProp()
{
assertNonLocal(subClassOf(Class("A"), some(ObjectProperty("p"), Thing)), Class("A"));
assertNonLocal(subClassOf(Class("A"), some(ObjectProperty("p"), Nothing)), Class("A"));
assertNonLocal(subClassOf(Class("A"), some(ObjectProperty("p"), Class("B"))), Class("A"));
assertNonLocal(subClassOf(Class("A"), some(ObjectProperty("p"), Class("A"))), Class("A"));
}
代码示例来源:origin: Galigator/openllet
@Test
public void indirectModuleTest()
{
final OWLAxiom[] axioms = { subClassOf(_A, and(_B, _C, some(_p, _C))), subClassOf(_B, or(all(_p, not(_C)), _D)), subClassOf(_D, _E) };
final OWLAxiom[] additions = { subClassOf(_A, not(_E)) };
final OWLAxiom[] deletions = {};
updateTest(axioms, additions, deletions);
}
代码示例来源:origin: Galigator/openllet
@Test
public void multipleDatatypeRange() throws Exception
{
final OWLAxiom[] axioms = { OWL.range(dp, XSD.BYTE), OWL.range(dp, XSD.NON_POSITIVE_INTEGER), OWL.range(dp, XSD.NON_NEGATIVE_INTEGER), OWL.subClassOf(_A, OWL.min(dp, 1)), OWL.classAssertion(_a, _A) };
setupGenerators(Stream.of(axioms));
testExplanations(OWL.propertyAssertion(_a, dp, OWL.constant(0)), 0, new OWLAxiom[] { axioms[1], axioms[2], axioms[3], axioms[4] });
}
代码示例来源:origin: Galigator/openllet
@SuppressWarnings("unused")
@Test
public void testPunning2() throws Exception
{
final OWLObjectProperty P = OWL.ObjectProperty("P");
final OWLObjectProperty S = OWL.ObjectProperty("S");
final OWLIndividual i = OWL.Individual("P");
final Set<OWLAxiom> axioms = new HashSet<>();
axioms.add(OWL.disjointProperties(P, S));
axioms.add(OWL.propertyAssertion(i, P, i));
axioms.add(OWL.propertyAssertion(i, S, i));
final OWLOntology ontology = OWL.Ontology(axioms);
final OpenlletReasoner reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ontology);
final PelletExplanation explain = new PelletExplanation(reasoner);
assertFalse(explain.getInconsistencyExplanations().isEmpty());
}
代码示例来源:origin: Galigator/openllet
@Test
public void objectMaxSubCls()
{
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Thing), Class("A")), Class("A"));
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Thing), Class("A")), Class("A"), ObjectProperty("p"));
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Nothing), Class("A")), Class("A"));
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Nothing), Class("A")), Class("A"), ObjectProperty("p"));
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Class("B")), Class("A")), Class("A"));
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Class("B")), Class("A")), Class("A"), ObjectProperty("p"));
assertNonLocal(subClassOf(max(ObjectProperty("p"), 2, Class("B")), Class("A")), Class("A"), ObjectProperty("p"), Class("B"));
}
代码示例来源:origin: Galigator/openllet
/**
* Test that universal object restriction subclasses are handled correctly
*/
@Test
public void objectUniversalSubCls()
{
assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"));
assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"), Class("B"));
assertNonLocal(subClassOf(all(ObjectProperty("p"), Class("B")), Class("A")), Class("A"), ObjectProperty("p"));
}
}
代码示例来源:origin: Galigator/openllet
@Before
public void setUp() throws OWLOntologyCreationException
{
_manager = OWLManager.createOWLOntologyManager();
final IRI ontologyURI = IRI.create("tag:clarkparsia.com,2008:pellint:test");
_ontology = _manager.createOntology(ontologyURI);
_cls = new OWLClass[5];
for (int i = 0; i < _cls.length; i++)
_cls[i] = OWL.Class(ontologyURI + "#C" + i);
_pro = new OWLObjectProperty[5];
for (int i = 0; i < _pro.length; i++)
_pro[i] = OWL.ObjectProperty(ontologyURI + "#R" + i);
_ind = new OWLIndividual[5];
for (int i = 0; i < _ind.length; i++)
_ind[i] = OWL.Individual(ontologyURI + "#I" + i);
_P0AllC0 = OWL.all(_pro[0], _cls[0]);
_P0SomeC1 = OWL.some(_pro[0], _cls[1]);
}
代码示例来源:origin: Galigator/openllet
/**
* Test that complemented sub class descriptions are handled correctly.
*/
@Test
public void objectComplementSubCls()
{
assertLocal(subClassOf(not(Thing), Class("A")), Class("A"));
assertNonLocal(subClassOf(not(Class("B")), Class("A")), Class("A"));
assertNonLocal(subClassOf(not(Class("B")), Class("A")), Class("A"), Class("B"));
}
内容来源于网络,如有侵权,请联系作者删除!