Class LanguageDetectorCrossValidator
java.lang.Object
opennlp.tools.langdetect.LanguageDetectorCrossValidator
Cross validator for
LanguageDetector.-
Constructor Summary
ConstructorsConstructorDescriptionLanguageDetectorCrossValidator(opennlp.tools.util.TrainingParameters mlParams, LanguageDetectorFactory factory, opennlp.tools.langdetect.LanguageDetectorEvaluationMonitor... listeners) Initializes aLanguageDetectorCrossValidatorwith the givenparameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidevaluate(opennlp.tools.util.ObjectStream<opennlp.tools.langdetect.LanguageSample> samples, int nFolds) Starts the evaluation.doublelong
-
Constructor Details
-
LanguageDetectorCrossValidator
public LanguageDetectorCrossValidator(opennlp.tools.util.TrainingParameters mlParams, LanguageDetectorFactory factory, opennlp.tools.langdetect.LanguageDetectorEvaluationMonitor... listeners) Initializes aLanguageDetectorCrossValidatorwith the givenparameters.- Parameters:
mlParams- TheTrainingParametersfor the context of cross validation.factory- TheLanguageDetectorFactoryfor creating related objects.listeners- theevaluation listeners.
-
-
Method Details
-
evaluate
public void evaluate(opennlp.tools.util.ObjectStream<opennlp.tools.langdetect.LanguageSample> 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.
-
getDocumentAccuracy
public double getDocumentAccuracy()- Returns:
- Retrieves the word accuracy for all iterations.
-
getDocumentCount
public long getDocumentCount()- 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.
-