com.penguinwerks.jodene.data
Class NMinusOneClassTranslator
java.lang.Object
com.penguinwerks.jodene.data.Translator
com.penguinwerks.jodene.data.NMinusOneClassTranslator
- All Implemented Interfaces:
- java.io.Serializable
- public class NMinusOneClassTranslator
- extends Translator
- implements java.io.Serializable
This class encodes a set of values using N-1 encoding, that is,
if it a class with K members is encoded using K-1 values. For
example:
Assume the class has the values {"dog", "cat", "gold-fish"} and
these values are defined in that order for this translator:
- "dog" -> 0.0, 0.0
- "cat" -> 1.0, 0.0
- "gold-fish" -> 0.0, 1.0
- Author:
- Paul Hoehne
- See Also:
- Serialized Form
|
Method Summary |
int |
getOutputSize()
The numer of doubles in the output array. |
double[] |
translate(java.lang.String values)
The N-1 translator returns N-1 doubles for N possible strings. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NMinusOneClassTranslator
public NMinusOneClassTranslator()
translate
public double[] translate(java.lang.String values)
throws TranslatorException
- The N-1 translator returns N-1 doubles for N possible strings. For
example, if the strings are { "car", "plane", "train", "boat" } then
there are 4 possible strings of 3 values { 0.0, 0.0, 0.0 } for "car",
{ 1.0, 0.0, 0.0 } for "plane", { 0.0, 1.0, 0.0 } for "traine", and
{ 0.0, 0.0, 1.0 } for "boat". If an unexpected string is entered,
"rocket", for example, then an exception is thrown.
- Specified by:
translate in class Translator
- Parameters:
values - The string to be translated.
- Returns:
- The array representing this string.
- Throws:
TranslatorException - Thrown if the string is not a known class.
getOutputSize
public int getOutputSize()
- The numer of doubles in the output array.
- Specified by:
getOutputSize in class Translator
- Returns:
- The size of the output array.