// Path: src/main/java/renaming/renamers/INGramIdentifierRenamer.java
// public static class Renaming implements Comparable<Renaming> {
// 	public final String name;
// 
// 	public final double score;
// 
// 	public final int nContexts;
// 
// 	public final Scope scope;
// 
// 	public Renaming(final String id, final double xEntropy,
// 			final int contexts, final Scope renamingScope) {
// 		name = id;
// 		score = xEntropy;
// 		nContexts = contexts;
// 		scope = renamingScope;
// 	}
// 
// 	@Override
// 	public int compareTo(final Renaming other) {
// 		return ComparisonChain.start().compare(score, other.score)
// 				.compare(name, other.name).result();
// 	}
// 
// 	@Override
// 	public boolean equals(final Object other) {
// 		if (!(other instanceof Renaming)) {
// 			return false;
// 		}
// 		final Renaming r = (Renaming) other;
// 		return Objects.equal(name, r.name) && Objects.equal(score, r.score);
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return Objects.hashCode(name, score);
// 
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return name + ":" + String.format("%.2f", score);
// 	}
// 
// }


import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import org.apache.commons.io.FileUtils;
import renaming.renamers.INGramIdentifierRenamer.Renaming;
import codemining.lm.ngram.AbstractNGramLM;
import codemining.lm.ngram.NGram;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
/**
 * 
 */
package renaming.formatting;





/**
 * Evaluate Formatting Renamings.
 * 
 * @author Miltos Allamanis <m.allamanis@ed.ac.uk>
 * 
 */
public class FormattingRenamingsEval {

	/**
	 * Struct class containing results.
	 * 
	 */
	public static class WhitespacePrecisionRecall {
		static double[] THRESHOLD_VALUES = { .1, .2, .5, 1, 1.5, 2, 2.5, 3,
				3.5, 4, 5, 6, 7, 8, 10, 12, 15, 20, 50, 100, Double.MAX_VALUE };
		final long[] nGaveSuggestions = new long[THRESHOLD_VALUES.length];
		final long[] nCorrect = new long[THRESHOLD_VALUES.length];

		long total = 0;

		/**
		 * Accumulate results to this object
		 * 
		 * @param other
		 */
		public synchronized void accumulate(
				final WhitespacePrecisionRecall other) {
			for (int i = 0; i < THRESHOLD_VALUES.length; i++) {
				nGaveSuggestions[i] += other.nGaveSuggestions[i];
				nCorrect[i] += other.nCorrect[i];
			}
			total += other.total;
		}

// Path: src/main/java/renaming/renamers/INGramIdentifierRenamer.java
// public static class Renaming implements Comparable<Renaming> {
// 	public final String name;
// 
// 	public final double score;
// 
// 	public final int nContexts;
// 
// 	public final Scope scope;
// 
// 	public Renaming(final String id, final double xEntropy,
// 			final int contexts, final Scope renamingScope) {
// 		name = id;
// 		score = xEntropy;
// 		nContexts = contexts;
// 		scope = renamingScope;
// 	}
// 
// 	@Override
// 	public int compareTo(final Renaming other) {
// 		return ComparisonChain.start().compare(score, other.score)
// 				.compare(name, other.name).result();
// 	}
// 
// 	@Override
// 	public boolean equals(final Object other) {
// 		if (!(other instanceof Renaming)) {
// 			return false;
// 		}
// 		final Renaming r = (Renaming) other;
// 		return Objects.equal(name, r.name) && Objects.equal(score, r.score);
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		return Objects.hashCode(name, score);
// 
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return name + ":" + String.format("%.2f", score);
// 	}
// 
// }


// Path: src/main/java/renaming/formatting/FormattingRenamingsEval.java
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import org.apache.commons.io.FileUtils;
import renaming.renamers.INGramIdentifierRenamer.Renaming;
import codemining.lm.ngram.AbstractNGramLM;
import codemining.lm.ngram.NGram;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;

/**
 * 
 */
package renaming.formatting;





/**
 * Evaluate Formatting Renamings.
 * 
 * @author Miltos Allamanis <m.allamanis@ed.ac.uk>
 * 
 */
public class FormattingRenamingsEval {

	/**
	 * Struct class containing results.
	 * 
	 */
	public static class WhitespacePrecisionRecall {
		static double[] THRESHOLD_VALUES = { .1, .2, .5, 1, 1.5, 2, 2.5, 3,
				3.5, 4, 5, 6, 7, 8, 10, 12, 15, 20, 50, 100, Double.MAX_VALUE };
		final long[] nGaveSuggestions = new long[THRESHOLD_VALUES.length];
		final long[] nCorrect = new long[THRESHOLD_VALUES.length];

		long total = 0;

		/**
		 * Accumulate results to this object
		 * 
		 * @param other
		 */
		public synchronized void accumulate(
				final WhitespacePrecisionRecall other) {
			for (int i = 0; i < THRESHOLD_VALUES.length; i++) {
				nGaveSuggestions[i] += other.nGaveSuggestions[i];
				nCorrect[i] += other.nCorrect[i];
			}
			total += other.total;
		}

		public void addSuggestion(final SortedSet<Renaming> suggestions,