Package opennlp.tools.ml.model
Class AbstractModel
java.lang.Object
opennlp.tools.ml.model.AbstractModel
- All Implemented Interfaces:
MaxentModel
- Direct Known Subclasses:
GISModel,PerceptronModel,QNModel
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal StringgetAllOutcomes(double[] ocs) Return a string matching all the outcome names with all the probabilities produced by theeval(String[] context)method.final StringgetBestOutcome(double[] ocs) Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.final Object[]Provides the fundamental data structures which encode the maxent model information.intGets the index associated with the String name of the given outcome.intReturns the number of outcomes for this model.final StringgetOutcome(int i) Return the name of an outcome corresponding to an int id.inthashCode()Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.ml.model.MaxentModel
eval, eval, eval
-
Constructor Details
-
AbstractModel
-
-
Method Details
-
getBestOutcome
Return the name of the outcome corresponding to the highest likelihood in the parameter ocs.- Specified by:
getBestOutcomein interfaceMaxentModel- Parameters:
ocs- A double[] as returned by the eval(String[] context) method.- Returns:
- The name of the most likely outcome.
-
getModelType
-
getAllOutcomes
Return a string matching all the outcome names with all the probabilities produced by theeval(String[] context)method.- Specified by:
getAllOutcomesin interfaceMaxentModel- Parameters:
ocs- Adouble[]as returned by theeval(String[] context)method.- Returns:
- String containing outcome names paired with the normalized
probability (contained in the
double[] ocs) for each one.
-
getOutcome
Return the name of an outcome corresponding to an int id.- Specified by:
getOutcomein interfaceMaxentModel- Parameters:
i- An outcome id.- Returns:
- The name of the outcome associated with that id.
-
getIndex
Gets the index associated with the String name of the given outcome.- Specified by:
getIndexin interfaceMaxentModel- 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:MaxentModelReturns the number of outcomes for this model.- Specified by:
getNumOutcomesin interfaceMaxentModel- Returns:
- The number of outcomes.
-
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.tools.ml.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.
- Returns:
- An Object[] with the values as described above.
-
hashCode
public int hashCode() -
equals
-