Open a terminal and go into the extracted folder. Then, execute the following command:
javac -cp getting-started-with-kb-example-1.3.1.jar fr/lirmm/graphik/graal/examples/getting_started/GettingStarted.java
Execute the following command:
java -cp getting-started-with-kb-example-1.3.1.jar fr/lirmm/graphik/graal/examples/getting_started/GettingStarted ./data/
KBBuilder kbb = new KBBuilder();
kbb.addAll(new DlgpParser(new File(rootDir, "animals.dlp")));
KnowledgeBase kb = kbb.build();
writer = new DlgpWriter();
writer.write("\n= Ontology =\n");
writer.write(kb.getOntology());
writer.write("\n= Facts =\n");
writer.write(kb.getFacts());
ConjunctiveQuery query = DlgpParser.parseQuery("?(X) :- mammal(X).");
writer.write("\n= Query =\n");
writer.write(query);
CloseableIterator resultIterator = kb.query(query);
if (resultIterator.hasNext()) {
do {
writer.write(resultIterator.next().toString());
writer.write("\n");
} while (resultIterator.hasNext());
} else {
writer.write("No answers.\n");
}
kb.close();
writer.close();