Conjunctive types.This example shows how to use conjunctive types. Its source code is under the samples/java
directory.
import java.io.FileInputStream;
import java.util.Collection;
import java.util.Iterator;
public class JavaConjunctive
{
public static void run(String prefix) throws Exception
{
environment.
loadSupport(
new FileInputStream(prefix +
"/xml/conjunctive/conjunctive.cogxml"), IOHandler.Format.COGXML);
Collection<EnvironmentObject> loadedgraphs = environment.loadObjects(new FileInputStream(prefix + "/xml/conjunctive/factconj.cogxml"), IOHandler.Format.COGXML);
Graph g = loadedgraphs.iterator().next().asGraph();
Collection<GraphObject> nodes = g.nodes();
for (Iterator<GraphObject> j=nodes.iterator(); j.hasNext(); )
{
GraphObject go = j.next();
System.out.print(go + " " + go.objectType() + " ");
if (go.objectType() == GraphObject.Type.CONCEPT)
{
if (go.hasConjunctiveType())
{
System.out.print("Conjunctive type: ");
Collection<SupportObject> types = go.conjunctiveType();
for (Iterator<SupportObject> k=types.iterator(); k.hasNext(); )
{
SupportObject so = k.next();
System.out.print(so.label() + " ");
}
}
else
System.out.print("Primitive type: " + go.type().label());
}
System.out.println();
}
}
public static void main(String args[]) throws Exception
{
String prefix = "..";
if (args.length == 1)
prefix = args[0];
System.out.println("prefix: " + prefix);
run(prefix);
}
}