pt.tumba.ngram.bayes
Class DiscreteVariable

java.lang.Object
  extended by pt.tumba.ngram.bayes.DiscreteVariable
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ProbabilityVariable

public class DiscreteVariable
extends java.lang.Object
implements java.io.Serializable

***************************************************************

See Also:
Serialized Form

Field Summary
protected  int index
           
protected  java.lang.String name
           
protected  java.lang.String[] values
           
 
Constructor Summary
DiscreteVariable()
          Default constructor for a DiscreteVariable.
DiscreteVariable(DiscreteVariable dv)
          Simple constructor for DiscreteVariable.
DiscreteVariable(java.lang.String n_vb)
          Simple constructor for DiscreteVariable.
DiscreteVariable(java.lang.String vb, int vi, java.lang.String[] vl)
          Simple constructor for DiscreteVariable.
 
Method Summary
 int get_index()
          Get the index of the current DiscreteVariable.
 java.lang.String get_name()
          Get the name of the current DiscreteVariable.
 DiscreteFunction get_numeric_values()
          Produce an array of numeric values for the values of a variable.
 java.lang.String get_value(int i)
          Get a value of the current DiscreteVariable.
 java.lang.String[] get_values()
          Get the values of the current DiscreteVariable.
 int index_of_value(java.lang.String value)
          Determine the index of a value given its name; returns INVALID_INDEX if there is no index.
 int number_values()
          Return the number of values in the current DiscreteVariable.
 void print()
          Print method for DiscreteVariable.
 void print(java.io.PrintStream out)
          Print method for DiscreteVariable.
 void set_name(java.lang.String n)
          Set the name of the current DiscreteVariable.
 void set_values(java.lang.String[] vals)
          Set the values of the current DiscreteVariable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

index

protected int index

values

protected java.lang.String[] values
Constructor Detail

DiscreteVariable

public DiscreteVariable()
Default constructor for a DiscreteVariable.


DiscreteVariable

public DiscreteVariable(java.lang.String n_vb)
Simple constructor for DiscreteVariable.

Parameters:
n_vb - Name of the variable.

DiscreteVariable

public DiscreteVariable(java.lang.String vb,
                        int vi,
                        java.lang.String[] vl)
Simple constructor for DiscreteVariable.

Parameters:
vb - Name of the variable.
vi - Index of the variable.
vl - Values of the variable.

DiscreteVariable

public DiscreteVariable(DiscreteVariable dv)
Simple constructor for DiscreteVariable.

Parameters:
dv - DiscreteVariable that is copied into current DiscreteVariable.
Method Detail

index_of_value

public int index_of_value(java.lang.String value)
Determine the index of a value given its name; returns INVALID_INDEX if there is no index.


get_numeric_values

public DiscreteFunction get_numeric_values()
Produce an array of numeric values for the values of a variable. The values are direct translation of the string values into doubles; if the translation fails for a particular value, that value is replaced by its index.


print

public void print()
Print method for DiscreteVariable.


print

public void print(java.io.PrintStream out)
Print method for DiscreteVariable.


get_name

public java.lang.String get_name()
Get the name of the current DiscreteVariable.


set_name

public void set_name(java.lang.String n)
Set the name of the current DiscreteVariable.


get_index

public int get_index()
Get the index of the current DiscreteVariable.


number_values

public int number_values()
Return the number of values in the current DiscreteVariable.


get_values

public java.lang.String[] get_values()
Get the values of the current DiscreteVariable.


set_values

public void set_values(java.lang.String[] vals)
Set the values of the current DiscreteVariable.


get_value

public java.lang.String get_value(int i)
Get a value of the current DiscreteVariable.

Parameters:
i - Position of the value in the array of values.