org.finetracker
Class FeatureVector

java.lang.Object
  extended by org.finetracker.FeatureVector

public class FeatureVector
extends java.lang.Object

This class represents a FeatureVector. A FeatureVector is essentially an array of measures of articulatoric features, represented by values between 0 and 1, inclusive. It also has a character representing the phoneme which this FeatureVector stands for.

Author:
Frank Kusters

Field Summary
static FeatureVector NULL_VECTOR
          A FeatureVector containing only NaN values.
 
Constructor Summary
FeatureVector(double[] features)
          Creates a FeatureVector containing the specified features.
 
Method Summary
 double calcDistance(FeatureVector fv)
          Calculates the distance between this FeatureVector and another one.
 boolean equals(java.lang.Object otherObject)
          Compares the features of this FeatureVector to the features of another one.
 char getPhoneme()
           
static FeatureVector parseFeatureVector(java.lang.String s)
          Converts a string of numbers to a FeatureVector.
static void setDistanceCalculation(DistanceCalculation dcParam)
          Sets the DistanceCalculation object to use.
 void setPhoneme(char phoneme)
           
 java.lang.String toString()
          Gets a string representation of this Feature Vector.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL_VECTOR

public static final FeatureVector NULL_VECTOR
A FeatureVector containing only NaN values. This FeatureVector is used at the root of the input and the lexicon, to make sure that Hypothesis-objects that stay at the root get a high score.

Constructor Detail

FeatureVector

public FeatureVector(double[] features)
              throws java.io.IOException
Creates a FeatureVector containing the specified features. Only the array reference is copied, not the entire array. Therefore it is the responsibility of the calling code to supply a new array. This is done for performance reasons.

Parameters:
features - features which this vector shall represent
Throws:
java.io.IOException - if the number of features supplied does not match the number of features expected.
Method Detail

calcDistance

public double calcDistance(FeatureVector fv)
Calculates the distance between this FeatureVector and another one. The actual calculation is done in an object that implements the DistanceCalculation interface.

Parameters:
fv - FeatureVector to calculate the distance to
Returns:
the distance between this FeatureVector and fv

parseFeatureVector

public static FeatureVector parseFeatureVector(java.lang.String s)
                                        throws java.io.IOException
Converts a string of numbers to a FeatureVector. If the String cannot be parsed, an exception is thrown.

Parameters:
s - the string to be converted
Returns:
the resultant FeatureVector
Throws:
java.io.IOException - if a string from the input could not be converted to a number, or if the number of features read doesn't match the expected number of features

setDistanceCalculation

public static void setDistanceCalculation(DistanceCalculation dcParam)
Sets the DistanceCalculation object to use.

Parameters:
dcParam - the DistanceCalculation object to use

getPhoneme

public char getPhoneme()
Returns:
the phoneme

setPhoneme

public void setPhoneme(char phoneme)
Parameters:
phoneme - the phoneme to set

equals

public boolean equals(java.lang.Object otherObject)
Compares the features of this FeatureVector to the features of another one. The phoneme is not checked for equality.

Overrides:
equals in class java.lang.Object
Parameters:
otherObject - the FeatureVector to compare to.
Returns:
true when the features of both vectors are equal, false when not.
See Also:
Object.equals(java.lang.Object)

toString

public java.lang.String toString()
Gets a string representation of this Feature Vector. It consists of the phoneme, followed by a colon and a space, followed by all elements of features seperated by spaces.

Overrides:
toString in class java.lang.Object
Returns:
the string representation
See Also:
Object.toString()