final ArrayList<Class<? extends IProcessingComponent>> algorithms = Lists
.newArrayList();
algorithms.add(LingoClusteringAlgorithm.class);
algorithms.add(STCClusteringAlgorithm.class);
TabularOutput t = new TabularOutput(new PrintWriter(System.out));
t.columnSeparator(" | ");
t.defaultFormat(Double.class).format("%.3f");
t.addColumn("Topic").alignLeft().format("%-18s");
t.addColumn("Algorithm").alignLeft().format("%-15s");
for (AmbientTopic topic : topics)
{
for (Class<? extends IProcessingComponent> algorithm : algorithms)
{
final Map<String, Object> attributes = Maps.newHashMap();
AmbientDocumentSourceDescriptor.attributeBuilder(attributes).topic(topic);
ProcessingResult result = controller.process(
attributes, AmbientDocumentSource.class, algorithm, ClusteringMetricsCalculator.class);
t.rowData("Topic", topic.name());
t.rowData("Algorithm", algorithm.getSimpleName());
Map<String, Object> attrs = result.getAttributes();
t.rowData(
"Contamination",
attrs.get(ContaminationMetricDescriptor.Keys.WEIGHTED_AVERAGE_CONTAMINATION));
t.rowData(
"F-Score",
attrs.get(PrecisionRecallMetricDescriptor.Keys.WEIGHTED_AVERAGE_F_MEASURE));
t.rowData(
"Precision",
attrs.get(PrecisionRecallMetricDescriptor.Keys.WEIGHTED_AVERAGE_PRECISION));
t.rowData(
"Recall",
attrs.get(PrecisionRecallMetricDescriptor.Keys.WEIGHTED_AVERAGE_RECALL));
t.rowData(
"NMI",
attrs.get(NormalizedMutualInformationMetricDescriptor.Keys.NORMALIZED_MUTUAL_INFORMATION));
t.nextRow();
}
}
}