package ch.bfh.bti7535.w2016.evaluate;

import ch.bfh.bti7535.w2016.algorithm.AbstractAlgorithm;
import ch.bfh.bti7535.w2016.algorithm.NaiveBayesAlgorithm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Evaluate {

	private static Logger log = (Logger) LoggerFactory.getLogger(Evaluate.class);

	private static void evaluateByClassname(Class clazz) {
		try {
			AbstractAlgorithm algo = (AbstractAlgorithm) clazz.newInstance();
			AlgoClassifier classifier = new AlgoClassifier(algo);

			double fmesure = classifier.getFmesure();
			double precision = classifier.getPrecision();
			double recall = classifier.getRecall();

			String baseline = String.format(
					"\n---------------------\nBaseline Algorithm\n---------------------\n"
							+ "Precision:\t%f\n"
							+ "Recall:\t\t%f\n"
							+ "f-Measure:\t%f\n\n", precision, recall, fmesure);

			log.info(baseline);
		} catch (IllegalAccessException | InstantiationException e) {
			log.error("Cannot instantiate {}", clazz.getName());
		}
	}

	public static void main(String[] args) {
		//evaluateByClassname(BaselineAlgorithm.class);
		evaluateByClassname(NaiveBayesAlgorithm.class);
	}
}

@@ -86,24 +86,81 @@
 tAlgorithm;%0A
+import ch.bfh.bti7535.w2016.algorithm.BaselineAlgorithm;%0A
 import ch.bf
@@ -433,16 +433,87 @@
 %09%09try %7B%0A
+%09%09%09log.info(%22Using %7B%7D for sentiment analysis%22, clazz.getSimpleName());%0A
 %09%09%09Abstr
@@ -840,26 +840,10 @@
 --%5Cn
-Baseline Algorithm
+%25s
 %5Cn--
@@ -950,16 +950,49 @@
 %25f%5Cn%5Cn%22,
+ algo.getClass().getSimpleName(),
  precisi
@@ -1207,16 +1207,360 @@
 args) %7B%0A
+%09%09if (args.length == 1) %7B%0A%09%09%09String arg0 = args%5B0%5D;%0A%09%09%09switch (arg0.toLowerCase()) %7B%0A%09%09%09case %22baseline%22:%0A%09%09%09%09evaluateByClassname(BaselineAlgorithm.class);%0A%09%09%09%09break;%0A%09%09%09case %22naivebayes%22:%0A%09%09%09%09evaluateByClassname(NaiveBayesAlgorithm.class);%0A%09%09%09%09break;%0A%09%09%09default:%0A%09%09%09%09log.error(%22The argument %7B%7D does not match any algorithm.%22);%0A%09%09%09%7D%0A%09%09%7D else %7B%0A%09
 %09%09//eval
@@ -1603,16 +1603,17 @@
 ass);%0A%09%09
+%09
 evaluate
@@ -1652,13 +1652,17 @@
 class);%0A
+%09%09%7D%0A
 %09%7D%0A%7D%0A

Allow specification of algorithm as program argument