@@ -0,0 +1,1307 @@
+package at.medunigraz.imi.bst.trec;%0A%0Aimport java.io.Closeable;%0Aimport java.io.File;%0Aimport java.io.FileWriter;%0Aimport java.io.Flushable;%0Aimport java.io.IOException;%0A%0Aimport com.opencsv.CSVWriter;%0A%0Aimport at.medunigraz.imi.bst.trec.evaluator.Evaluator;%0A%0Apublic class StatsWriter implements Closeable, Flushable %7B%0A%09private static final String%5B%5D FIELDS = new String%5B%5D %7B %22NDCG%22, %22RPrec%22, %22infAP%22, %22P10%22, %22F%22 %7D;%0A%0A%09private CSVWriter writer;%0A%0A%09public StatsWriter(File output) %7B%0A%09%09try %7B%0A%09%09%09writer = new CSVWriter(new FileWriter(output));%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%0A%09%09writeHeader();%0A%09%7D%0A%0A%09private void writeHeader() %7B%0A%09%09writer.writeNext(FIELDS);%0A%09%09flush();%0A%09%7D%0A%0A%09public void write(Evaluator evaluator) %7B%0A%09%09String%5B%5D entries = new String%5BFIELDS.length%5D;%0A%09%09entries%5B0%5D = String.valueOf(evaluator.getNDCG());%0A%09%09entries%5B1%5D = String.valueOf(evaluator.getRPrec());%0A%09%09entries%5B2%5D = String.valueOf(evaluator.getInfAP());%0A%09%09entries%5B3%5D = String.valueOf(evaluator.getP10());%0A%09%09entries%5B4%5D = String.valueOf(evaluator.getF());%0A%0A%09%09writer.writeNext(entries);%0A%09%7D%0A%0A%09@Override%0A%09public void close() %7B%0A%09%09try %7B%0A%09%09%09writer.close();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public void flush() %7B%0A%09%09try %7B%0A%09%09%09writer.flush();%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Write stats in a CSV file (#8)