edu.umass.cs.mallet.base.types
Class FeatureSequence

java.lang.Object
  extended byedu.umass.cs.mallet.base.types.FeatureSequence
All Implemented Interfaces:
Sequence, java.io.Serializable
Direct Known Subclasses:
FeatureSequenceWithBigrams, LabelSequence

public class FeatureSequence
extends java.lang.Object
implements Sequence, java.io.Serializable

An implementation of Sequence that ensures that every Object in the sequence has the same class. Feature sequences are mutable, and will expand as new objects are added.

See Also:
Serialized Form

Constructor Summary
FeatureSequence(Alphabet dict)
           
FeatureSequence(Alphabet dict, int capacity)
           
FeatureSequence(Alphabet dict, int[] features)
          Creates a FeatureSequence given all of the objects in the sequence.
FeatureSequence(Alphabet dict, int[] features, int len)
           
 
Method Summary
 void add(int featureIndex)
           
 void add(java.lang.Object key)
           
 void addFeatureWeightsTo(double[] weights)
           
 void addFeatureWeightsTo(double[] weights, double scale)
           
 java.lang.Object get(int pos)
           
 Alphabet getAlphabet()
           
 int getIndexAtPosition(int pos)
           
 int getLength()
           
 java.lang.Object getObjectAtPosition(int pos)
           
protected  void growIfNecessary()
           
 int size()
           
 int[] toFeatureIndexSequence()
           
 int[] toSortedFeatureIndexSequence()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FeatureSequence

public FeatureSequence(Alphabet dict,
                       int[] features)
Creates a FeatureSequence given all of the objects in the sequence.

Parameters:
dict - A dictionary that maps objects in the sequence to numeric indices.
features - An array where features[i] gives the index in dict of the ith element of the sequence.

FeatureSequence

public FeatureSequence(Alphabet dict,
                       int[] features,
                       int len)

FeatureSequence

public FeatureSequence(Alphabet dict,
                       int capacity)

FeatureSequence

public FeatureSequence(Alphabet dict)
Method Detail

getAlphabet

public Alphabet getAlphabet()

getLength

public final int getLength()

size

public final int size()
Specified by:
size in interface Sequence

getIndexAtPosition

public final int getIndexAtPosition(int pos)

getObjectAtPosition

public java.lang.Object getObjectAtPosition(int pos)

get

public java.lang.Object get(int pos)
Specified by:
get in interface Sequence

toString

public java.lang.String toString()

growIfNecessary

protected void growIfNecessary()

add

public void add(int featureIndex)

add

public void add(java.lang.Object key)

addFeatureWeightsTo

public void addFeatureWeightsTo(double[] weights)

addFeatureWeightsTo

public void addFeatureWeightsTo(double[] weights,
                                double scale)

toFeatureIndexSequence

public int[] toFeatureIndexSequence()

toSortedFeatureIndexSequence

public int[] toSortedFeatureIndexSequence()