calhoun.analysis.crf.io
Class InputSequenceComposite

java.lang.Object
  extended by calhoun.analysis.crf.io.InputSequenceComposite
All Implemented Interfaces:
InputSequence<java.util.Map<java.lang.String,java.lang.Object>>

public class InputSequenceComposite
extends java.lang.Object
implements InputSequence<java.util.Map<java.lang.String,java.lang.Object>>

a composite input sequence made up of individual components. This is useful when putting together different features that may take different inputs. Each component is given a name within the overall composite and can be reference by that name. All sequences must have the same length. The value at any position in the sequence is a map that relates component names to their values at that position.


Constructor Summary
InputSequenceComposite()
          default constructor.
InputSequenceComposite(java.util.Map<java.lang.String,InputSequence<?>> data)
          constructor that initializes the sequence with a set of components.
 
Method Summary
 void addComponent(java.lang.String name, InputSequence<?> seq)
          adds a new component input sequence to this composite.
 void addComponents(java.util.Map<java.lang.String,InputSequence<?>> data)
          adds all input sequences in the given map as components.
 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.
 java.util.Map<java.lang.String,InputSequence<?>> getComponents()
          returns all of components of this input sequence.
 java.util.Map<java.lang.String,java.lang.Object> getX(int ix)
          retrieves the input value at a position in the input sequence.
 int length()
          Returns the length of this sequence
 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.
 InputSequenceComposite 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputSequenceComposite

public InputSequenceComposite()
default constructor. Components should be added with addComponents.


InputSequenceComposite

public InputSequenceComposite(java.util.Map<java.lang.String,InputSequence<?>> data)
constructor that initializes the sequence with a set of components.

Parameters:
data - the initial input sequences to use as the components
Method Detail

addComponent

public void addComponent(java.lang.String name,
                         InputSequence<?> seq)
adds a new component input sequence to this composite. Each new component must have a unique name and all components must have the same length.


addComponents

public void addComponents(java.util.Map<java.lang.String,InputSequence<?>> data)
adds all input sequences in the given map as components.


getComponents

public java.util.Map<java.lang.String,InputSequence<?>> getComponents()
returns all of components of this input sequence.

Returns:
a map that maps component names to input sequences

getX

public java.util.Map<java.lang.String,java.lang.Object> getX(int ix)
Description copied from interface: InputSequence
retrieves the input value at a position in the input sequence.

Specified by:
getX in interface InputSequence<java.util.Map<java.lang.String,java.lang.Object>>
Parameters:
ix - the index position at which to get the input. This is a zero-based index.
Returns:
the object at this position in the input.

length

public int length()
Description copied from interface: InputSequence
Returns the length of this sequence

Specified by:
length in interface InputSequence<java.util.Map<java.lang.String,java.lang.Object>>
Returns:
length

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<java.util.Map<java.lang.String,java.lang.Object>>
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<java.util.Map<java.lang.String,java.lang.Object>>
Returns:
a collection containing the component names

subSequence

public InputSequenceComposite 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<java.util.Map<java.lang.String,java.lang.Object>>
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.