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

java.lang.Object
  extended by se.lth.cs.nlp.nlputils.ml.FeatureDeclaration
All Implemented Interfaces:
Serializable

public class FeatureDeclaration
extends Object
implements Serializable

Declaration of a feature set.

Author:
Richard Johansson (richard@cs.lth.se)
See Also:
Serialized Form

Constructor Summary
FeatureDeclaration()
          Creates a new, empty, feature set.
FeatureDeclaration(String[] names)
          Creates a new feature set from the given feature names.
 
Method Summary
 void addFeature(String name)
          Adds a new feature to the feature set.
 void addFeature(String name, int n)
          Adds a new feature to the feature set, and assigns it the given number.
 int getFeatureIndex(String name)
          Returns the feature number of the given feature.
 int size()
          Returns the number of active features in this feature set.
 FeatureDeclaration subset(Collection<String> used)
          Returns a FeatureDeclaration that is a subset of this declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FeatureDeclaration

public FeatureDeclaration()
Creates a new, empty, feature set.


FeatureDeclaration

public FeatureDeclaration(String[] names)
Creates a new feature set from the given feature names.

Parameters:
names - the feature names.
Method Detail

addFeature

public void addFeature(String name)
Adds a new feature to the feature set.

Parameters:
name - the name of the new feature.

addFeature

public void addFeature(String name,
                       int n)
Adds a new feature to the feature set, and assigns it the given number.

Parameters:
name - the name of the new feature.
n - the number to assign it.

getFeatureIndex

public int getFeatureIndex(String name)
Returns the feature number of the given feature.

Parameters:
name - the feature name.
Returns:
the number.

size

public int size()
Returns the number of active features in this feature set.

Returns:
the number of active features.

subset

public FeatureDeclaration subset(Collection<String> used)
Returns a FeatureDeclaration that is a subset of this declaration.

Parameters:
used - the names of the features that should be included in the subset.
Returns:
the subset.