System.out.println();
for(BinaryTextRelation binaryTextRelation : JCasUtil.select(systemView, BinaryTextRelation.class)) {
String category = binaryTextRelation.getCategory();
IdentifiedAnnotation entity1; // entity whose role is "Argument"
IdentifiedAnnotation entity2; // entity whose role is "Related_to"
if(binaryTextRelation.getArg1().getRole().equals("Argument")) {
entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument();
entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument();
} else {
entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument();
entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument();
}
String arg1 = entity1.getCoveredText();
String arg2 = entity2.getCoveredText();
int type1 = entity1.getTypeID();
int type2 = entity2.getTypeID();
// print relation and its arguments: location_of(colon/6, colon cancer/2)
System.out.format("%s(%s/%d, %s/%d)\n", category, arg1, type1, arg2, type2);
if(displayContext) {