edu.cmu.minorthird.classify.sequential
Class InstanceFromSequence

java.lang.Object
  extended by edu.cmu.minorthird.classify.sequential.InstanceFromSequence
All Implemented Interfaces:
HasSubpopulationId, Instance, SequenceConstants, Visible

public class InstanceFromSequence
extends java.lang.Object
implements Instance, SequenceConstants

An instance that appears as part of a sequence.

Author:
William Cohen

Field Summary
 
Fields inherited from interface edu.cmu.minorthird.classify.sequential.SequenceConstants
HISTORY_FEATURE, NULL_CLASS_NAME
 
Constructor Summary
InstanceFromSequence(Instance instance, java.lang.String[] previousLabels)
           
 
Method Summary
 Instance asPlainInstance()
          Return the wrapped instance.
 java.util.Iterator<Feature> binaryFeatureIterator()
          Return an iterator over all binary features.
 java.util.Iterator<Feature> featureIterator()
          Return an iterator over all features
static void fillHistory(java.lang.String[] history, ClassLabel[] labels, int j)
          Utility to create history from a sequence of class labels, starting at positive j-1.
static void fillHistory(java.lang.String[] history, Example[] sequence, int j)
          Utility to create history from a sequence of examples, starting at positive j-1.
static void fillHistory(java.lang.String[] history, java.lang.String[] labels, int j)
          Utility to create history from a sequence of Strings, starting at positive j-1.
 java.lang.Object getSource()
          Get the underlying object used that this instance describes
 java.lang.String getSubpopulationId()
          Get the subpopulation from which this instance was drawn.
 double getWeight(Feature f)
          Get the weight assigned to a feature in this instance.
static void main(java.lang.String[] argv)
           
 java.util.Iterator<Feature> numericFeatureIterator()
          Return an iterator over all numeric features.
 int numFeatures()
          Return the number of all the features
 Viewer toGUI()
          Create a view of this object
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InstanceFromSequence

public InstanceFromSequence(Instance instance,
                            java.lang.String[] previousLabels)
Parameters:
instance - - the instance to extend
previousLabels - - element k is the classLabel of the example (k+1) positions before this instance in the sequence.
Method Detail

asPlainInstance

public Instance asPlainInstance()
Return the wrapped instance.


getSource

public final java.lang.Object getSource()
Description copied from interface: Instance
Get the underlying object used that this instance describes

Specified by:
getSource in interface Instance

getSubpopulationId

public final java.lang.String getSubpopulationId()
Description copied from interface: Instance
Get the subpopulation from which this instance was drawn. A null id is considered to be a unique subpopulation---different from every other subpopulation, including other nulls. A subpopulation is a subset of the training data which is expected to contain additional regularities - for instance, pages from the same site, or spans from the same document. Testing routines may use subpopulation's to more correctly spit datasets into train/test subsets.

Specified by:
getSubpopulationId in interface HasSubpopulationId
Specified by:
getSubpopulationId in interface Instance

numericFeatureIterator

public final java.util.Iterator<Feature> numericFeatureIterator()
Description copied from interface: Instance
Return an iterator over all numeric features.

Specified by:
numericFeatureIterator in interface Instance

binaryFeatureIterator

public final java.util.Iterator<Feature> binaryFeatureIterator()
Description copied from interface: Instance
Return an iterator over all binary features.

Specified by:
binaryFeatureIterator in interface Instance

featureIterator

public final java.util.Iterator<Feature> featureIterator()
Description copied from interface: Instance
Return an iterator over all features

Specified by:
featureIterator in interface Instance

numFeatures

public final int numFeatures()
Description copied from interface: Instance
Return the number of all the features

Specified by:
numFeatures in interface Instance

getWeight

public final double getWeight(Feature f)
Description copied from interface: Instance
Get the weight assigned to a feature in this instance.

Specified by:
getWeight in interface Instance

toString

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

toGUI

public final Viewer toGUI()
Description copied from interface: Visible
Create a view of this object

Specified by:
toGUI in interface Visible

fillHistory

public static void fillHistory(java.lang.String[] history,
                               Example[] sequence,
                               int j)
Utility to create history from a sequence of examples, starting at positive j-1.


fillHistory

public static void fillHistory(java.lang.String[] history,
                               ClassLabel[] labels,
                               int j)
Utility to create history from a sequence of class labels, starting at positive j-1.


fillHistory

public static void fillHistory(java.lang.String[] history,
                               java.lang.String[] labels,
                               int j)
Utility to create history from a sequence of Strings, starting at positive j-1.


main

public static void main(java.lang.String[] argv)