Package opennlp.tools.postag
Class POSTaggerCrossValidator
java.lang.Object
opennlp.tools.postag.POSTaggerCrossValidator
-
Constructor Summary
ConstructorsConstructorDescriptionPOSTaggerCrossValidator
(String languageCode, TrainingParameters trainParam, File tagDictionary, byte[] featureGeneratorBytes, Map<String, Object> resources, Integer tagdicCutoff, String factoryClass, POSTagFormat format, POSTaggerEvaluationMonitor... listeners) Initializes aPOSTaggerCrossValidator
that builds a ngram dictionary dynamically.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, POSTagFormat format, POSTaggerEvaluationMonitor... listeners) Creates aPOSTaggerCrossValidator
using the givenPOSTaggerFactory
.POSTaggerCrossValidator
(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTaggerEvaluationMonitor... listeners) Creates aPOSTaggerCrossValidator
using the givenPOSTaggerFactory
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
evaluate
(ObjectStream<POSSample> samples, int nFolds) Starts the evaluation.double
long
-
Constructor Details
-
POSTaggerCrossValidator
public POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, File tagDictionary, byte[] featureGeneratorBytes, Map<String, Object> resources, Integer tagdicCutoff, String factoryClass, POSTagFormat format, 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.format
- A validPOSTagFormat
.listeners
- Theevaluation listeners
.
-
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
.
-
POSTaggerCrossValidator
public POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTagFormat format, 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.format
- A validPOSTagFormat
.listeners
- Theevaluation listeners
.
-
-
Method Details
-
evaluate
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.
-