net.anotheria.portalkit.engines.mailhunter.TransformationEngine Maven / Gradle / Ivy
package net.anotheria.portalkit.engines.mailhunter;
import java.util.ArrayList;
import net.anotheria.portalkit.engines.mailhunter.configurators.PlainConfigurator;
import net.anotheria.util.NumberUtils;
/**
* TODO please remined another to comment this class
* @author another
*/
public class TransformationEngine {
private ArrayList transformations;
private ArrayList matchers;
private TransformationStats transStats[];
private TransformationEngine(EngineConfigurator configurator){
matchers = new ArrayList();
transformations = new ArrayList();
configurator.configure(this);
//reorganize?
//System.out.println("Ready configured, transformations: "+transformations+", matcher: "+matchers);
transStats = new TransformationStats[transformations.size()];
for (int i=0; i0)
start--;
details.setStart(start);
details.setEnd(end);
details.setMatchedPattern(t.transform(context.getToMatch().substring(start, end + 1)));
details.setMatchedArea(context.getToMatch().substring(start, end + 1));
return details;
}
public boolean doesMatch(String toCheck, double probabilityTreshhold) {
return doesMatch(toCheck, probabilityTreshhold, "");
}
public boolean doesMatch(String toCheck, double probabilityTreshhold, String locale){
double result = getHighestMatchProbability(toCheck, locale);
return result>=probabilityTreshhold;
}
public void addMatcher(Matcher m){
matchers.add(m);
}
public void addTransformation(Transformation t){
transformations.add(t);
}
public void printOutStats(){
System.out.println("==== Transformation stats: ====");
for (int i=0; i