Open a terminal and go into the extracted folder. Then, execute the following command:
javac -cp rewriting-example-1.3.1.jar fr/lirmm/graphik/graal/examples/rewriting/Rewriting.java
Execute the following command:
java -cp rewriting-example-1.3.1.jar fr/lirmm/graphik/graal/examples/rewriting/Rewriting ./data/
DlgpWriter writer = new DlgpWriter();
writer.write(new Prefix("", "http://ksg.meraka.co.za/adolena.owl#"));
writer.write(new Prefix("NAP", "file:///home/aurona/0AlleWerk/Navorsing/Ontologies/NAP/NAP#"));
File f = new File(rootDir, "A.dlp");
Ontology onto = new DefaultOntology(new DlgpParser(f));
ConjunctiveQuery query = DlgpParser.parseQuery("@prefix : "
+ "@prefix NAP: <file:///home/aurona/0AlleWerk/Navorsing/Ontologies/NAP/NAP#> "
+ "?(X0) :- NAP:Device(X0), :assistsWith(X0, X1).");
writer.write("\n= Query =\n");
writer.write(query);
QueryRewriter rewriter = new PureRewriter();
CloseableIteratorWithoutException it = rewriter.execute(query, onto);
writer.write("\n= Rewritings =\n");
while (it.hasNext()) {
writer.write(it.next());
writer.flush();
}
it.close();
RulesCompilation compilation = new IDCompilation();
compilation.compile(onto.iterator());
PureRewriter pure = new PureRewriter(false);
it = pure.execute(query, onto, compilation);
UnionOfConjunctiveQueries ucq = new DefaultUnionOfConjunctiveQueries(query.getAnswerVariables(), it);
writer.write("\n= Pivotal Rewritings =\n");
writer.write(ucq);
writer.write("\n= Unfolded Rewritings =\n");
it = PureRewriter.unfold(ucq, compilation);
while (it.hasNext()) {
writer.write(it.next());
writer.flush();
}
it.close();
writer.close();