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 aPOSTaggerCrossValidatorthat builds a ngram dictionary dynamically.POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTaggerEvaluationMonitor... listeners)Creates aPOSTaggerCrossValidatorusing the givenPOSTaggerFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidevaluate(ObjectStream<POSSample> samples, int nFolds)Starts the evaluation.doublegetWordAccuracy()longgetWordCount()
-
-
-
Constructor Detail
-
POSTaggerCrossValidator
public POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, File tagDictionary, byte[] featureGeneratorBytes, Map<String,Object> resources, Integer tagdicCutoff, String factoryClass, POSTaggerEvaluationMonitor... listeners)
Initializes aPOSTaggerCrossValidatorthat builds a ngram dictionary dynamically. It instantiates a subclass ofPOSTaggerFactoryusing the tag and the ngram dictionaries.- Parameters:
languageCode- An ISO conform language code.trainParam- TheTrainingParametersfor the context of cross validation.tagDictionary- TheFilethat 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 aPOSTaggerCrossValidatorusing the givenPOSTaggerFactory.- Parameters:
languageCode- An ISO conform language code.trainParam- TheTrainingParametersfor the context of cross validation.factory- ThePOSTaggerFactoryto be used.listeners- Theevaluation listeners.
-
-
Method Detail
-
evaluate
public void evaluate(ObjectStream<POSSample> samples, int nFolds) throws IOException
Starts the evaluation.- Parameters:
samples- TheObjectStreamofsamplesto 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.
-
-