use of fr.lirmm.graphik.graal.core.ruleset.DefaultOntology in project graal by graphik-team.
the class ChaseTest method test.
@Test
public void test() throws ParseException, ChaseException {
Ontology onto = new DefaultOntology();
onto.add(DlgpParser.parseRule("p(X) :- q(X)."));
onto.add(DlgpParser.parseRule("q(X) :- p(X)."));
InMemoryAtomSet store = new DefaultInMemoryGraphStore();
store.add(DlgpParser.parseAtom("p(a)."));
Chase chase = new BreadthFirstChase(onto, store);
Assert.assertTrue(chase.hasNext());
chase.next();
Assert.assertTrue(chase.hasNext());
chase.next();
Assert.assertFalse(chase.hasNext());
}
use of fr.lirmm.graphik.graal.core.ruleset.DefaultOntology in project graal by graphik-team.
the class KBBuilderTest method testSetOntology.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#setOntology(fr.lirmm.graphik.graal.api.core.RuleSet)}.
* @throws ParseException
*/
@Test
public void testSetOntology() throws ParseException {
// Given
KBBuilder kbb = new KBBuilder();
Ontology ontology = new DefaultOntology();
Rule r1 = DlgpParser.parseRule("[R1] p(X) :- q(X).");
ontology.add(r1);
// When
kbb.setOntology(ontology);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(r1, kb.getRule("R1"));
Assert.assertEquals(1, kb.getOntology().size());
}
Aggregations