You can download the java file here.
This example shows how to use the View datastructure to
create an arbitrary view. A view is a graph, where the nodes
are Constituent s and the edges are Relation s.
|
package edu.illinois.cs.cogcomp.edison.examples;
import edu.illinois.cs.cogcomp.edison.sentences.Constituent;
import edu.illinois.cs.cogcomp.edison.sentences.Relation;
import edu.illinois.cs.cogcomp.edison.sentences.TextAnnotation;
import edu.illinois.cs.cogcomp.edison.sentences.View;
/**
* @author Vivek Srikumar
*
*/
public class ViewExample {
public static void main(String[] args) {
String corpus = "2001_ODYSSEY";
String textId = "001";
String text1 = "Good afternoon, gentlemen. I am a HAL-9000 computer.";
|
Create a new View called MyViewName, that is created by
MyViewGenerator. This view is attached to ta1 and is scored 0.121.
|
View myView = new View("MyViewName", "MyViewGenerator", ta1, 0.121);
ta1.addView("MyViewName", myView);
Constituent m1 = new Constituent("M1", "MyViewName", ta1, 5, 6);
myView.addConstituent(m1);
Constituent m2 = new Constituent("M2", "MyViewName", ta1, 7, 10);
myView.addConstituent(m2);
Constituent m3 = new Constituent("M1", "MyViewName", ta1, 8, 9);
myView.addConstituent(m3);
Constituent m4 = new Constituent("M2", "MyViewName", ta1, 9, 10);
myView.addConstituent(m4);
Relation r1 = new Relation("Subject-Object", m1, m2, 0.001);
myView.addRelation(r1);
Relation r2 = new Relation("NameOf", m3, m4, 0.12);
myView.addRelation(r2);
System.out.println(myView.getConstituents());
System.out.println(myView.getRelations());
System.out.println(r1.getSource());
System.out.println(r2.getTarget());
}
}
|