// Path: src/main/java/it/uniroma2/sag/kelp/predictionfunction/SequencePrediction.java
// public class SequencePrediction implements Prediction {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = -1040539866977906008L;
// 	/**
// 	 * This list contains multiple labelings to be assigned to a single sequence
// 	 */
// 	private List<SequencePath> paths;
// 
// 	public SequencePrediction() {
// 		paths = new ArrayList<SequencePath>();
// 	}
// 
// 	/**
// 	 * @return The best path, i.e., the labeling with the highest score in the
// 	 *         list of labelings provided by a classifier
// 	 */
// 	public SequencePath bestPath() {
// 		return paths.get(0);
// 	}
// 
// 	/**
// 	 * @return a list containing multiple labelings to be assigned to a single
// 	 *         sequence
// 	 */
// 	public List<SequencePath> getPaths() {
// 		return paths;
// 	}
// 
// 	@Override
// 	public Float getScore(Label label) {
// 		return null;
// 	}
// 
// 	/**
// 	 * @param paths
// 	 *            a list contains multiple labelings to be assigned to a single
// 	 *            sequence
// 	 */
// 	public void setPaths(List<SequencePath> paths) {
// 		this.paths = paths;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		StringBuilder sb = new StringBuilder();
// 		for (int i = 0; i < paths.size(); i++) {
// 			if (i == 0)
// 				sb.append("Best Path\t");
// 			else
// 				sb.append("Altern. Path\t");
// 			SequencePath sequencePath = paths.get(i);
// 			sb.append(sequencePath + "\n");
// 		}
// 		return sb.toString();
// 	}
// 
// }


import java.util.List;
import it.uniroma2.sag.kelp.data.example.Example;
import it.uniroma2.sag.kelp.data.example.SequenceExample;
import it.uniroma2.sag.kelp.data.example.SequencePath;
import it.uniroma2.sag.kelp.data.label.Label;
import it.uniroma2.sag.kelp.data.label.SequenceEmission;
import it.uniroma2.sag.kelp.predictionfunction.Prediction;
import it.uniroma2.sag.kelp.predictionfunction.SequencePrediction;
/*
 * Copyright 2014 Simone Filice and Giuseppe Castellucci and Danilo Croce and Roberto Basili
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package it.uniroma2.sag.kelp.utils.evaluation;



/**
 * This is an instance of an Evaluator. It allows to compute the some common
 * measure for classification tasks acting over <code>SequenceExample<code>s. It
 * computes precision, recall, f1s for each class, and a global accuracy.
 * 
 * @author Danilo Croce
 */
public class MulticlassSequenceClassificationEvaluator extends MulticlassClassificationEvaluator{

	/**
	 * Initialize a new F1Evaluator that will work on the specified classes
	 * 
	 * @param labels
	 */
	public MulticlassSequenceClassificationEvaluator(List<Label> labels) {
		super(labels);
	}

	public void addCount(Example test, Prediction prediction) {
		addCount((SequenceExample) test, (SequencePrediction) prediction);
	}

	/**
	 * This method should be implemented in the subclasses to update counters
	 * useful to compute the performance measure
	 * 
	 * @param test
	 *            the test example
	 * @param predicted
	 *            the prediction of the system
	 */
// Path: src/main/java/it/uniroma2/sag/kelp/predictionfunction/SequencePrediction.java
// public class SequencePrediction implements Prediction {
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = -1040539866977906008L;
// 	/**
// 	 * This list contains multiple labelings to be assigned to a single sequence
// 	 */
// 	private List<SequencePath> paths;
// 
// 	public SequencePrediction() {
// 		paths = new ArrayList<SequencePath>();
// 	}
// 
// 	/**
// 	 * @return The best path, i.e., the labeling with the highest score in the
// 	 *         list of labelings provided by a classifier
// 	 */
// 	public SequencePath bestPath() {
// 		return paths.get(0);
// 	}
// 
// 	/**
// 	 * @return a list containing multiple labelings to be assigned to a single
// 	 *         sequence
// 	 */
// 	public List<SequencePath> getPaths() {
// 		return paths;
// 	}
// 
// 	@Override
// 	public Float getScore(Label label) {
// 		return null;
// 	}
// 
// 	/**
// 	 * @param paths
// 	 *            a list contains multiple labelings to be assigned to a single
// 	 *            sequence
// 	 */
// 	public void setPaths(List<SequencePath> paths) {
// 		this.paths = paths;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		StringBuilder sb = new StringBuilder();
// 		for (int i = 0; i < paths.size(); i++) {
// 			if (i == 0)
// 				sb.append("Best Path\t");
// 			else
// 				sb.append("Altern. Path\t");
// 			SequencePath sequencePath = paths.get(i);
// 			sb.append(sequencePath + "\n");
// 		}
// 		return sb.toString();
// 	}
// 
// }


// Path: src/main/java/it/uniroma2/sag/kelp/utils/evaluation/MulticlassSequenceClassificationEvaluator.java
import java.util.List;
import it.uniroma2.sag.kelp.data.example.Example;
import it.uniroma2.sag.kelp.data.example.SequenceExample;
import it.uniroma2.sag.kelp.data.example.SequencePath;
import it.uniroma2.sag.kelp.data.label.Label;
import it.uniroma2.sag.kelp.data.label.SequenceEmission;
import it.uniroma2.sag.kelp.predictionfunction.Prediction;
import it.uniroma2.sag.kelp.predictionfunction.SequencePrediction;

/*
 * Copyright 2014 Simone Filice and Giuseppe Castellucci and Danilo Croce and Roberto Basili
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package it.uniroma2.sag.kelp.utils.evaluation;



/**
 * This is an instance of an Evaluator. It allows to compute the some common
 * measure for classification tasks acting over <code>SequenceExample<code>s. It
 * computes precision, recall, f1s for each class, and a global accuracy.
 * 
 * @author Danilo Croce
 */
public class MulticlassSequenceClassificationEvaluator extends MulticlassClassificationEvaluator{

	/**
	 * Initialize a new F1Evaluator that will work on the specified classes
	 * 
	 * @param labels
	 */
	public MulticlassSequenceClassificationEvaluator(List<Label> labels) {
		super(labels);
	}

	public void addCount(Example test, Prediction prediction) {
		addCount((SequenceExample) test, (SequencePrediction) prediction);
	}

	/**
	 * This method should be implemented in the subclasses to update counters
	 * useful to compute the performance measure
	 * 
	 * @param test
	 *            the test example
	 * @param predicted
	 *            the prediction of the system
	 */
	public void addCount(SequenceExample test, SequencePrediction predicted) {