opennlp.model
Class AbstractModel

java.lang.Object
  extended by opennlp.model.AbstractModel
All Implemented Interfaces:
MaxentModel
Direct Known Subclasses:
GISModel, PerceptronModel, QNModel

public abstract class AbstractModel
extends Object
implements MaxentModel


Nested Class Summary
static class AbstractModel.ModelType
           
 
Constructor Summary
AbstractModel(Context[] params, String[] predLabels, IndexHashTable<String> pmap, String[] outcomeNames)
           
AbstractModel(Context[] params, String[] predLabels, String[] outcomeNames)
           
AbstractModel(Context[] params, String[] predLabels, String[] outcomeNames, int correctionConstant, double correctionParam)
           
 
Method Summary
 String getAllOutcomes(double[] ocs)
          Return a string matching all the outcome names with all the probabilities produced by the eval(String[] context) method.
 String getBestOutcome(double[] ocs)
          Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.
 Object[] getDataStructures()
          Provides the fundamental data structures which encode the maxent model information.
 int getIndex(String outcome)
          Gets the index associated with the String name of the given outcome.
 AbstractModel.ModelType getModelType()
           
 int getNumOutcomes()
          Returns the number of outcomes for this model.
 String getOutcome(int i)
          Return the name of an outcome corresponding to an int id.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface opennlp.model.MaxentModel
eval, eval, eval
 

Constructor Detail

AbstractModel

public AbstractModel(Context[] params,
                     String[] predLabels,
                     IndexHashTable<String> pmap,
                     String[] outcomeNames)

AbstractModel

public AbstractModel(Context[] params,
                     String[] predLabels,
                     String[] outcomeNames)

AbstractModel

public AbstractModel(Context[] params,
                     String[] predLabels,
                     String[] outcomeNames,
                     int correctionConstant,
                     double correctionParam)
Method Detail

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 MaxentModel
Parameters:
ocs - A double[] as returned by the eval(String[] context) method.
Returns:
The name of the most likely outcome.

getModelType

public AbstractModel.ModelType getModelType()

getAllOutcomes

public final String getAllOutcomes(double[] ocs)
Return a string matching all the outcome names with all the probabilities produced by the eval(String[] context) method.

Specified by:
getAllOutcomes in interface MaxentModel
Parameters:
ocs - A double[] as returned by the eval(String[] context) 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)
Return the name of an outcome corresponding to an int id.

Specified by:
getOutcome in interface MaxentModel
Parameters:
i - An outcome id.
Returns:
The name of the outcome associated with that id.

getIndex

public int getIndex(String outcome)
Gets the index associated with the String name of the given outcome.

Specified by:
getIndex in interface MaxentModel
Parameters:
outcome - the String name of the outcome for which the index is desired
Returns:
the index if the given outcome label exists for this model, -1 if it does not.

getNumOutcomes

public int getNumOutcomes()
Description copied from interface: MaxentModel
Returns the number of outcomes for this model.

Specified by:
getNumOutcomes in interface MaxentModel
Returns:
The number of outcomes.

getDataStructures

public final Object[] getDataStructures()
Provides the fundamental data structures which encode the maxent model information. This method will usually only be needed by GISModelWriters. The following values are held in the Object array which is returned by this method:
  • index 0: opennlp.maxent.Context[] containing the model parameters
  • index 1: java.util.Map containing the mapping of model predicates to unique integers
  • index 2: java.lang.String[] containing the names of the outcomes, stored in the index of the array which represents their unique ids in the model.
  • index 3: java.lang.Integer containing the value of the models correction constant
  • index 4: java.lang.Double containing the value of the models correction parameter

    Specified by:
    getDataStructures in interface MaxentModel
    Returns:
    An Object[] with the values as described above.


  • Copyright © 2013 The Apache Software Foundation. All Rights Reserved.