for(BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(goldView, BinaryTextRelation.class))) {
if(! relation.getCategory().equals("CONTAINS")) {
continue;
}
RelationArgument arg1 = relation.getArg1();
RelationArgument arg2 = relation.getArg2();
String eventText;
String timeText;
if(arg1.getArgument() instanceof TimeMention && arg2.getArgument() instanceof EventMention) {
timeText = arg1.getArgument().getCoveredText().toLowerCase();
eventText = Utils.normalizeEventText(jCas, arg2.getArgument());
} else if(arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof TimeMention) {
eventText = Utils.normalizeEventText(jCas, arg1.getArgument());
timeText = arg2.getArgument().getCoveredText().toLowerCase();
} else {
// this is not a event-time relation
continue;
}
HashSet<String> timeUnits = Utils.getTimeUnits(timeText);
if(textToDistribution.containsKey(eventText) && timeUnits.size() > 0) {
// there is duration information and we are able to get time units
Map<String, Float> eventDistribution = textToDistribution.get(eventText);
Map<String, Float> timeDistribution = Utils.convertToDistribution(timeUnits.iterator().next());
float eventExpectedDuration = Utils.expectedDuration(eventDistribution);
float timeExpectedDuration = Utils.expectedDuration(timeDistribution);
String context = Utils.getTextBetweenAnnotations(goldView, arg1.getArgument(), arg2.getArgument());
String out = String.format("%s|%.5f|%s|%.5f|%s\n",
timeUnits.iterator().next(), timeExpectedDuration * 3650,
eventText, eventExpectedDuration * 3650,
context.length() < 80 ? context : "...");
try {