package at.medunigraz.imi.abbres;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.TreeSet;

import at.medunigraz.imi.abbres.model.Abbreviation;
import at.medunigraz.imi.abbres.model.mapper.FuzzyMapper;
import at.medunigraz.imi.abbres.model.mapper.Mapper;
import at.medunigraz.imi.abbres.model.mapper.StrictMapper;
import at.medunigraz.imi.abbres.model.matcher.LeftBigramMatcher;
import at.medunigraz.imi.abbres.model.matcher.Matcher;
import at.medunigraz.imi.abbres.model.matcher.RightBigramMatcher;
import at.medunigraz.imi.abbres.model.matcher.UnigramMatcher;
import at.medunigraz.imi.abbres.resolver.DefaultResolver;
import at.medunigraz.imi.abbres.resolver.Resolver;

public class Debugger {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		Resolver r = new DefaultResolver();

		do {
			System.out.print("Solve for: ");
			String abbr = br.readLine();

			System.out.print("With left context: ");
			String left = br.readLine();

			System.out.print("And right context: ");
			String right = br.readLine();

			Abbreviation a = new Abbreviation(abbr).withLeftContext(left).withRightContext(right);
			String guess = r.resolve(a);
			System.out.println("Best guess is: " + guess);

			Matcher unigram = new UnigramMatcher(a);
			Matcher leftBigram = new LeftBigramMatcher(a);
			Matcher rightBigram = new RightBigramMatcher(a);

			Mapper strictUnigram = new StrictMapper(unigram);
			Mapper strictLeftBigram = new StrictMapper(leftBigram);
			Mapper strictRightBigram = new StrictMapper(rightBigram);

			Mapper fuzzyUnigram = new FuzzyMapper(unigram);
			Mapper fuzzyLeftBigram = new FuzzyMapper(leftBigram);
			Mapper fuzzyRightBigram = new FuzzyMapper(rightBigram);

			NavigableSet<Mapper> set = new TreeSet<>();
			set.add(strictUnigram);
			set.add(strictLeftBigram);
			set.add(strictRightBigram);
			set.add(fuzzyUnigram);
			set.add(fuzzyLeftBigram);
			set.add(fuzzyRightBigram);

			for (Iterator<Mapper> iter = set.descendingIterator(); iter.hasNext();) {
				Mapper mapper = iter.next();

				String mapperClass = mapper.getClass().getSimpleName();
				String matcherClass = mapper.getMatcher().getClass().getSimpleName();
				String gram = mapper.getBestEntry().getKey();
				int frequency = mapper.getBestEntry().getValue();
				System.out.println(
						String.format("%s %s best guess: %s (%d)", mapperClass, matcherClass, gram, frequency));

			}

		} while (br.readLine() != null);
	}
}

@@ -303,21 +303,16 @@
 .mapper.
-Fuzzy
 Mapper;%0A
@@ -360,67 +360,14 @@
 per.
-Mapper;%0Aimport at.medunigraz.imi.abbres.model.mapper.Strict
+Single
 Mapp
@@ -610,32 +610,202 @@
 UnigramMatcher;%0A
+import at.medunigraz.imi.abbres.model.policy.FuzzyPolicy;%0Aimport at.medunigraz.imi.abbres.model.policy.Policy;%0Aimport at.medunigraz.imi.abbres.model.policy.StrictPolicy;%0A
 import at.meduni
@@ -1646,24 +1646,64 @@
 atcher(a);%0A%0A
+%09%09%09Policy strict = new StrictPolicy();%0A%0A
 %09%09%09Mapper st
@@ -1717,29 +1717,29 @@
 gram = new S
-trict
+ingle
 Mapper(unigr
@@ -1732,32 +1732,40 @@
 leMapper(unigram
+, strict
 );%0A%09%09%09Mapper str
@@ -1781,29 +1781,29 @@
 gram = new S
-trict
+ingle
 Mapper(leftB
@@ -1799,32 +1799,40 @@
 apper(leftBigram
+, strict
 );%0A%09%09%09Mapper str
@@ -1853,21 +1853,21 @@
  = new S
-trict
+ingle
 Mapper(r
@@ -1872,24 +1872,70 @@
 (rightBigram
+, strict);%0A%0A%09%09%09Policy fuzzy = new FuzzyPolicy(
 );%0A%0A%09%09%09Mappe
@@ -1951,29 +1951,30 @@
 igram = new 
-Fuzzy
+Single
 Mapper(unigr
@@ -1971,24 +1971,31 @@
 pper(unigram
+, fuzzy
 );%0A%09%09%09Mapper
@@ -2013,29 +2013,30 @@
 igram = new 
-Fuzzy
+Single
 Mapper(leftB
@@ -2036,24 +2036,31 @@
 r(leftBigram
+, fuzzy
 );%0A%09%09%09Mapper
@@ -2083,21 +2083,22 @@
 m = new 
-Fuzzy
+Single
 Mapper(r
@@ -2103,24 +2103,31 @@
 (rightBigram
+, fuzzy
 );%0A%0A%09%09%09Navig

Upgrade Debugger class to use new classes