// Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Override
// 	public int compare(String o1, String o2) {
// 		return Double.compare(get(o1), get(o2));
// 	}
// 
// 	public Integer get(String s) {
// 		if (containsKey(s))
// 			return super.get(s);
// 		put(s, 0);
// 		return 0;
// 	}
// 
// 	public void increment(String a) {
// 		put(a, get(a) + 1);
// 	}
// 
// 	public void increment(String a, int value) {
// 		put(a, get(a) + value);
// 	}
// 
// 	public List<String> ordered() {
// 		List<String> values = Lists.newArrayList(this.keySet());
// 		Collections.sort(values, this);
// 		return values;
// 	}
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import lombok.extern.log4j.Log4j;
import opennlp.tools.util.Span;
import org.edits.MapInteger;
import com.swabunga.spell.engine.SpellDictionary;
import com.swabunga.spell.engine.SpellDictionaryHashMap;
import com.swabunga.spell.engine.Word;
package org.edits.nlp;





@Log4j
public class SpellChecker {

	private static SpellChecker instance;

	public static SpellChecker getInstance() {
		if (instance == null) {
			try {
				instance = new SpellChecker(OpenNLP.getInstance());
			} catch (Exception e) {
				log.debug(e);
				throw new RuntimeException("Could not load spell checker modules");
			}
		}
		return instance;
	}

	private final SpellDictionary dict;

	private final OpenNLP opennlp;

	private SpellChecker(OpenNLP opennlp_) throws Exception {
		opennlp = opennlp_;
		InputStream im = this.getClass().getClassLoader().getResource("words.txt").openStream();
		dict = new SpellDictionaryHashMap(new InputStreamReader(im));
	}

	public String correct(String text) throws Exception {
		return correct(text, new MapInteger());
	}

// Path: edits-core/src/main/java/org/edits/MapInteger.java
// public class MapInteger extends HashMap<String, Integer> implements Comparator<String> {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	@Override
// 	public int compare(String o1, String o2) {
// 		return Double.compare(get(o1), get(o2));
// 	}
// 
// 	public Integer get(String s) {
// 		if (containsKey(s))
// 			return super.get(s);
// 		put(s, 0);
// 		return 0;
// 	}
// 
// 	public void increment(String a) {
// 		put(a, get(a) + 1);
// 	}
// 
// 	public void increment(String a, int value) {
// 		put(a, get(a) + value);
// 	}
// 
// 	public List<String> ordered() {
// 		List<String> values = Lists.newArrayList(this.keySet());
// 		Collections.sort(values, this);
// 		return values;
// 	}
// }


// Path: edits-nlp/src/main/java/org/edits/nlp/SpellChecker.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import lombok.extern.log4j.Log4j;
import opennlp.tools.util.Span;
import org.edits.MapInteger;
import com.swabunga.spell.engine.SpellDictionary;
import com.swabunga.spell.engine.SpellDictionaryHashMap;
import com.swabunga.spell.engine.Word;

package org.edits.nlp;





@Log4j
public class SpellChecker {

	private static SpellChecker instance;

	public static SpellChecker getInstance() {
		if (instance == null) {
			try {
				instance = new SpellChecker(OpenNLP.getInstance());
			} catch (Exception e) {
				log.debug(e);
				throw new RuntimeException("Could not load spell checker modules");
			}
		}
		return instance;
	}

	private final SpellDictionary dict;

	private final OpenNLP opennlp;

	private SpellChecker(OpenNLP opennlp_) throws Exception {
		opennlp = opennlp_;
		InputStream im = this.getClass().getClassLoader().getResource("words.txt").openStream();
		dict = new SpellDictionaryHashMap(new InputStreamReader(im));
	}

	public String correct(String text) throws Exception {
		return correct(text, new MapInteger());
	}

	public String correct(String text, MapInteger context) throws Exception {