AGPrologDisjunction.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGPrologDisjunction {
@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("prologdisjunction", AGPaths.TRIPLE_STORES);
AGUtils.loadNTriplesWithTiming(ts, AGPaths.dataSources("kennedy.ntriples"));
AGUtils.indexAllTriplesWithTiming(ts);
ts.registerNamespace("ex", "http://example.org/kennedy/");
AGUtils.addPrologRule("(<-- (ancestor ?x ?y) (q ?x !ex:has-child ?y))", ts);
AGUtils.addPrologRule("(<- (ancestor ?x ?y) (q ?x !ex:has-child ?z) (ancestor ?z ?y))", ts);
String pquery = "(?x)" + "(ancestor ?x !ex:person13)";
AGUtils.doPrologQuery(ts, pquery);
AGUtils.addPrologRule("(<-- (descendent ?x ?y) (ancestor ?y ?x))", ts);
pquery = "(?x)" + "(descendent ?x !ex:person13)";
AGUtils.doPrologQuery(ts, pquery);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next