Search in sources :

Example 1 with BreadthFirstChase

use of fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase 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 BreadthFirstChase

use of fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase in project graal by graphik-team.

the class DefaultKnowledgeBase method semiSaturate.

@Override
public void semiSaturate() throws KnowledgeBaseException {
    if (!this.isSemiSaturated) {
        this.compileRule();
        Chase chase = new BreadthFirstChase(this.ruleCompilation.getSaturation(), this.store);
        chase.setProfiler(this.getProfiler());
        try {
            chase.next();
        } catch (ChaseException e) {
            throw new KnowledgeBaseException(e);
        }
        this.isSemiSaturated = true;
    }
}
Also used : BreadthFirstChase(fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase) KnowledgeBaseException(fr.lirmm.graphik.graal.api.kb.KnowledgeBaseException) ChaseException(fr.lirmm.graphik.graal.api.forward_chaining.ChaseException) Chase(fr.lirmm.graphik.graal.api.forward_chaining.Chase) BreadthFirstChase(fr.lirmm.graphik.graal.forward_chaining.BreadthFirstChase)

Aggregations

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