hu.birot.OTKit.otBuildingBlocks
Class Eval

java.lang.Object
  extended by hu.birot.OTKit.otBuildingBlocks.Eval

public class Eval
extends java.lang.Object

Contains a number of static methods that belong to the evaluation process, either in an OT or in a HG or in any other different approach.


Constructor Summary
Eval()
           
 
Method Summary
static Comparison Compare(Candidate c1, Candidate c2, Hierarchy h)
          Comparison of c1 and c2, as defined by methods CompareOT and CompareHG.
static java.util.Vector<Candidate> Compare(java.util.Vector<Candidate> candidate_set, Hierarchy h)
          This method returns the most harmonic subset of comparison with respect to hierarchy h.
static Comparison CompareHG(Candidate c1, Candidate c2, Hierarchy h)
          This static methods compares candidate c1 to candidate c2 in a Harmony Grammar sense, with respect to the constraints found in the hierarchy h, using the weights defined in h.
static java.util.Vector<Candidate> CompareHG(java.util.Vector<Candidate> candidate_set, Hierarchy h)
          This method returns the most harmonic subset of comparison with respect to hierarchy h, according the method Harmony Grammar, using the weights specified in h.
static Comparison CompareOT(Candidate c1, Candidate c2, Constraint[] h)
          Compares candidate c1 to candidate c2 in an Optimality Theoretic sense, with respect to the constraint ranking (hierarchy) found in the array of Constraints h.
static Comparison CompareOT(Candidate c1, Candidate c2, Hierarchy h)
          This static methods compares candidate c1 to candidate c2 in an Optimality Theoretic sense, with respect to the constraint ranking (hierarchy) h.
static java.util.Vector<Candidate> CompareOT(java.util.Vector<Candidate> candidate_set, Constraint[] h)
          This method returns the most harmonic subset of comparison with respect to hierarchy h, according the method Optimality Grammar, using the hierarchy as specified in the array h.
static java.util.Vector<Candidate> CompareOT(java.util.Vector<Candidate> candidate_set, Hierarchy h)
          This method returns the most harmonic subset of comparison with respect to hierarchy h, according the method Optimality Grammar, using the ranks specified in h.
static double EvalHG(Candidate c, Hierarchy h)
          This static method returns the evaluation of candidate c with respect to the HG constraint hierarchy h.
static Violation[] EvalOT(Candidate c, Constraint[] h)
          This static method returns the evaluation of candidate c with respect to the OT constraint hierarchy encoded in the constraint array h.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Eval

public Eval()
Method Detail

CompareOT

public static Comparison CompareOT(Candidate c1,
                                   Candidate c2,
                                   Constraint[] h)

Compares candidate c1 to candidate c2 in an Optimality Theoretic sense, with respect to the constraint ranking (hierarchy) found in the array of Constraints h. The higher a constraint is ranked in the hierarchy, the higher its index in the array. Note that H is typically Hierarchy.sortByRank().

For the sake of faster computation, it is supposed that two violations are always comparable. That is, the method Violation.notComparable(Violation, Violation) never returns true. If the method Violation.betterEqual is implemented in a tricky way such that two violations are not always comparable, then you need to define (and implement) your own version of Optimality Theory, after having decided what to do with these cases. A possible source of bugs can be due to constraints that return violations belonging to two different subclasses of the class Violation (such as, both IntegerViolation and FloatViolation.)

Parameters:
c1 - : Candidate 1 to be compared.
c2 - : Candidate 2 to be compared.
h - : array of constraints acting as the hierarchy in an OT-sense.
Returns:
an object of type Comparison. Note that Comparison.better is the better one of c1 and c2; Comparison.worse is the worse one; Comparison.fatal is the fatal constraint; Comparison.difference is the difference in the ways c1 and c2 violate the fatal constraint. Moreover, Comparison.isBetterThan is true iff c1 is more harmonic than c2; Comparison.isWorseThan is true iff c1 is less harmonic than c2; Comparison.areEquivalent is true iff c1 and c2 have exactly the same violation profile. (Exactly one of these three boolean values is always true, the other being always false.) If Comparison.areEquivalent is true, then the first three values are not instantiated, and Comparison.difference is 0. If v1 and v2 are numeric violations (where v1 and v2 are the violation levels of the fatal constraint by c1 and c2 respectively), then Comparison.difference == v1-v2; Comparison.difference == 0 iff Comparison.areEquivalent == true; Comparison.difference > 0 iff Comparison.isWorse == true; Comparison.difference < 0 iff Comparison.isBetter == true. Note that the sign of Comparison.difference has opposite consequences for being better/worse in HG than in OT.

CompareHG

public static Comparison CompareHG(Candidate c1,
                                   Candidate c2,
                                   Hierarchy h)
This static methods compares candidate c1 to candidate c2 in a Harmony Grammar sense, with respect to the constraints found in the hierarchy h, using the weights defined in h. The harmony H(c_j) of each candidate c_j is the sum of (the weight of constraint i in h times the numeric value of the violation assigned by constraint i to candidate c_j) for all i. The candidate with higher harmony is better.

Parameters:
c1 - : Candidate 1 to be compared.
c2 - : Candidate 2 to be compared.
h - : the hierarchy used for the comparison.
Returns:
The method returns an object of type Comparison. Comparison.better is the better one of c1 and c2 (the one with a higher harmony), while Comparison.worse is the worse one (the one with a lower harmony). These two values are not instantiated if none of them is better. Comparison.difference is H(c1)-H(c2). Comparison.fatal is not defined. Moreover, Comparison.isBetterThan is true iff c1 is more harmonic than c2 (Comparison.difference > 0); Comparison.isWorseThan is true iff c1 is less harmonic than c2 (Comparison.difference < 0); Comparison.areEquivalent is true iff c1 and c2 have exactly the same harmony (Comparison.difference == 0 iff). (Exactly one of these three boolean values is always true, the other being always false.) Note that the sign of Comparison.difference has opposite consequences for being better/worse in HG than in OT.

