use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class KBBuilderTest method testAddAll.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#addAll(fr.lirmm.graphik.util.stream.CloseableIterator)}.
* @throws KBBuilderException
* @throws ParseException
* @throws AtomSetException
*/
@Test
public void testAddAll() throws KBBuilderException, ParseException, AtomSetException {
// Given
KBBuilder kbb = new KBBuilder();
Parser<Object> parser = new DlgpParser("[R1] p(X) :- q(X). p(a).");
// When
kbb.addAll(parser);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(DlgpParser.parseRule("[R1] p(X) :- q(X)."), kb.getRule("R1"));
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("p(a).")));
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class KBBuilderTest method testAddAtomMapper.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#add(fr.lirmm.graphik.graal.api.core.Atom, fr.lirmm.graphik.graal.api.core.mapper.Mapper)}.
* @throws ParseException
* @throws KBBuilderException
* @throws AtomSetException
*/
@Test
public void testAddAtomMapper() throws ParseException, KBBuilderException, AtomSetException {
// Given
KBBuilder kbb = new KBBuilder();
Atom a = DlgpParser.parseAtom("p(a).");
Mapper mapper = new PrefixMapper("graphik#");
// When
kbb.add(a, mapper);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("<graphik#p>(a).")));
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class KBBuilderTest method testAddRulesCloseableIteratorOfObject.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#addRules(fr.lirmm.graphik.util.stream.CloseableIterator)}.
* @throws AtomSetException
* @throws ParseException
* @throws KBBuilderException
*/
@Test
public void testAddRulesCloseableIteratorOfObject() throws ParseException, AtomSetException, KBBuilderException {
// Given
KBBuilder kbb = new KBBuilder();
Parser<Object> parser = new DlgpParser("[R1] p(X) :- q(X). p(a).");
// When
kbb.addRules(parser);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(DlgpParser.parseRule("[R1] p(X) :- q(X)."), kb.getRule("R1"));
Assert.assertEquals(1, kb.getOntology().size());
Assert.assertFalse(kb.getFacts().contains(DlgpParser.parseAtom("p(a).")));
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class KBBuilderTest method testAddRulesCloseableIteratorOfObjectMapper.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#addRules(fr.lirmm.graphik.util.stream.CloseableIterator, fr.lirmm.graphik.graal.api.core.mapper.Mapper)}.
* @throws KBBuilderException
* @throws ParseException
* @throws AtomSetException
*/
@Test
public void testAddRulesCloseableIteratorOfObjectMapper() throws KBBuilderException, ParseException, AtomSetException {
// Given
KBBuilder kbb = new KBBuilder();
Parser<Object> parser = new DlgpParser("[R1] p(X) :- q(X). p(a).");
Mapper mapper = new PrefixMapper("graphik#");
// When
kbb.addRules(parser, mapper);
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(DlgpParser.parseRule("[R1] <graphik#p>(X) :- <graphik#q>(X)."), kb.getRule("R1"));
Assert.assertFalse(kb.getFacts().contains(DlgpParser.parseAtom("p(a).")));
}
use of fr.lirmm.graphik.graal.api.kb.KnowledgeBase in project graal by graphik-team.
the class KBBuilderTest method testSetApproach.
/**
* Test method for {@link fr.lirmm.graphik.graal.kb.KBBuilder#setApproach(fr.lirmm.graphik.graal.api.kb.Approach)}.
*/
@Test
public void testSetApproach() {
// Given
KBBuilder kbb = new KBBuilder();
kbb.setApproach(Approach.SATURATION_ONLY);
// When
KnowledgeBase kb = kbb.build();
// Then
Assert.assertEquals(Approach.SATURATION_ONLY, kb.getApproach());
}
Aggregations