Package opennlp.tools.ml.maxent
Class GIS
- java.lang.Object
-
- opennlp.tools.ml.AbstractTrainer
-
- opennlp.tools.ml.AbstractEventTrainer
-
- opennlp.tools.ml.maxent.GIS
-
- All Implemented Interfaces:
EventTrainer
public class GIS extends AbstractEventTrainer
A Factory class which uses instances of GISTrainer to create and train GISModels.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MAXENT_VALUE
static boolean
PRINT_MESSAGES
Set this to false if you don't want messages about the progress of model training displayed.static double
SMOOTHING_OBSERVATION
If we are using smoothing, this is used as the "number" of times we want the trainer to imagine that it saw a feature that it actually didn't see.-
Fields inherited from class opennlp.tools.ml.AbstractEventTrainer
DATA_INDEXER_ONE_PASS_VALUE, DATA_INDEXER_PARAM, DATA_INDEXER_TWO_PASS_VALUE
-
Fields inherited from class opennlp.tools.ml.AbstractTrainer
ALGORITHM_PARAM, CUTOFF_DEFAULT, CUTOFF_PARAM, ITERATIONS_DEFAULT, ITERATIONS_PARAM, TRAINER_TYPE_PARAM
-
Fields inherited from interface opennlp.tools.ml.EventTrainer
EVENT_VALUE
-
-
Constructor Summary
Constructors Constructor Description GIS()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractModel
doTrain(DataIndexer indexer)
boolean
isSortAndMerge()
boolean
isValid()
static GISModel
trainModel(int iterations, DataIndexer indexer)
Train a model using the GIS algorithm.static GISModel
trainModel(int iterations, DataIndexer indexer, boolean smoothing)
Train a model using the GIS algorithm.static GISModel
trainModel(int iterations, DataIndexer indexer, boolean printMessagesWhileTraining, boolean smoothing, Prior modelPrior, int cutoff)
Train a model using the GIS algorithm.static GISModel
trainModel(int iterations, DataIndexer indexer, boolean printMessagesWhileTraining, boolean smoothing, Prior modelPrior, int cutoff, int threads)
Train a model using the GIS algorithm.static GISModel
trainModel(int iterations, DataIndexer indexer, Prior modelPrior, int cutoff)
Train a model using the GIS algorithm with the specified number of iterations, data indexer, and prior.static GISModel
trainModel(ObjectStream<Event> eventStream)
Train a model using the GIS algorithm, assuming 100 iterations and no cutoff.static GISModel
trainModel(ObjectStream<Event> eventStream, boolean smoothing)
Train a model using the GIS algorithm, assuming 100 iterations and no cutoff.static GISModel
trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff)
Train a model using the GIS algorithm.static GISModel
trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff, boolean smoothing, boolean printMessagesWhileTraining)
Train a model using the GIS algorithm.static GISModel
trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff, double sigma)
Train a model using the GIS algorithm.-
Methods inherited from class opennlp.tools.ml.AbstractEventTrainer
getDataIndexer, train
-
Methods inherited from class opennlp.tools.ml.AbstractTrainer
getAlgorithm, getCutoff, getIterations, init
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface opennlp.tools.ml.EventTrainer
init
-
-
-
-
Field Detail
-
MAXENT_VALUE
public static final java.lang.String MAXENT_VALUE
- See Also:
- Constant Field Values
-
PRINT_MESSAGES
public static boolean PRINT_MESSAGES
Set this to false if you don't want messages about the progress of model training displayed. Alternately, you can use the overloaded version of trainModel() to conditionally enable progress messages.
-
SMOOTHING_OBSERVATION
public static double SMOOTHING_OBSERVATION
If we are using smoothing, this is used as the "number" of times we want the trainer to imagine that it saw a feature that it actually didn't see. Defaulted to 0.1.
-
-
Method Detail
-
isValid
public boolean isValid()
- Overrides:
isValid
in classAbstractEventTrainer
-
isSortAndMerge
public boolean isSortAndMerge()
- Specified by:
isSortAndMerge
in classAbstractEventTrainer
-
doTrain
public AbstractModel doTrain(DataIndexer indexer) throws java.io.IOException
- Specified by:
doTrain
in classAbstractEventTrainer
- Throws:
java.io.IOException
-
trainModel
public static GISModel trainModel(ObjectStream<Event> eventStream) throws java.io.IOException
Train a model using the GIS algorithm, assuming 100 iterations and no cutoff.- Parameters:
eventStream
- The EventStream holding the data on which this model will be trained.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
- Throws:
java.io.IOException
-
trainModel
public static GISModel trainModel(ObjectStream<Event> eventStream, boolean smoothing) throws java.io.IOException
Train a model using the GIS algorithm, assuming 100 iterations and no cutoff.- Parameters:
eventStream
- The EventStream holding the data on which this model will be trained.smoothing
- Defines whether the created trainer will use smoothing while training the model.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
- Throws:
java.io.IOException
-
trainModel
public static GISModel trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff) throws java.io.IOException
Train a model using the GIS algorithm.- Parameters:
eventStream
- The EventStream holding the data on which this model will be trained.iterations
- The number of GIS iterations to perform.cutoff
- The number of times a feature must be seen in order to be relevant for training.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
- Throws:
java.io.IOException
-
trainModel
public static GISModel trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff, boolean smoothing, boolean printMessagesWhileTraining) throws java.io.IOException
Train a model using the GIS algorithm.- Parameters:
eventStream
- The EventStream holding the data on which this model will be trained.iterations
- The number of GIS iterations to perform.cutoff
- The number of times a feature must be seen in order to be relevant for training.smoothing
- Defines whether the created trainer will use smoothing while training the model.printMessagesWhileTraining
- Determines whether training status messages are written to STDOUT.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
- Throws:
java.io.IOException
-
trainModel
public static GISModel trainModel(ObjectStream<Event> eventStream, int iterations, int cutoff, double sigma) throws java.io.IOException
Train a model using the GIS algorithm.- Parameters:
eventStream
- The EventStream holding the data on which this model will be trained.iterations
- The number of GIS iterations to perform.cutoff
- The number of times a feature must be seen in order to be relevant for training.sigma
- The standard deviation for the gaussian smoother.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
- Throws:
java.io.IOException
-
trainModel
public static GISModel trainModel(int iterations, DataIndexer indexer, boolean smoothing)
Train a model using the GIS algorithm.- Parameters:
iterations
- The number of GIS iterations to perform.indexer
- The object which will be used for event compilation.smoothing
- Defines whether the created trainer will use smoothing while training the model.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-
trainModel
public static GISModel trainModel(int iterations, DataIndexer indexer)
Train a model using the GIS algorithm.- Parameters:
iterations
- The number of GIS iterations to perform.indexer
- The object which will be used for event compilation.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-
trainModel
public static GISModel trainModel(int iterations, DataIndexer indexer, Prior modelPrior, int cutoff)
Train a model using the GIS algorithm with the specified number of iterations, data indexer, and prior.- Parameters:
iterations
- The number of GIS iterations to perform.indexer
- The object which will be used for event compilation.modelPrior
- The prior distribution for the model.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-
trainModel
public static GISModel trainModel(int iterations, DataIndexer indexer, boolean printMessagesWhileTraining, boolean smoothing, Prior modelPrior, int cutoff)
Train a model using the GIS algorithm.- Parameters:
iterations
- The number of GIS iterations to perform.indexer
- The object which will be used for event compilation.printMessagesWhileTraining
- Determines whether training status messages are written to STDOUT.smoothing
- Defines whether the created trainer will use smoothing while training the model.modelPrior
- The prior distribution for the model.cutoff
- The number of times a predicate must occur to be used in a model.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-
trainModel
public static GISModel trainModel(int iterations, DataIndexer indexer, boolean printMessagesWhileTraining, boolean smoothing, Prior modelPrior, int cutoff, int threads)
Train a model using the GIS algorithm.- Parameters:
iterations
- The number of GIS iterations to perform.indexer
- The object which will be used for event compilation.printMessagesWhileTraining
- Determines whether training status messages are written to STDOUT.smoothing
- Defines whether the created trainer will use smoothing while training the model.modelPrior
- The prior distribution for the model.cutoff
- The number of times a predicate must occur to be used in a model.- Returns:
- The newly trained model, which can be used immediately or saved to disk using an opennlp.tools.ml.maxent.io.GISModelWriter object.
-
-