本文整理汇总了Java中opennlp.tools.ml.AbstractEventTrainer类的典型用法代码示例。如果您正苦于以下问题:Java AbstractEventTrainer类的具体用法?Java AbstractEventTrainer怎么用?Java AbstractEventTrainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractEventTrainer类属于opennlp.tools.ml包,在下文中一共展示了AbstractEventTrainer类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValid
import opennlp.tools.ml.AbstractEventTrainer; //导入依赖的package包/类
public static boolean isValid(Map<String, String> trainParams) {
// TODO: Need to validate all parameters correctly ... error prone?!
String algorithmName = trainParams.get(AbstractTrainer.ALGORITHM_PARAM);
// If a trainer type can be determined, then the trainer is valid!
if (algorithmName != null &&
!BUILTIN_TRAINERS.containsKey(algorithmName) && getTrainerType(trainParams) == null) {
return false;
}
try {
String cutoffString = trainParams.get(AbstractTrainer.CUTOFF_PARAM);
if (cutoffString != null) Integer.parseInt(cutoffString);
String iterationsString = trainParams.get(AbstractTrainer.ITERATIONS_PARAM);
if (iterationsString != null) Integer.parseInt(iterationsString);
}
catch (NumberFormatException e) {
return false;
}
String dataIndexer = trainParams.get(AbstractEventTrainer.DATA_INDEXER_PARAM);
if (dataIndexer != null) {
if (!(AbstractEventTrainer.DATA_INDEXER_ONE_PASS_VALUE.equals(dataIndexer)
|| AbstractEventTrainer.DATA_INDEXER_TWO_PASS_VALUE.equals(dataIndexer)
|| AgeClassifyGIS.DATA_INDEXER_CHI_SQUARED.equals(dataIndexer))) {
return false;
}
}
// TODO: Check data indexing ...
return true;
}