AGReasoningSubPropertyOf.java
package com.franz.ag.examples;
import com.franz.ag.*;
public class AGReasoningSubPropertyOf {
@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("subpropertyof", AGPaths.TRIPLE_STORES);
ts.registerNamespace("ex","http://example.org/");
ts.addStatement("!ex:p","!rdfs:subPropertyOf", "!ex:q");
ts.addStatement("!ex:q","!rdfs:subPropertyOf", "!ex:r");
ts.addStatement("!ex:a","!ex:p", "!ex:b");
Cursor cc = ts.getStatements(false,"!ex:p","!rdfs:subPropertyOf",null);
System.out.println("Retrieving super-properties of ex:p");
AGUtils.showTriples(cc);
cc = ts.getStatements(true,"!ex:p","!rdfs:subPropertyOf",null);
System.out.println("Inferring super-properties of ex:p");
AGUtils.showTriples(cc);
cc = ts.getStatements(false,"!ex:a",null,"!ex:b");
System.out.println("Retrieving properties that hold between ex:a and ex:b");
AGUtils.showTriples(cc);
cc = ts.getStatements(true,"!ex:a",null,"!ex:b");
System.out.println("Inferring properties that hold between ex:a and ex:b");
AGUtils.showTriples(cc);
ts.closeTripleStore();
ags.disable();
}
}
Up |
Next