@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 ruleTest1b() 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 ruleTest6() throws Exception { final OWLAxiom[] axioms = { OWL.propertyAssertion(_a, _p, _b), OWL.classAssertion(_b, _B), SWRL.rule(SWRL.antecedent(SWRL.classAtom(OWL.some(_p, _B), _x)), SWRL.consequent(SWRL.classAtom(_C, _x))) }; setupGenerators(Stream.of(axioms)); testExplanations(OWL.classAssertion(_a, _C), 1, 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 ruleTest2() throws Exception { final OWLAxiom[] axioms = { OWL.subPropertyOf(_q, _p), OWL.propertyAssertion(_a, _q, _b), 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 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 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); }
SWRL.antecedent(SWRL.classAtom(ClsA, varA)), // SWRL.consequent(SWRL.classAtom(ClsB, varA))// )); SWRL.antecedent(SWRL.classAtom(ClsB, varA)), // SWRL.consequent(SWRL.classAtom(ClsC, varA))// )); SWRL.antecedent(SWRL.classAtom(OWL.and(ClsD, ClsC), varA)), // SWRL.consequent(SWRL.classAtom(ClsE, varA))// )); SWRL.antecedent(SWRL.classAtom(OWL.and(ClsD, OWL.not(ClsF)), varA)), // SWRL.consequent(SWRL.classAtom(ClsG, varA))// ); SWRL.antecedent(SWRL.classAtom(OWL.and(ClsD, ClsF), varA)), // SWRL.consequent(SWRL.classAtom(ClsG, varA))// );
@Test public void testAxiomConverterRules1() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final AxiomConverter converter = new AxiomConverter(kb, OWL._factory); final ATermAppl C = ATermUtils.makeTermAppl("C"); final ATermAppl D = ATermUtils.makeTermAppl("D"); final ATermAppl x = ATermUtils.makeVar("x"); kb.addClass(C); kb.addClass(D); final ATermAppl[] head = new ATermAppl[] { ATermUtils.makeTypeAtom(x, D) }; final ATermAppl[] body = new ATermAppl[] { ATermUtils.makeTypeAtom(x, C) }; final ATermAppl rule = ATermUtils.makeRule(head, body); final OWLAxiom actual = converter.convert(rule); final Set<SWRLAtom> antecedent = new HashSet<>(); final Set<SWRLAtom> consequent = new HashSet<>(); antecedent.add(classAtom(Class("C"), variable("x"))); consequent.add(classAtom(Class("D"), variable("x"))); final OWLAxiom expected = rule(antecedent, consequent); assertEquals(expected, actual); }
SWRL.antecedent(SWRL.classAtom(ClsA, varA)), // SWRL.consequent(SWRL.classAtom(ClsB, varA))// )); SWRL.antecedent(SWRL.classAtom(ClsB, varA)), // SWRL.consequent(SWRL.classAtom(ClsC, varA))// )); SWRL.antecedent(SWRL.classAtom(OWL.and(ClsD, ClsC), varA)), // SWRL.consequent(SWRL.classAtom(ClsE, varA))// )); SWRL.antecedent(SWRL.classAtom(OWL.and(ClsD, OWL.not(ClsF)), varA)), // SWRL.consequent(SWRL.classAtom(ClsG, varA))// ); SWRL.antecedent(SWRL.classAtom(OWL.and(ClsD, ClsF), varA)), // SWRL.consequent(SWRL.classAtom(ClsG, varA))// );
public void testAxiomConverterRules1c() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final AxiomConverter converter = new AxiomConverter(kb, OWL._manager.getOWLDataFactory()); final ATermAppl C = ATermUtils.makeTermAppl("C"); final ATermAppl D = ATermUtils.makeTermAppl("D"); final ATermAppl x = ATermUtils.makeVar("x"); final ATermAppl name = ATermUtils.makeBnode("MyRule"); kb.addClass(C); kb.addClass(D); final ATermAppl[] head = new ATermAppl[] { ATermUtils.makeTypeAtom(x, D) }; final ATermAppl[] body = new ATermAppl[] { ATermUtils.makeTypeAtom(x, C) }; final ATermAppl rule = ATermUtils.makeRule(name, head, body); final OWLAxiom actual = converter.convert(rule); final Set<SWRLAtom> antecedent = new HashSet<>(); final Set<SWRLAtom> consequent = new HashSet<>(); antecedent.add(classAtom(Class("C"), variable("x"))); consequent.add(classAtom(Class("D"), variable("x"))); final OWLAxiom expected = rule(name.getArgument(0).toString(), true, antecedent, consequent); assertEquals(expected, actual); }
@Test public void testAxiomConverterRules1b() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final AxiomConverter converter = new AxiomConverter(kb, OWL._manager.getOWLDataFactory()); final ATermAppl C = ATermUtils.makeTermAppl("C"); final ATermAppl D = ATermUtils.makeTermAppl("D"); final ATermAppl x = ATermUtils.makeVar("x"); final ATermAppl name = ATermUtils.makeTermAppl("MyRule"); kb.addClass(C); kb.addClass(D); final ATermAppl[] head = new ATermAppl[] { ATermUtils.makeTypeAtom(x, D) }; final ATermAppl[] body = new ATermAppl[] { ATermUtils.makeTypeAtom(x, C) }; final ATermAppl rule = ATermUtils.makeRule(name, head, body); final OWLAxiom actual = converter.convert(rule); final Set<SWRLAtom> antecedent = new HashSet<>(); final Set<SWRLAtom> consequent = new HashSet<>(); antecedent.add(classAtom(Class("C"), variable("x"))); consequent.add(classAtom(Class("D"), variable("x"))); final OWLAxiom expected = rule(name.getName(), antecedent, consequent); assertEquals(expected, actual); }
@Test public void testAxiomConverterRules2() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final AxiomConverter converter = new AxiomConverter(kb, OWL._manager.getOWLDataFactory()); final ATermAppl C = ATermUtils.makeTermAppl("C"); final ATermAppl D = ATermUtils.makeTermAppl("D"); final ATermAppl i = ATermUtils.makeTermAppl("i"); kb.addClass(C); kb.addClass(D); kb.addIndividual(i); final ATermAppl[] head = new ATermAppl[] { ATermUtils.makeTypeAtom(i, D) }; final ATermAppl[] body = new ATermAppl[] { ATermUtils.makeTypeAtom(i, C) }; final ATermAppl rule = ATermUtils.makeRule(head, body); final OWLAxiom actual = converter.convert(rule); final Set<SWRLAtom> antecedent = new HashSet<>(); final Set<SWRLAtom> consequent = new HashSet<>(); antecedent.add(classAtom(Class("C"), SWRL.individual(OWL.Individual("i")))); consequent.add(classAtom(Class("D"), SWRL.individual(OWL.Individual("i")))); final OWLAxiom expected = rule(antecedent, consequent); assertEquals(expected, actual); }
SWRL.classAtom(clazz, varX), // OWL._factory.getSWRLBuiltInAtom(IRI.create("MyRandomFunction"), Arrays.asList(varY))), //
SWRL.classAtom(clazz, varX), // OWL._factory.getSWRLBuiltInAtom(IRI.create("MyRandomFunction"), Arrays.asList(varY))), //