package OT; import java.util.*; /** * Hierarchy of constraints. * @version 1999-03-31 * @author Andrea Heiberg, University of Arizona */ public class Hierarchy extends Vector { LanguageFeatureTypeSet languageFeatureTypeSet; public Hierarchy (LanguageFeatureTypeSet languageFeatureTypeSet) { this.languageFeatureTypeSet = languageFeatureTypeSet; } //end constructor /** Parse raw data into constraint hierarchy. */ public void parseRawData(Vector rawLines) { FeatureType featureType1; FeatureType featureType2; //rawLines (input) is a vector of lines //textLine is a vector of "words" for (Enumeration e = rawLines.elements(); e.hasMoreElements();) { Vector textLine = (Vector)e.nextElement(); for (Enumeration f = textLine.elements(); f.hasMoreElements();) { String ct = (String)f.nextElement(); if (ct.equals("FeatureLinearity")) { super.addElement(new FeatureLinearity()); } else { //feature type-specific constraint f.nextElement(); //skip "featuretype" String ft = (String)f.nextElement(); String anchor = (String)f.nextElement(); featureType1 = new FeatureType(ft,anchor); if (ct.equals("AlignFeature")) { Edge edge = new Edge((String)f.nextElement()); super.addElement(new AlignFeature(featureType1,edge)); } else if (ct.equals("AlignPrWd")) { Edge edge = new Edge((String)f.nextElement()); super.addElement(new AlignPrWd(featureType1,edge)); } else if (ct.equals("MAX-A")) { super.addElement(new MaxA(featureType1)); } else if (ct.equals("MAX-F")) { super.addElement(new MaxF(featureType1)); } else if (ct.equals("DEP-A")) { super.addElement(new DepA(featureType1)); } else if (ct.equals("DEP-F")) { super.addElement(new DepF(featureType1)); } else if (ct.equals("GroundPositive")) { f.nextElement(); //skip "featuretype" String ft2 = (String)f.nextElement(); String anchor2 = (String)f.nextElement(); featureType2 = new FeatureType(ft2,anchor2); super.addElement(new GroundPositive(featureType1,featureType2)); } else if (ct.equals("GroundNegative")) { f.nextElement(); //skip "featuretype" String ft2 = (String)f.nextElement(); String anchor2 = (String)f.nextElement(); featureType2 = new FeatureType(ft2,anchor2); super.addElement(new GroundNegative(featureType1,featureType2)); } else if (ct.equals("*Float")) { super.addElement(new NoFloat(featureType1)); } //end if } // end if } //end for } // end for super.trimToSize(); } //end parseRawData }