package OT; import java.util.*; /** * MAX constraint for associations. Penalizes removing associations to features of featureType1. * @version 1999-03-31 * @author Andrea Heiberg, University of Arizona */ public class MaxA extends CorrespondAssociation { public MaxA(FeatureType featureType1) { super(featureType1); } //end constructor /** Removes all DeleteAssociation operations on featureType1 from gen. **/ public Gen cullGen(Gen gen) { Gen newGen = new Gen(gen.input, gen.languageFeatureTypeSet, gen.debug); StringBuffer sb = new StringBuffer(); for (Enumeration e = gen.elements(); e.hasMoreElements();) { boolean match = false; Operation op = (Operation)e.nextElement(); if (op instanceof DeleteAssociation) { if (op.featureType.toString().equals(featureType1.toString())) { match = true; sb.append(this.toString() + ": culled " + op + "\n"); } //end if } //end if if (!match) newGen.addElement(op); } //end for gen.debug.write(sb.toString()); sb = null; return newGen; } //end cullGen /** Returns the number of times that candidate violates this constraint. **/ public Integer evaluate(Representation candidate, Representation input) { return super.evaluate(candidate, input); } //end evaluate public String toString() { return ("MAX-A(" + featureType1 + ")"); } //end toString }