marytts.unitselection.select
Class FFRTargetCostFunction

java.lang.Object
  extended by marytts.unitselection.select.FFRTargetCostFunction
All Implemented Interfaces:
TargetCostFunction
Direct Known Subclasses:
HalfPhoneFFRTargetCostFunction

public class FFRTargetCostFunction
extends java.lang.Object
implements TargetCostFunction


Nested Class Summary
 class FFRTargetCostFunction.TargetCostReporter
           
 
Field Summary
protected  double[] cumulWeightedCosts
           
protected  boolean debugShowCostGraph
           
protected  FeatureDefinition featureDefinition
           
protected  FeatureVector[] featureVectors
           
protected  int nCostComputations
           
protected  TargetFeatureComputer targetFeatureComputer
           
protected  WeightFunc[] weightFunction
           
protected  boolean[] weightsNonZero
           
 
Constructor Summary
FFRTargetCostFunction()
           
 
Method Summary
 void computeTargetFeatures(Target target)
          Compute the features for a given target, and store them in the target.
 double cost(Target target, Unit unit)
          Compute the goodness-of-fit of a given unit for a given target.
protected  double cost(Target target, Unit unit, FeatureDefinition weights, WeightFunc[] weightFunctions)
           
 java.lang.String getFeature(Unit unit, java.lang.String featureName)
          Get the string representation of the feature value associated with the given unit
 FeatureDefinition getFeatureDefinition()
          Provide access to the Feature Definition used.
 FeatureVector getFeatureVector(Unit unit)
          Look up the features for a given unit.
 FeatureVector[] getFeatureVectors()
          Get all feature vectors.
 void load(FeatureFileReader ffr, java.lang.String weightsFile, FeatureProcessorManager featProc)
          Initialise the data needed to do a target cost computation.
 void load(java.lang.String featureFileName, java.lang.String weightsFile, FeatureProcessorManager featProc)
          Initialise the data needed to do a target cost computation.
protected  void rememberWhichWeightsAreNonZero()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weightFunction

protected WeightFunc[] weightFunction

targetFeatureComputer

protected TargetFeatureComputer targetFeatureComputer

featureVectors

protected FeatureVector[] featureVectors

featureDefinition

protected FeatureDefinition featureDefinition

weightsNonZero

protected boolean[] weightsNonZero

debugShowCostGraph

protected boolean debugShowCostGraph

cumulWeightedCosts

protected double[] cumulWeightedCosts

nCostComputations

protected int nCostComputations
Constructor Detail

FFRTargetCostFunction

public FFRTargetCostFunction()
Method Detail

cost

public double cost(Target target,
                   Unit unit)
Compute the goodness-of-fit of a given unit for a given target.

Specified by:
cost in interface TargetCostFunction
Parameters:
target -
unit -
Returns:
a non-negative number; smaller values mean better fit, i.e. smaller cost.

cost

protected double cost(Target target,
                      Unit unit,
                      FeatureDefinition weights,
                      WeightFunc[] weightFunctions)

load

public void load(java.lang.String featureFileName,
                 java.lang.String weightsFile,
                 FeatureProcessorManager featProc)
          throws java.io.IOException
Initialise the data needed to do a target cost computation.

Specified by:
load in interface TargetCostFunction
Parameters:
featureFileName - name of a file containing the unit features
weightsFile - an optional weights file -- if non-null, contains feature weights that override the ones present in the feature file.
featProc - a feature processor manager which can provide feature processors to compute the features for a target at run time
Throws:
java.io.IOException

load

public void load(FeatureFileReader ffr,
                 java.lang.String weightsFile,
                 FeatureProcessorManager featProc)
          throws java.io.IOException
Description copied from interface: TargetCostFunction
Initialise the data needed to do a target cost computation.

Specified by:
load in interface TargetCostFunction
Parameters:
ffr - a reader for the file containing the unit features
weightsFile - an optional weights file -- if non-null, contains feature weights that override the ones present in the feature file.
featProc - a feature processor manager which can provide feature processors to compute the features for a target at run time
Throws:
java.io.IOException

rememberWhichWeightsAreNonZero

protected void rememberWhichWeightsAreNonZero()

computeTargetFeatures

public void computeTargetFeatures(Target target)
Compute the features for a given target, and store them in the target.

Specified by:
computeTargetFeatures in interface TargetCostFunction
Parameters:
target - the target for which to compute the features
See Also:
Target.getFeatureVector()

getFeatureVector

public FeatureVector getFeatureVector(Unit unit)
Look up the features for a given unit.

Specified by:
getFeatureVector in interface TargetCostFunction
Parameters:
unit - a unit in the database
Returns:
the FeatureVector for target cost computation associated to this unit

getFeature

public java.lang.String getFeature(Unit unit,
                                   java.lang.String featureName)
Get the string representation of the feature value associated with the given unit

Specified by:
getFeature in interface TargetCostFunction
Parameters:
unit - the unit whose feature value is requested
featureName - name of the feature requested
Returns:
a string representation of the feature value
Throws:
java.lang.IllegalArgumentException - if featureName is not a known feature

getFeatureDefinition

public FeatureDefinition getFeatureDefinition()
Description copied from interface: TargetCostFunction
Provide access to the Feature Definition used.

Specified by:
getFeatureDefinition in interface TargetCostFunction
Returns:
the feature definition object.

getFeatureVectors

public FeatureVector[] getFeatureVectors()
Description copied from interface: TargetCostFunction
Get all feature vectors. This is useful for more efficient access.

Specified by:
getFeatureVectors in interface TargetCostFunction
Returns:
the full array of feature vectors, or null if this method is not supported.