}
@Override
protected AnnotationStatistics<String> test(CollectionReader collectionReader, File directory)
throws Exception {
AggregateBuilder aggregateBuilder = this.getPreprocessorAggregateBuilder();
aggregateBuilder.add(CopyFromGold.getDescription(EventMention.class, TimeMention.class));
// aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(
// RemoveCrossSentenceRelations.class,
// RemoveCrossSentenceRelations.PARAM_SENTENCE_VIEW,
// CAS.NAME_DEFAULT_SOFA,
// RemoveCrossSentenceRelations.PARAM_RELATION_VIEW,
// GOLD_VIEW_NAME));
if (this.useClosure) {
aggregateBuilder.add(
AnalysisEngineFactory.createPrimitiveDescription(AddClosure.class),//AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class),
CAS.NAME_DEFAULT_SOFA,
GOLD_VIEW_NAME);
// aggregateBuilder.add(
// AnalysisEngineFactory.createPrimitiveDescription(AddContain2Overlap.class),
// CAS.NAME_DEFAULT_SOFA,
// GOLD_VIEW_NAME);
// aggregateBuilder.add(
// AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveBeforeAndOnRelations.class),
// CAS.NAME_DEFAULT_SOFA,
// GOLD_VIEW_NAME);
}
// aggregateBuilder.add(
// AnalysisEngineFactory.createPrimitiveDescription(RemoveNonContainsRelations.class,
// RemoveNonContainsRelations.PARAM_RELATION_VIEW,
// GOLD_VIEW_NAME));
// aggregateBuilder.add(
// AnalysisEngineFactory.createPrimitiveDescription(RemoveEventEventRelations.class),
// CAS.NAME_DEFAULT_SOFA,
// GOLD_VIEW_NAME);
aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveRelations.class));
aggregateBuilder.add(this.baseline ? RecallBaselineEventTimeRelationAnnotator.createAnnotatorDescription(directory) :
EventTimeRelationAnnotator.createAnnotatorDescription(new File(directory,EVENT_TIME)));
aggregateBuilder.add(EventEventRelationAnnotator.createAnnotatorDescription(new File(directory,EVENT_EVENT)));
aggregateBuilder.add(EventDischargeTimeAnnotator.createAnnotatorDescription(new File(directory,EVENT_DISCHARGE)));
aggregateBuilder.add(EventAdmissionTimeAnnotator.createAnnotatorDescription(new File(directory,EVENT_ADMISSION)));
if (this.useClosure) {//add closure for system output
aggregateBuilder.add(
AnalysisEngineFactory.createPrimitiveDescription(AddClosure.class),//AnalysisEngineFactory.createPrimitiveDescription(AddTransitiveContainsRelations.class),
GOLD_VIEW_NAME,
CAS.NAME_DEFAULT_SOFA
);
}
if(this.i2b2Output != null){
aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(WriteI2B2XML.class, WriteI2B2XML.PARAM_OUTPUT_DIR, this.i2b2Output), "TimexView", CAS.NAME_DEFAULT_SOFA);
}
//remove the null argument from relations
aggregateBuilder.add(AnalysisEngineFactory.createPrimitiveDescription(RemoveNullArgumentRelations.class));
Function<BinaryTextRelation, ?> getSpan = new Function<BinaryTextRelation, HashableArguments>() {
public HashableArguments apply(BinaryTextRelation relation) {
return new HashableArguments(relation);
}
};
Function<BinaryTextRelation, String> getOutcome = AnnotationStatistics.annotationToFeatureValue("category");
AnnotationStatistics<String> stats = new AnnotationStatistics<>();
JCasIterable jcasIter =new JCasIterable(collectionReader, aggregateBuilder.createAggregate());
JCas jCas = null;
while(jcasIter.hasNext()) {
jCas = jcasIter.next();
JCas goldView = jCas.getView(GOLD_VIEW_NAME);
JCas systemView = jCas.getView(CAS.NAME_DEFAULT_SOFA);