Package opennlp.tools.ml.model

# Class AbstractModel

java.lang.Object
opennlp.tools.ml.model.AbstractModel

All Implemented Interfaces:
  `opennlp.tools.ml.model.MaxentModel`

public abstract class AbstractModel extends Object implements opennlp.tools.ml.model.MaxentModel
A basic `MaxentModel` implementation.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AbstractModel(opennlp.tools.ml.model.Context[] params, String[] predLabels, String[] outcomeNames)`
  Initializes an `AbstractModel`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  `final String`
  `getAllOutcomes(double[] ocs)`
  Retrieves a string matching all the outcome names with all the probabilities produced by the `MaxentModel.eval(String[])` method.
  `final String`
  `getBestOutcome(double[] ocs)`
  Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.
  `final Object[]`
  `getDataStructures()`
  Provides the fundamental data structures which encode the `MaxentModel` information.
  `int`
  `getIndex(String outcome)`
  `opennlp.tools.ml.AlgorithmType`
  `getModelType()`
  `int`
  `getNumOutcomes()`
  `final String`
  `getOutcome(int i)`
  `int`
  `hashCode()`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface opennlp.tools.ml.model.MaxentModel

  `eval, eval, eval`

- ## Constructor Details

  - ### AbstractModel

    public AbstractModel(opennlp.tools.ml.model.Context[] params, String[] predLabels, String[] outcomeNames)
    Initializes an `AbstractModel`.
    Parameters:
      `params` - The `parameters` to set.
      `predLabels` - The predicted labels.
      `outcomeNames` - The names of the outcomes.

- ## Method Details

  - ### getBestOutcome

    public final String getBestOutcome(double[] ocs)
    Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.
    Specified by:
      `getBestOutcome` in interface `opennlp.tools.ml.model.MaxentModel`
    Parameters:
      `ocs` - A `double[]` as returned by the `method`.
    Returns:
      The name of the most likely outcome.

  - ### getModelType

    public opennlp.tools.ml.AlgorithmType getModelType()
    Returns:
      Retrieves the `AlgorithmType`.

  - ### getAllOutcomes

    public final String getAllOutcomes(double[] ocs)
    Retrieves a string matching all the outcome names with all the probabilities produced by the `MaxentModel.eval(String[])` method.
    Specified by:
      `getAllOutcomes` in interface `opennlp.tools.ml.model.MaxentModel`
    Parameters:
      `ocs` - A `double[]` as returned by the `MaxentModel.eval(String[])` method.
    Returns:
      String containing outcome names paired with the normalized probability (contained in the `double[] ocs`) for each one.

  - ### getOutcome

    public final String getOutcome(int i)
    Specified by:
      `getOutcome` in interface `opennlp.tools.ml.model.MaxentModel`
    Parameters:
      `i` - An outcome id.
    Returns:
      Retrieves the name of the outcome associated with `id`.

  - ### getIndex

    public int getIndex(String outcome)
    Specified by:
      `getIndex` in interface `opennlp.tools.ml.model.MaxentModel`
    Parameters:
      `outcome` - The String name of the outcome for which the index is desired.
    Returns:
      Retrieves the index if the given `outcome` label exists for this model, `-1` if it does not.

  - ### getNumOutcomes

    public int getNumOutcomes()
    Specified by:
      `getNumOutcomes` in interface `opennlp.tools.ml.model.MaxentModel`

  - ### getDataStructures

    public final Object[] getDataStructures()
    Provides the fundamental data structures which encode the `MaxentModel` information.

    The following values are held in the `Object[]` which is returned by this method:

    - index 0: `Context` array containing the model parameters.
    - index 1: `Map` containing the mapping of model predicates to unique integers.
    - index 2: `String` array containing the names of the outcomes, stored in the index of the array which represents their unique ids in the model.
    Returns:
      An `Object` array with the values as described above.

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### equals

    public boolean equals(Object obj)
    Overrides:
      `equals` in class `Object`