package at.medunigraz.imi.abbres.model.reducer;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import at.medunigraz.imi.abbres.model.Abbreviation;
import at.medunigraz.imi.abbres.model.NGramMap;
import at.medunigraz.imi.abbres.model.NGramMapFactory;
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.UnigramMatcher;
import junit.framework.TestCase;

public class BigramWithFallbackReducerTest extends TestCase {
	public void testReduce() {
		Map<String, Integer> unigramMap = new TreeMap<>();
		unigramMap.put("To", 10);
		unigramMap.put("A", 1000);
		unigramMap.put("Kill", 1);
		unigramMap.put("Pride", 1000);
		unigramMap.put("Prejudice", 100);
		unigramMap.put("Pr", 10);
		unigramMap.put("Prid.", 10);
		NGramMapFactory.setUnigramMap(new NGramMap(unigramMap));
		
		Abbreviation a = new Abbreviation("Pr.").withLeftContext("and");
		List<Mapper> mappers = Arrays.asList(new StrictMapper(new UnigramMatcher(a)));
		BigramWithFallbackReducer reducer = new BigramWithFallbackReducer();
		assertEquals("Pride", reducer.reduce(mappers));
		
		
		Map<String, Integer> bigramMap = new TreeMap<>();
		bigramMap.put("Pride and", 10);
		bigramMap.put("and Prejudice", 1000);
		bigramMap.put("Prejudice is", 1);
		bigramMap.put("is a", 100);
		bigramMap.put("a novel", 100);
		bigramMap.put("and Pr", 10);
		bigramMap.put("and Prej.", 10);
		NGramMapFactory.setBigramMap(new NGramMap(bigramMap));
		
		mappers = Arrays.asList(new StrictMapper(new UnigramMatcher(a)), new StrictMapper(new LeftBigramMatcher(a)));
		assertEquals("Prejudice", reducer.reduce(mappers));	
	}
}

@@ -339,32 +339,91 @@
 .mapper.Mapper;%0A
+import at.medunigraz.imi.abbres.model.mapper.SingleMapper;%0A
 import at.meduni
@@ -457,32 +457,32 @@
 r.StrictMapper;%0A
-
 import at.meduni
@@ -588,24 +588,83 @@
 ramMatcher;%0A
+import at.medunigraz.imi.abbres.model.policy.StrictPolicy;%0A
 import junit
@@ -1207,37 +1207,37 @@
 ays.asList(new S
-trict
+ingle
 Mapper(new Unigr
@@ -1244,24 +1244,44 @@
 amMatcher(a)
+, new StrictPolicy()
 ));%0A%09%09Bigram
@@ -1776,29 +1776,29 @@
 asList(new S
-trict
+ingle
 Mapper(new U
@@ -1813,17 +1813,16 @@
 tcher(a)
-)
 , new St
@@ -1821,24 +1821,45 @@
 , new Strict
+Policy()), new Single
 Mapper(new L
@@ -1877,16 +1877,36 @@
 tcher(a)
+, new StrictPolicy()
 ));%0A%09%09as

Upgrade test to use new classes