cc.mallet.pipe
Class Array2FeatureVector

java.lang.Object
  extended by cc.mallet.pipe.Pipe
      extended by cc.mallet.pipe.Array2FeatureVector
All Implemented Interfaces:
AlphabetCarrying, java.io.Serializable

public class Array2FeatureVector
extends Pipe

Converts a Java array of numerical types to a FeatureVector, where the Alphabet is the data array index wrapped in an Integer object.

Author:
Jerod Weinman weinman@cs.umass.edu
See Also:
Serialized Form

Constructor Summary
Array2FeatureVector()
           
Array2FeatureVector(Alphabet dataAlphabet, Alphabet targetAlphabet)
          Construct a pipe based on the dimensions of the data and target.
Array2FeatureVector(int capacity)
           
 
Method Summary
 Instance pipe(Instance carrier)
          Convert the data in an Instance from an array to a FeatureVector leaving other fields unchanged.
 int size()
          Current size of the Vocabulary
 
Methods inherited from class cc.mallet.pipe.Pipe
alphabetsMatch, getAlphabet, getAlphabets, getDataAlphabet, getInstanceId, getTargetAlphabet, instanceFrom, instancesFrom, instancesFrom, isDataAlphabetSet, isTargetProcessing, newIteratorFrom, preceedingPipeDataAlphabetNotification, preceedingPipeTargetAlphabetNotification, precondition, readResolve, setDataAlphabet, setOrCheckDataAlphabet, setOrCheckTargetAlphabet, setTargetAlphabet, setTargetProcessing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Array2FeatureVector

public Array2FeatureVector(int capacity)

Array2FeatureVector

public Array2FeatureVector()

Array2FeatureVector

public Array2FeatureVector(Alphabet dataAlphabet,
                           Alphabet targetAlphabet)
Construct a pipe based on the dimensions of the data and target.

Method Detail

pipe

public Instance pipe(Instance carrier)
              throws java.lang.IllegalStateException
Convert the data in an Instance from an array to a FeatureVector leaving other fields unchanged. Instance.getData() must return a numeric array, and it is cast to double[]

Overrides:
pipe in class Pipe
Throws:
java.lang.IllegalStateException - If Instance.getTarget() is not a Labeling

size

public int size()
Current size of the Vocabulary