/*******************************************************************************
 * Copyright 2016
 * Language Technology Lab
 * University of Duisburg-Essen
 *
 * 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 de.unidue.ltl.evaluation.measure;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.dkpro.statistics.correlation.PearsonCorrelation;

import de.unidue.ltl.evaluation.EvaluationEntry;
import de.unidue.ltl.evaluation.EvaluationResult;


public class PearsonCorrelation 
	extends EvaluationMeasure
{

	public PearsonCorrelation(Collection<EvaluationEntry> entries) {
		super(entries);
	}

	private List<Double> val1;
	private List<Double> val2;
	
	@Override
	public List<EvaluationResult> calculate() {
		List <EvaluationResult> evals = new ArrayList<EvaluationResult>();
		
		val1 = new ArrayList<Double>();
		val2 = new ArrayList<Double>(); 
		
		for (EvaluationEntry entry : entries) {
			val1.add((double) entry.getGold());
			val2.add((double) entry.getPredicted());
			
		}
		
		double result = PearsonCorrelation.computeCorrelation(val1, val1);
		
		EvaluationResult obj = new EvaluationResult();
		obj.setResult(result);
		evals.add(obj);
		
		return evals;
	}

	
	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return "SpearmanCorrelation";
	}

}

@@ -953,34 +953,17 @@
 elation.
-PearsonCorrelation
+*
 ;%0A%0Aimpor
@@ -1621,16 +1621,49 @@
 esult = 
+org.dkpro.statistics.correlation.
 PearsonC
@@ -1914,15 +1914,14 @@
 rn %22
-Spearma
+Pearso
 nCor

update pearson