Search in sources :

Example 1 with DefaultOntology

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());
}
Also used : Ontology(fr.lirmm.graphik.graal.api.core.Ontology) DefaultOntology(fr.lirmm.graphik.graal.core.ruleset.DefaultOntology) BreadthFirstChase(fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase) InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) DefaultInMemoryGraphStore(fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore) DefaultOntology(fr.lirmm.graphik.graal.core.ruleset.DefaultOntology) Chase(fr.lirmm.graphik.graal.api.forward_chaining.Chase) BreadthFirstChase(fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase) Test(org.junit.Test)

Example 2 with DefaultOntology

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());
}
Also used : DefaultOntology(fr.lirmm.graphik.graal.core.ruleset.DefaultOntology) Ontology(fr.lirmm.graphik.graal.api.core.Ontology) KnowledgeBase(fr.lirmm.graphik.graal.api.kb.KnowledgeBase) Rule(fr.lirmm.graphik.graal.api.core.Rule) DefaultOntology(fr.lirmm.graphik.graal.core.ruleset.DefaultOntology) Test(org.junit.Test)

Aggregations

Ontology (fr.lirmm.graphik.graal.api.core.Ontology)2 DefaultOntology (fr.lirmm.graphik.graal.core.ruleset.DefaultOntology)2 Test (org.junit.Test)2 InMemoryAtomSet (fr.lirmm.graphik.graal.api.core.InMemoryAtomSet)1 Rule (fr.lirmm.graphik.graal.api.core.Rule)1 Chase (fr.lirmm.graphik.graal.api.forward_chaining.Chase)1 KnowledgeBase (fr.lirmm.graphik.graal.api.kb.KnowledgeBase)1 DefaultInMemoryGraphStore (fr.lirmm.graphik.graal.core.atomset.graph.DefaultInMemoryGraphStore)1 BreadthFirstChase (fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase)1