CompareOT

public static Comparison CompareOT(Candidate c1,
                                   Candidate c2,
                                   Hierarchy h)
This static methods compares candidate c1 to candidate c2 in an Optimality Theoretic sense, with respect to the constraint ranking (hierarchy) h. Ranking variable "rank" in h is used to define the constraint ranking (hierarchy): the higher the rank value of a certain constraint, the higher it is ranked in the hierarchy. If two constraints have the same rank value, their relative ranking is uncertain (depends on the sorting algorithm). Importantly, the method h.sortByRank() must have been called since the last change in the rank values.

Parameters:
c1 - : Candidate 1 to be compared.
c2 - : Candidate 2 to be compared.
h - : constraints whose rank values are used to define the hierarchy.
Returns:
an object of type Comparison. Note that Comparison.better is the better one of c1 and c2; Comparison.worse is the worse one; Comparison.fatal is the fatal constraint; Comparison.difference is the difference in the ways c1 and c2 violate the fatal constraint. Moreover, Comparison.isBetterThan is true iff c1 is more harmonic than c2; Comparison.isWorseThan is true iff c1 is less harmonic than c2; Comparison.areEquivalent is true iff c1 and c2 have exactly the same violation profile. (Exactly one of these three boolean values is always true, the other being always false.) If Comparison.areEquivalent is true, then the first three values are not instantiated, and Comparison.difference is 0. If v1 and v2 are numeric violations (where v1 and v2 are the violation levels of the fatal constraint by c1 and c2 respectively), then Comparison.difference == v1-v2; Comparison.difference == 0 iff Comparison.areEquivalent == true; Comparison.difference > 0 iff Comparison.isWorse == true; Comparison.difference < 0 iff Comparison.isBetter == true. Note that the sign of Comparison.difference has opposite consequences for being better/worse in HG than in OT.

Compare

public static Comparison Compare(Candidate c1,
                                 Candidate c2,
                                 Hierarchy h)
Comparison of c1 and c2, as defined by methods CompareOT and CompareHG. It is the field h.type (either the string "ot" or "hg", case distinction being ignored) which defines the method of comparison.

Parameters:
c1 - : Candidate 1 to be compared.
c2 - : Candidate 2 to be compared.
h - : Hierarchy used for the comparison.
Returns:
An object of type Comparison. For exact meaning of its fields, refer to methods CompareOT and CompareHG.

EvalOT

public static Violation[] EvalOT(Candidate c,
                                 Constraint[] h)
This static method returns the evaluation of candidate c with respect to the OT constraint hierarchy encoded in the constraint array h.

Parameters:
c - : The candidate to be evaluated.
h - : An array of constraints that represents the OT constraint ranking.
Returns:
An array of violations v[i], where v[i] equals the violation assigned by constraint h[i] to candidate c.

EvalHG

public static double EvalHG(Candidate c,
                            Hierarchy h)
This static method returns the evaluation of candidate c with respect to the HG constraint hierarchy h. The weight in defined in h are used to calculate the harmony of c.

Parameters:
c - : The candidate to be evaluated.
h - : A hierarchy that contains the HG constraints and their weights.
Returns:
A (double float) integer that is the sum of (the weight of constraint i in h times the numeric value of the violation assigned by constraint i to candidate c) for all i.

Compare

public static java.util.Vector<Candidate> Compare(java.util.Vector<Candidate> candidate_set,
                                                  Hierarchy h)
This method returns the most harmonic subset of comparison with respect to hierarchy h. Field h.type defines the method to be used: "ot" or "hg". In the former case, hierarchy is specified by h.sortedByRank (hence, you should run h.sortByRank before hand). In the latter case, the weights specified in h will define the relative harmony of any two candidates.

Parameters:
candidate_set - : A Vector of Candidates to be compared.
h - : The Hierarchy according to which comparison is done.
Returns:
The most harmonic subset of comparison with respect to hierarchy h.

CompareHG

public static java.util.Vector<Candidate> CompareHG(java.util.Vector<Candidate> candidate_set,
                                                    Hierarchy h)
This method returns the most harmonic subset of comparison with respect to hierarchy h, according the method Harmony Grammar, using the weights specified in h.

Parameters:
candidate_set - : A Vector of Candidates to be compared.
h - : The Hierarchy according to which comparison is done.
Returns:
The most harmonic subset of comparison with respect to hierarchy h.

CompareOT

public static java.util.Vector<Candidate> CompareOT(java.util.Vector<Candidate> candidate_set,
                                                    Hierarchy h)
This method returns the most harmonic subset of comparison with respect to hierarchy h, according the method Optimality Grammar, using the ranks specified in h. You must have run h.sortByRank before calling this method, because this method makes only use of h.sortedByRank.

Parameters:
candidate_set - : A Vector of Candidates to be compared.
h - : The Hierarchy according to which comparison is done.
Returns:
The most harmonic subset of comparison with respect to hierarchy h.

CompareOT

public static java.util.Vector<Candidate> CompareOT(java.util.Vector<Candidate> candidate_set,
                                                    Constraint[] h)
This method returns the most harmonic subset of comparison with respect to hierarchy h, according the method Optimality Grammar, using the hierarchy as specified in the array h. The higher the index of a constraint in h, the higher it is ranked in the hierarchy.

Parameters:
candidate_set - : A Vector of Candidates to be compared.
h - : The Hierarchy according to which comparison is done.
Returns:
The most harmonic subset of comparison with respect to hierarchy h.