se.lth.cs.nlp.nlputils.ml
Class FeatureList

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.ml.FeatureList

public class FeatureList
extends Object

A list of feature values.

Author:
Richard Johansson (richard@cs.lth.se)

Field Summary
 FeatureDeclaration decl
          The feature declaration that is used by this feature list.
 String[] features
          The array of feature values.
 
Constructor Summary
FeatureList(FeatureDeclaration decl)
          Creates a new feature list given a declaration.
FeatureList(FeatureDeclaration decl, String[] features)
          Creates a new feature list given a declaration, using the given array as storage.
 
Method Summary
 boolean equals(Object o)
           
 String getFeature(int index)
          Gets the value of a feature given by index.
 String getFeature(String featureName)
          Gets the value of a feature given by name.
 int hashCode()
           
 void setFeature(int featureIndex, String value)
          Sets the value of a feature given by index.
 void setFeature(String featureName, String value)
          Sets the value of a feature given by name.
 String toString()
           
 String toTrainingString()
          Returns a string that can be used to create training sets with the NumericEncoding.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

decl

public FeatureDeclaration decl
The feature declaration that is used by this feature list.


features

public String[] features
The array of feature values.

Constructor Detail

FeatureList

public FeatureList(FeatureDeclaration decl)
Creates a new feature list given a declaration.

Parameters:
decl - the declaration to use.

FeatureList

public FeatureList(FeatureDeclaration decl,
                   String[] features)
Creates a new feature list given a declaration, using the given array as storage.

Parameters:
decl - the declaration to use.
features - the array to use as storage.
Method Detail

setFeature

public void setFeature(String featureName,
                       String value)
Sets the value of a feature given by name. If the feature is declared inactive, then this method returns silently.

Parameters:
featureName - the name of the feature.
value - the value of the feature.

setFeature

public void setFeature(int featureIndex,
                       String value)
Sets the value of a feature given by index. If the feature is declared inactive, then this method returns silently.

Parameters:
featureIndex - the index of the feature.
value - the value of the feature.

getFeature

public String getFeature(String featureName)
Gets the value of a feature given by name. If the feature is declared inactive, then this method returns null.

Parameters:
featureName - the name of the feature.
Returns:
the value of the feature, or null if the feature is inactive.

getFeature

public String getFeature(int index)
Gets the value of a feature given by index. If the feature is declared inactive, then this method returns null.

Parameters:
index - the index of the feature.
Returns:
the value of the feature, or null if the feature is inactive.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

toTrainingString

public String toTrainingString()
Returns a string that can be used to create training sets with the NumericEncoding.

Returns:
the training string.