use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testIsConsistentFalse2.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#isConsistent()}.
* @throws KnowledgeBaseException
* @throws AtomSetException
* @throws KBBuilderException
*/
@Test
public void testIsConsistentFalse2() throws KnowledgeBaseException, AtomSetException, KBBuilderException {
KBBuilder kbb = new KBBuilder();
kbb.addAll(new DlgpParser("q2(X) :- q(X). pr(X) :- p(X), r(X). q(a), p(a), r(a). [NC] ! :- q2(X), pr(X)."));
kbb.setApproach(Approach.REWRITING_FIRST);
KnowledgeBase kb = kbb.build();
Assert.assertFalse(kb.isConsistent());
kb.close();
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testIsConsistentTrue.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#isConsistent()}.
*/
@Test
public void testIsConsistentTrue() throws KnowledgeBaseException, AtomSetException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("[R] p(X) :- q(X). p(a). [NC] ! :- q(X), p(X)."));
Assert.assertTrue(kb.isConsistent());
kb.close();
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testSaturate.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#saturate()}.
* @throws AtomSetException
* @throws ParseException
* @throws KnowledgeBaseException
*/
@Test
public void testSaturate() throws ParseException, AtomSetException, KnowledgeBaseException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("p(X) :- q(X). q(X) :- r(X). r(X) :- s(X). s(a)."));
kb.saturate();
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("r(a).")));
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("q(a).")));
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("p(a).")));
kb.close();
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseQueryTest method testQuery.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#query(fr.lirmm.graphik.graal.api.core.Query)}.
* @throws AtomSetException
* @throws KnowledgeBaseException
* @throws ParseException
* @throws IteratorException
*/
@Test
public void testQuery() throws AtomSetException, ParseException, KnowledgeBaseException, IteratorException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("p(X) :- q(X). q(X) :- r(X). r(X) :- s(X). s(a)."));
CloseableIterator<Substitution> res = kb.query(DlgpParser.parseQuery("? :- p(a)."));
Assert.assertTrue(res.hasNext());
res.close();
kb.close();
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseQueryTest method testQueryWithTimeout0.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#query(fr.lirmm.graphik.graal.api.core.Query, long)}.
* @throws AtomSetException
* @throws KnowledgeBaseException
* @throws ParseException
* @throws IteratorException
* @throws TimeoutException
*/
@Test
public void testQueryWithTimeout0() throws AtomSetException, ParseException, KnowledgeBaseException, IteratorException, TimeoutException {
KnowledgeBase kb = new DefaultKnowledgeBase(new DlgpParser("p(X) :- q(X). q(X) :- r(X). r(X) :- s(X). s(a)."));
CloseableIterator<Substitution> res = kb.query(DlgpParser.parseQuery("? :- p(a)."), 0);
Assert.assertTrue(res.hasNext());
res.close();
kb.close();
}
Aggregations