use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testAddSameQueryTwice.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#addQuery(fr.lirmm.graphik.graal.api.core.Query)}.
* @throws ParseException
*/
@Test
public void testAddSameQueryTwice() throws ParseException {
Query q1 = DlgpParser.parseQuery("[Q1] ? :- p(X).");
KnowledgeBase kb = new KBBuilder().build();
kb.addQuery(q1);
kb.addQuery(q1);
Assert.assertTrue(kb.getQueryNames().contains("Q1"));
Assert.assertEquals(q1, kb.getQuery("Q1"));
Assert.assertEquals(1, kb.getQueryNames().size());
kb.close();
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testAddQuery.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#addQuery(fr.lirmm.graphik.graal.api.core.Query)}.
* @throws ParseException
*/
@Test
public void testAddQuery() throws ParseException {
Query q1 = DlgpParser.parseQuery("[Q1] ? :- p(X).");
KnowledgeBase kb = new KBBuilder().build();
kb.addQuery(q1);
Assert.assertTrue(kb.getQueryNames().contains("Q1"));
Assert.assertEquals(q1, kb.getQuery("Q1"));
kb.close();
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class DefaultKnowledgeBaseTest method testDefaultKnowledgeBaseAtomSetParserOfObject.
/**
* Test method for
* {@link fr.lirmm.graphik.graal.kb.DefaultKnowledgeBase#DefaultKnowledgeBase(fr.lirmm.graphik.graal.api.core.AtomSet, fr.lirmm.graphik.graal.api.io.Parser)}.
* @throws ParseException
* @throws AtomSetException
*/
@Test
public void testDefaultKnowledgeBaseAtomSetParserOfObject() throws ParseException, AtomSetException {
Atom aa = DlgpParser.parseAtom("q(a).");
Atom ab = DlgpParser.parseAtom("q(b).");
Atom ac = DlgpParser.parseAtom("q(c).");
Rule r = DlgpParser.parseRule("[R] p(X) :- q(X).");
NegativeConstraint nc = DlgpParser.parseNegativeConstraint("[NC] ! :- q(X), p(X).");
AtomSet store = new DefaultInMemoryGraphStore();
store.add(aa);
KnowledgeBase kb = new DefaultKnowledgeBase(store, new DlgpParser("[R] p(X) :- q(X). q(b). q(c). [NC] ! :- q(X), p(X)."));
Assert.assertTrue(kb.getOntology().contains(r));
Assert.assertTrue(kb.getOntology().contains(nc));
Assert.assertTrue(kb.getFacts().contains(aa));
Assert.assertTrue(kb.getFacts().contains(ab));
Assert.assertTrue(kb.getFacts().contains(ac));
kb.close();
}
Aggregations