public void explainInstance(final OWLIndividual ind, final OWLClass c) { if (c.isOWLThing()) { return; } final OWLAxiom axiom = OWL.classAssertion(ind, c); explainAxiom(axiom); }
@Test public void basicTypesTest() { final OWLAxiom[] axioms = { classAssertion(_a, _A), classAssertion(_b, _B), domain(_p, _C), range(_p, _D), propertyAssertion(_a, _p, _b) }; typesTest(axioms); }
/** * Test that anonymous individuals as the object of property assertions are translated correctly */ @Test public void anonymousIndividualPropertyAssertion() throws Exception { assumeTrue(!(this instanceof JenaExplanationTest)); final OWLAxiom[] axioms = { OWL.propertyAssertion(_a, _p, _anon1), OWL.classAssertion(_anon1, _A), OWL.subClassOf(OWL.some(_p, _A), _B) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
private static OpenlletReasoner setupReasonerIndividualNodeSetPolicy(final IndividualNodeSetPolicy p) { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _C), OWL.classAssertion(_b, _C), OWL.classAssertion(_c, _C), OWL.sameAs(_a, _b), OWL.differentFrom(_b, _c), OWL.differentFrom(_a, _c) }; final OWLOntology ont = OWL.Ontology(axioms); final OWLReasonerConfiguration config = new SimpleConfiguration(new NullReasonerProgressMonitor(), FreshEntityPolicy.ALLOW, Long.MAX_VALUE, p); final OpenlletReasoner pellet = OpenlletReasonerFactory.getInstance().createReasoner(ont, config); return pellet; }
@Test public void ruleTest4() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), SWRL.rule(SWRL.antecedent(SWRL.classAtom(_A, _x)), SWRL.consequent(SWRL.classAtom(_B, _x), SWRL.classAtom(_C, _x))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 1, axioms); testExplanations(OWL.classAssertion(_a, _C), 1, axioms); }
@Test public void ruleTest1() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.classAssertion(_b, _B), OWL.propertyAssertion(_a, _p, _b), SWRL.rule(SWRL.antecedent(SWRL.classAtom(_A, _x)), SWRL.consequent(SWRL.classAtom(_B, _x))), SWRL.rule(SWRL.antecedent(SWRL.classAtom(_B, _x), SWRL.propertyAtom(_p, _x, _y), SWRL.classAtom(_B, _y)), SWRL.consequent(SWRL.classAtom(_C, _x))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _A), 0, new OWLAxiom[] { axioms[0] }); testExplanations(OWL.classAssertion(_a, _B), 0, new OWLAxiom[] { axioms[0], axioms[3] }); testExplanations(OWL.classAssertion(_a, _C), 1, axioms); }
@Test public void basicInstancesUpdateTest() { final OWLAxiom[] axioms = { classAssertion(_a, _A), classAssertion(_b, _B), domain(_p, _C), range(_p, _D), propertyAssertion(_a, _p, _b) }; final OWLAxiom[] additions = { range(_p, _E) }; final OWLAxiom[] deletions = { range(_p, _D) }; instancesUpdateTest(axioms, additions, deletions); }
@Test public void userDefinedDatatype1() 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, OWL.restrict(XSD.INTEGER, OWL.maxExclusive(10))))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
@Test public void ruleTest5() throws Exception { final OWLAxiom[] axioms = { OWL.propertyAssertion(_a, _p, _b), SWRL.rule(SWRL.antecedent(SWRL.propertyAtom(_p, _x, _y)), SWRL.consequent(SWRL.classAtom(_A, _x), SWRL.classAtom(_B, _y))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _A), 1, axioms); testExplanations(OWL.classAssertion(_b, _B), 1, axioms); }
@Test public void ruleTest3() throws Exception { final OWLAxiom[] axioms = { OWL.inverseProperties(_q, _p), OWL.propertyAssertion(_b, _q, _a), OWL.classAssertion(_b, _B), SWRL.rule(SWRL.antecedent(SWRL.propertyAtom(_p, _x, _y), SWRL.classAtom(_B, _y)), SWRL.consequent(SWRL.classAtom(_A, _x))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _A), 1, axioms); }
@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); }
@Test public void ruleBuiltinTest1() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.propertyAssertion(_a, dp, OWL.constant(9)), SWRL.rule(SWRL.antecedent(SWRL.classAtom(_A, _x), SWRL.propertyAtom(dp, _x, _dx), SWRL.lessThan(_dx, SWRL.constant(10))), SWRL.consequent(SWRL.classAtom(_B, _x))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
@Test public void propertyChain2() throws Exception { final OWLAxiom[] axioms = { OWL.subPropertyOf(new OWLObjectProperty[] { _p, _q }, _r), OWL.propertyAssertion(_a, _p, _b), OWL.propertyAssertion(_b, _q, _c), OWL.equivalentClasses(_A, OWL.some(_r, OWL.Thing)) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _A), 0, axioms); }
@Test public void typeInheritanceWithAnonIndividual() { final OWLAxiom[] axioms = { OWL.subClassOf(_C, _D), OWL.classAssertion(_anon, _C) }; final OWLOntology ont = OWL.Ontology(axioms); final OpenlletReasoner pellet = OpenlletReasonerFactory.getInstance().createReasoner(ont); assertTrue(pellet.getInstances(_D, true).nodes().count() == 0); assertTrue(pellet.getInstances(_D, false).nodes().count() == 1); }
@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); }
@Test public void ruleBuiltinTest2() throws Exception { final OWLAxiom[] axioms = { OWL.classAssertion(_a, _A), OWL.propertyAssertion(_a, dp, OWL.constant(9)), SWRL.rule(SWRL.antecedent(SWRL.classAtom(_A, _x), SWRL.propertyAtom(dp, _x, _dx), SWRL.greaterThan(_dx, SWRL.constant(5)), SWRL.lessThan(_dx, SWRL.constant(10))), SWRL.consequent(SWRL.classAtom(_B, _x))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _B), 0, axioms); }
@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] }); }
@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))); }
@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] }); }
@Test public void subPropertiesOfFunctionalDataProperty() throws Exception { final OWLAxiom[] axioms = { OWL.functional(dp), OWL.subPropertyOf(dq, dp), OWL.subPropertyOf(dr, dp), OWL.propertyAssertion(_a, dq, OWL.constant(1)), OWL.classAssertion(_a, OWL.some(dr, XSD.INTEGER)) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.propertyAssertion(_a, dp, OWL.constant(1)), 0, new OWLAxiom[] { axioms[1], axioms[3] }); testExplanations(OWL.propertyAssertion(_a, dr, OWL.constant(1)), 0, axioms); }