Package opennlp.tools.postag
Class POSTaggerCrossValidator
- java.lang.Object
-
- opennlp.tools.postag.POSTaggerCrossValidator
-
public class POSTaggerCrossValidator extends Object
-
-
Constructor Summary
Constructors Constructor Description POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, File tagDictionary, byte[] featureGeneratorBytes, Map<String,Object> resources, Integer tagdicCutoff, String factoryClass, POSTaggerEvaluationMonitor... listeners)
Initializes aPOSTaggerCrossValidator
that builds a ngram dictionary dynamically.POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTaggerEvaluationMonitor... listeners)
Creates aPOSTaggerCrossValidator
using the givenPOSTaggerFactory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
evaluate(ObjectStream<POSSample> samples, int nFolds)
Starts the evaluation.double
getWordAccuracy()
long
getWordCount()
-
-
-
Constructor Detail
-
POSTaggerCrossValidator
public POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, File tagDictionary, byte[] featureGeneratorBytes, Map<String,Object> resources, Integer tagdicCutoff, String factoryClass, POSTaggerEvaluationMonitor... listeners)
Initializes aPOSTaggerCrossValidator
that builds a ngram dictionary dynamically. It instantiates a subclass ofPOSTaggerFactory
using the tag and the ngram dictionaries.- Parameters:
languageCode
- An ISO conform language code.trainParam
- TheTrainingParameters
for the context of cross validation.tagDictionary
- TheFile
that references the aTagDictionary
.featureGeneratorBytes
- The bytes for feature generation.resources
- Additional resources as key-value map.factoryClass
- The class name used for factory instantiation.listeners
- Theevaluation listeners
.
-
POSTaggerCrossValidator
public POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTaggerEvaluationMonitor... listeners)
Creates aPOSTaggerCrossValidator
using the givenPOSTaggerFactory
.- Parameters:
languageCode
- An ISO conform language code.trainParam
- TheTrainingParameters
for the context of cross validation.factory
- ThePOSTaggerFactory
to be used.listeners
- Theevaluation listeners
.
-
-
Method Detail
-
evaluate
public void evaluate(ObjectStream<POSSample> samples, int nFolds) throws IOException
Starts the evaluation.- Parameters:
samples
- TheObjectStream
ofsamples
to train and test with.nFolds
- Number of folds. It must be greater than zero.- Throws:
IOException
- Thrown if IO errors occurred.
-
getWordAccuracy
public double getWordAccuracy()
- Returns:
- Retrieves the accuracy for all iterations.
-
getWordCount
public long getWordCount()
- Returns:
- Retrieves the number of words which where validated over all iterations. The result is the amount of folds multiplied by the total number of words.
-
-