AGPrologFunctorQminus.java
package com.franz.ag.examples;
import com.franz.ag.*;
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);
AGUtils.loadNTriplesWithTiming(ts, AGPaths.dataSources("kennedy.ntriples"));
AGUtils.indexAllTriplesWithTiming(ts);
ts.registerNamespace("ex", "http://example.org/kennedy/");
String pquery = "(?x)(q !ex:person1 !ex:has-child ?x)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?y)(q !ex:person1 !ex:has-child ?x)(q ?x !ex:has-child ?y)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?y ?z)" + "(q !ex:person1 !ex:has-child ?x)"
+ "(q ?x !ex:has-child ?y)" + "(q ?y !ex:spouse ?z)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?x ?y)" +
"(q ?x !ex:first-name ?n1)" +
"(q ?x !ex:has-child ?y)" +
"(q ?y !ex:first-name ?n2)" +
"(= ?n1 ?n2)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?x ?y)" +
"(q ?x !ex:alma-mater ?am)" +
"(q ?am !ex:ivy-league !ex:true)" +
"(q ?x !ex:has-child ?y)" +
"(q ?y !ex:alma-mater ?am2)" +
"(q ?am2 !ex:ivy-league !ex:true)";
AGUtils.doPrologQuery(ts, pquery);
pquery = "(?x ?y)" +
"(q ?x !ex:alma-mater ?am)" +
"(q ?am !ex:ivy-league !ex:true)" +
"(q ?x !ex:has-child ?y)" +
"(q ?y !ex:alma-mater ?am)";
AGUtils.doPrologQuery(ts, pquery);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next