AGPrologFunctorQminus.java
package com.franz.agbase.examples;
import com.franz.agbase.*;
public class AGPrologFunctorQminus {
@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("functorqminus", 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(true);
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 for " + pquery);
AGUtils.showResults(it);
pquery = "(q- ?x !ex:owns ?y)";
q.setVariables(vars);
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
ts.addStatement("!ex:A","!rdfs:subClassOf", "!ex:B");
ts.addStatement("!ex:B","!rdfs:subClassOf", "!ex:C");
ts.addStatement("!ex:a","!rdf:type", "!ex:A");
ts.indexAllTriples();
pquery = "(q- ?x !rdf:type ?y)";
q.setVariables(vars);
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
pquery = "(q ?x !rdf:type ?y)";
q.setVariables(vars);
q.setQuery(pquery);
it = q.run();
System.out.println("Results for " + pquery);
AGUtils.showResults(it);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next