calhoun.analysis.crf.io
Class TrainingSequence<A>

java.lang.Object
  extended by calhoun.analysis.crf.io.TrainingSequence<A>
Type Parameters:
A - the elements which make up the input sequence which is part of this training sequence
All Implemented Interfaces:
InputSequence<A>

public class TrainingSequence<A>
extends java.lang.Object
implements InputSequence<A>

represents an input sequence that also contains a sequence of hidden states.


Constructor Summary
TrainingSequence(InputSequence<? extends A> xArg)
          constructs a training sequence using just the input sequence.
TrainingSequence(InputSequence<? extends A> xArg, int[] yArg)
          constructs a training sequence using these input and hidden sequences
 
Method Summary
 InputSequence<?> getComponent(java.lang.String name)
          For input sequences that are a composite of several different input objects, returns a particular component of the input.
 InputSequence<? extends A> getInputSequence()
          gets the underlying input sequence
 TrainingSequence getTrainingComponent(java.lang.String name)
          returns a new TrainingSequence created by taking a single component of the input sequence and pairing it with the hidden states for this Training Sequence.
 A getX(int ix)
          gets the value of the underlying input sequence at a particular position
 int[] getY()
          gets the vector of hidden state indices
 int getY(int x1)
          gets the hidden state index at a particular position
 int length()
          gets the length of the input and training sequences
 java.util.Collection<java.lang.String> listComponents()
          For input sequences that are a composite of several different input objects, returns a list of the names of the components in this input sequence.
 void setY(int[] hiddenStates)
          sets the vector of hidden state indices.
 void setY(int x, int z)
          sets the hidden state index at a particular position
 TrainingSequence<A> subSequence(int start, int end)
          tTakes a subinterval of the input sequence with given start-end coordinates which are relative coordinates, 1-based, and inclusive.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TrainingSequence

public TrainingSequence(InputSequence<? extends A> xArg)
constructs a training sequence using just the input sequence. The hidden sequence needs to be added later using setY.

Parameters:
xArg - the input sequence the hidden states correspond to

TrainingSequence

public TrainingSequence(InputSequence<? extends A> xArg,
                        int[] yArg)
constructs a training sequence using these input and hidden sequences

Parameters:
xArg - the input sequence the hidden states correspond to
yArg - the state indices of the values of the hidden states
Method Detail

getInputSequence

public InputSequence<? extends A> getInputSequence()
gets the underlying input sequence

Returns:
the underlying input sequence

getY

public int[] getY()
gets the vector of hidden state indices

Returns:
an array of ints containing the index of the hidden state at each position in the sequence

setY

public void setY(int[] hiddenStates)
sets the vector of hidden state indices. Must be the same length as the previsouly specified inputs

Parameters:
hiddenStates - an array of ints containing the index of the hidden state at each position in the sequence

getY

public int getY(int x1)
gets the hidden state index at a particular position

Parameters:
x1 - the 0-based position at which to get the hidden state index
Returns:
the hidden state index at this position

setY

public void setY(int x,
                 int z)
sets the hidden state index at a particular position

Parameters:
x - the 0-based position at which to get the hidden state index
z - the vlaue of the hidden state index to set for this position

getX

public A getX(int ix)
gets the value of the underlying input sequence at a particular position

Specified by:
getX in interface InputSequence<A>
Parameters:
ix - a zero-based index into the input sequence
Returns:
the value of the input sequence at the position

length

public int length()
gets the length of the input and training sequences

Specified by:
length in interface InputSequence<A>
Returns:
the length of the training sequence

getComponent

public InputSequence<?> getComponent(java.lang.String name)
Description copied from interface: InputSequence
For input sequences that are a composite of several different input objects, returns a particular component of the input. For simple input sequences that just return an object, this method should throw UnsupportedOperationException.

Specified by:
getComponent in interface InputSequence<A>
Parameters:
name - the name of the input component to return
Returns:
the input sequence representing this component

listComponents

public java.util.Collection<java.lang.String> listComponents()
Description copied from interface: InputSequence
For input sequences that are a composite of several different input objects, returns a list of the names of the components in this input sequence. For simple input sequences that just return an object, this method should throw UnsupportedOperationException.

Specified by:
listComponents in interface InputSequence<A>
Returns:
a collection containing the component names

getTrainingComponent

public TrainingSequence getTrainingComponent(java.lang.String name)
returns a new TrainingSequence created by taking a single component of the input sequence and pairing it with the hidden states for this Training Sequence. The input sequence must be a composite.

Parameters:
name - the name of the component to extract from the composite input sequence
Returns:
a new TrainingSequence created from teh extracted input sequence component

subSequence

public TrainingSequence<A> subSequence(int start,
                                       int end)
Description copied from interface: InputSequence
tTakes a subinterval of the input sequence with given start-end coordinates which are relative coordinates, 1-based, and inclusive. Thus 1-10 will mean returning a new InputSequence which is the first 10 positions of the current one.

An implementation that does not support subsetting should throw an UnsupportedOperationException

Specified by:
subSequence in interface InputSequence<A>
Parameters:
start - the 1-based index of the first position of the input to retrieve.
end - the 1-based index of the last position of the input to retrieve.
Returns:
an input sequence which is a sbusequence of the original sequence.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object