hhreco.recognition
Class MSTrainingModel

java.lang.Object
  extended byhhreco.recognition.MSTrainingModel

public class MSTrainingModel
extends java.lang.Object

MSTrainingModel (Multi-Stroke Training Model) is a data structure for storing training examples and their types. Each training example is a set of TimedStroke objects.


Field Summary
static boolean NEGATIVE
          Internal constant for the array slot of negative examples.
static boolean POSITIVE
          Internal constant for the array slot of positive examples.
 
Constructor Summary
MSTrainingModel()
          Construct an empty training model.
 
Method Summary
 void addExample(java.lang.String t, TimedStroke[] s, boolean which)
          Add an example to this training model for the given type (either positive or negative, denoted by the "which" argument).
 void addNegativeExample(java.lang.String t, TimedStroke[] s)
          Add a negative example to this training model for the given type.
 void addPositiveExample(java.lang.String t, TimedStroke[] s)
          Add a positive example to this training model for the given type.
 void clear()
          Remvoe all data from the model.
 void combine(MSTrainingModel model)
          Add the data in the specified model into "this" model.
 boolean containsType(java.lang.String t)
          Return true if the training type with the specified name is in the model, or false otherwise.
 TimedStroke[] getNegativeExample(java.lang.String t, int i)
          Return the negative example at the specified index for the given type.
 TimedStroke[] getPositiveExample(java.lang.String t, int i)
          Return the positive example at the specified index for the given type.
 int getTypeCount()
          Return how many types are contained in this training model.
 int negativeExampleCount(java.lang.String t)
          Return the number of negative examples for the given type.
 java.util.Iterator negativeExamples(java.lang.String t)
          An iterator over the negative examples for the given type.
 int positiveExampleCount(java.lang.String t)
          Returns the number of positive examples for the given type.
 java.util.Iterator positiveExamples(java.lang.String t)
          An iterator over the positive examples for the given type.
 void removeExample(java.lang.String t, TimedStroke[] s, boolean which)
          Remove the specified example of the given type from this training model.
 void removeNegativeExample(java.lang.String t, TimedStroke[] s)
          Remove the specified negative example of the specified type from this training set.
 void removePositiveExample(java.lang.String t, TimedStroke[] s)
          Remove the specified positive example of the specified type from this training set.
 void removeType(java.lang.String t)
          Remove the specified type from this training set.
 java.lang.String toString()
          Text representation of this class containing information on the types and the number of positive and negative examples in the model.
 java.util.Iterator types()
          An iterator over the types contained in this training model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NEGATIVE

public static final boolean NEGATIVE
Internal constant for the array slot of negative examples.

See Also:
Constant Field Values

POSITIVE

public static final boolean POSITIVE
Internal constant for the array slot of positive examples.

See Also:
Constant Field Values
Constructor Detail

MSTrainingModel

public MSTrainingModel()
Construct an empty training model.

Method Detail

addNegativeExample

public final void addNegativeExample(java.lang.String t,
                                     TimedStroke[] s)
Add a negative example to this training model for the given type.


addPositiveExample

public final void addPositiveExample(java.lang.String t,
                                     TimedStroke[] s)
Add a positive example to this training model for the given type.


addExample

public final void addExample(java.lang.String t,
                             TimedStroke[] s,
                             boolean which)
Add an example to this training model for the given type (either positive or negative, denoted by the "which" argument).


clear

public void clear()
Remvoe all data from the model.


combine

public final void combine(MSTrainingModel model)
Add the data in the specified model into "this" model.


containsType

public final boolean containsType(java.lang.String t)
Return true if the training type with the specified name is in the model, or false otherwise.


getPositiveExample

public final TimedStroke[] getPositiveExample(java.lang.String t,
                                              int i)
Return the positive example at the specified index for the given type.


getNegativeExample

public final TimedStroke[] getNegativeExample(java.lang.String t,
                                              int i)
Return the negative example at the specified index for the given type.


getTypeCount

public final int getTypeCount()
Return how many types are contained in this training model.


negativeExampleCount

public final int negativeExampleCount(java.lang.String t)
Return the number of negative examples for the given type.


negativeExamples

public final java.util.Iterator negativeExamples(java.lang.String t)
An iterator over the negative examples for the given type. Each example returned in the iterator is an array of TimedStrokes (TimedStroke[]).


positiveExampleCount

public final int positiveExampleCount(java.lang.String t)
Returns the number of positive examples for the given type.


positiveExamples

public final java.util.Iterator positiveExamples(java.lang.String t)
An iterator over the positive examples for the given type. Each example returned in the iterator is an array of TimedStrokes (TimedStroke[]).


removeExample

public final void removeExample(java.lang.String t,
                                TimedStroke[] s,
                                boolean which)
Remove the specified example of the given type from this training model. (either positive or negative, denoted by the "which" argument). If the type contains no examples (both positive and negative), remove the type from the model.


removeNegativeExample

public final void removeNegativeExample(java.lang.String t,
                                        TimedStroke[] s)
Remove the specified negative example of the specified type from this training set. This method cannot be called while iterating over the negative examples, otherwise a ConcurrentModificationException will be thrown.


removePositiveExample

public final void removePositiveExample(java.lang.String t,
                                        TimedStroke[] s)
Remove the specified positive example of the specified type from this training set. This method cannot be called while iterating over the positive examples, otherwise a ConcurrentModificationException will be thrown.


removeType

public final void removeType(java.lang.String t)
Remove the specified type from this training set. This method cannot be called while iterating over the types, otherwise a ConcurrentModificationException will be thrown.


types

public java.util.Iterator types()
An iterator over the types contained in this training model.


toString

public java.lang.String toString()
Text representation of this class containing information on the types and the number of positive and negative examples in the model.