All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dist.edu.umd.hooka.alignment.RefinerFactory Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package edu.umd.hooka.alignment;

import edu.umd.hooka.Alignment;

public class RefinerFactory {
	static final String GROW_DIAG_FINAL_AND = "grow-diag-final-and";
	static final String INTERSECTION = "intersection";
	static final String UNION = "union";
	static final String GROW_DIAG_FINAL = "grow-diag-final";
	static final String OCH = "och";
	
	static abstract class Pred {
		public abstract boolean eval(Alignment a, int i, int j);
	}
	
	static class Och extends Pred {
		public boolean eval(Alignment a, int i, int j) {
			return (!a.rookAligned(i, j) ||
					a.neighborAligned(i, j) && !a.lneighborAligned(i, j));		  
		}
	}

	static class Koehn extends Pred {
		public boolean eval(Alignment a, int i, int j) {
			return !a.doubleRookAligned(i, j) && a.neighborAligned(i, j);		  
		}
	}

	static class KoehnFinal extends Pred {
		public boolean eval(Alignment a, int i, int j) {
			return !a.rookAligned(i, j);		  
		}
	}

	static class IntersectionRefiner extends Refiner {
		public Alignment refine(Alignment a1, Alignment a2) {
			return Alignment.intersect(a1, a2);
		}
	}

	static class UnionRefiner extends Refiner {
		public Alignment refine(Alignment a1, Alignment a2) {
			return Alignment.union(a1, a2);
		}
	}

	static class GrowDiagFinalAndRefiner extends Refiner {
		static Koehn koehn = new Koehn();
		static KoehnFinal koehnFinal = new KoehnFinal();
		public Alignment refine(Alignment a2, Alignment a1) {
			Alignment au = Alignment.union(a1, a2);
			Alignment a = Alignment.intersect(a1, a2);
			
			grow(a, koehn, false, au);
			//System.out.println(a1.toString());
			grow(a, koehnFinal, true, a1);
			grow(a, koehnFinal, true, a2);
			
			return a;
		}
	}
	
	static class Pair {
		public Pair(int i, int j) {this.i=i; this.j=j;}
		public int i;
		public int j;
	}
	
	static void grow(Alignment a, Pred pred, boolean idem, Alignment pot)
	{
		int flen = a.getFLength();
		int elen = a.getELength();
		if (idem) {
			for (int i=0;i p = new java.util.ArrayList();
			for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy