AGPrologIncludeInferred.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
public class AGPrologIncludeInferred {
@param
@throws
public static void main(String[] args) throws AllegroGraphException {
AllegroGraphConnection ags = new AllegroGraphConnection();
try {
ags.enable();
} catch (Exception e) {
throw new AllegroGraphException("Server connection problem", e);
}
AllegroGraph ts = ags.renew("prologincludeinferred", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
ts.addStatement("!ex:a","!ex:owned-by","!ex:b");
ts.addStatement("!ex:c","!ex:owns","!ex:d");
ts.addStatement("!ex:jans","!ex:owns","!ex:birra");
ts.addStatement("!ex:owned-by","!owl:inverseOf","!ex:owns");
ts.indexAllTriples();
PrologSelectQuery q = new PrologSelectQuery();
q.setTripleStore(ts);
q.setIncludeInferred(false);
String[] vars = new String[]{"x","y"};
String pquery = "(q ?x !ex:owns ?y)";
q.setVariables(vars);
q.setQuery(pquery);
ValueSetIterator it = q.run();
System.out.println("Results (no reasoning) for " + pquery);
AGUtils.showResults(it);
q.setIncludeInferred(true);
it = q.run();
System.out.println("Results (with reasoning) for " + pquery);
AGUtils.showResults(it);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next