AGReasoningSameAs.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGReasoningSameAs {
@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("sameas", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
ts.addStatement("!ex:a","!owl:sameAs", "!ex:b");
ts.addStatement("!ex:b","!owl:sameAs", "!ex:c");
ts.addStatement("!ex:c","!ex:p", "!ex:d");
Cursor cc = ts.getStatements(false,"!ex:a",null,"!ex:c");
System.out.println("Ground triples relating ex:a and ex:c (should be none):");
AGUtils.showTriples(cc);
cc = ts.getStatements(true,"!ex:a",null,"!ex:c");
System.out.println("Infer triples relating ex:a and ex:c");
AGUtils.showTriples(cc);
cc = ts.getStatements(true,"!ex:a",null,"!ex:d");
System.out.println("Infer triples relating ex:a and ex:d");
AGUtils.showTriples(cc);
ts.addStatement("!ex:jans","!ex:owns","!ex:birra");
ts.addStatement("!ex:jans","!owl:sameAs","!ex:jannes");
ts.addStatement("!ex:aasman","!owl:sameAs","!ex:jannes");
ts.addStatement("!ex:birra","!owl:sameAs","!ex:son-of-samira");
cc = ts.getStatements(true,"!ex:aasman",null,"!ex:son-of-samira");
System.out.println("Infer triples relating ex:aasman and ex:son-of-samira");
AGUtils.showTriples(cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next