AGPrologFunctorQ.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGPrologFunctorQ {
@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("functorq", 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");
String pquery = "(?x ?y) (q- ?x !ex:owns ?y)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?x ?y) (q ?x !ex:owns ?y)";
AGUtils.doPrologQuery(ts, pquery);
ts.addStatement("!ex:A","!rdfs:subClassOf", "!ex:B");
ts.addStatement("!ex:B","!rdfs:subClassOf", "!ex:C");
ts.addStatement("!ex:a","!rdf:type", "!ex:A");
pquery = "(?x ?y) (q- ?x !rdf:type ?y)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?x ?y) (q ?x !rdf:type ?y)";
AGUtils.doPrologQuery(ts, pquery);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next