Quick links: Examples - Files.
Classes: Hierarchy - Index - List - Members.
Packages: Index - base - jni.

JavaProjection.java

I/O and projection.This example shows how to use the projection operation. Its source code is under the samples/java directory.

import java.io.FileInputStream;
public class JavaProjection
{
public static void run(String prefix) throws Exception
{
Environment environment = new cogitant.jni.Environment();
environment.setIOConfig(IOHandler.ConfigPropertyBool.KEEPGRAPHOBJECTIDENTIFIERS, true);
environment.loadSupport(new FileInputStream(prefix + "/xml/bucolic/bucolic_id.cogxml"), IOHandler.Format.COGXML);
environment.loadObjects(new FileInputStream(prefix + "/xml/bucolic/fact_coref.cogxml"), IOHandler.Format.COGXML);
environment.loadObjects(new FileInputStream(prefix + "/xml/bucolic/query.cogxml"), IOHandler.Format.COGXML);
Graph g = environment.findGraph("query");
Graph h = environment.findGraph("fact_coref");
// Search for projections from g to h
System.out.println(environment.projectionHas(g, h));
System.out.println(environment.projectionNum(g, h));
System.out.println(environment.projectionFind(g, h)); // -> 2 projections
// Search again projections from g to h, but this time, we only want projections such that cn15 (from h) is the image of cn12 (from g).
Projection partialproj = environment.newProjection(g,h);
partialproj.newCouple(g.findByIdentifier("cn12"), h.findByIdentifier("cn15"));
environment.projectionConfig().setInitialProjection(partialproj);
System.out.println(environment.projectionFind(g, h)); // -> only 1 projection
environment.projectionConfig().setInitialProjection(null);
}
public static void main(String args[]) throws Exception
{
String prefix = "..";
if (args.length == 1)
prefix = args[0];
System.out.println("prefix: " + prefix);
run(prefix);
}
}