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 aPOSTaggerCrossValidatorthat 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 aPOSTaggerCrossValidatorthat builds a ngram dictionary dynamically.POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTagFormat format, POSTaggerEvaluationMonitor... listeners) Creates aPOSTaggerCrossValidatorusing the givenPOSTaggerFactory.POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTaggerEvaluationMonitor... listeners) Creates aPOSTaggerCrossValidatorusing the givenPOSTaggerFactory. -
Method Summary
Modifier and TypeMethodDescriptionvoidevaluate(ObjectStream<POSSample> samples, int nFolds) Starts the evaluation.doublelong
-
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 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.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 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.
-
POSTaggerCrossValidator
public POSTaggerCrossValidator(String languageCode, TrainingParameters trainParam, POSTaggerFactory factory, POSTagFormat format, POSTaggerEvaluationMonitor... listeners) Creates aPOSTaggerCrossValidatorusing the givenPOSTaggerFactory.- Parameters:
languageCode- An ISO conform language code.trainParam- TheTrainingParametersfor the context of cross validation.factory- ThePOSTaggerFactoryto be used.format- A validPOSTagFormat.listeners- Theevaluation listeners.
-
-
Method Details
-
evaluate
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.
-