本文整理汇总了Java中info.ephyra.questionanalysis.atype.QuestionClassifier类的典型用法代码示例。如果您正苦于以下问题:Java QuestionClassifier类的具体用法?Java QuestionClassifier怎么用?Java QuestionClassifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QuestionClassifier类属于info.ephyra.questionanalysis.atype包,在下文中一共展示了QuestionClassifier类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classify
import info.ephyra.questionanalysis.atype.QuestionClassifier; //导入依赖的package包/类
public List<AnswerType> classify(Instance instance)
{
List<AnswerType> res = new ArrayList<AnswerType>();
for (QuestionClassifier classifier : classifiers) {
List<AnswerType> classifierResult = classifier.classify(instance);
if (classifierResult != null && classifierResult.size() > 0
&& !classifierResult.get(0).getType().equals("NOANS")) {
if (!mergeResults) return classifierResult;
for (AnswerType atype : classifierResult)
if (!res.contains(atype)) res.add(atype);
}
}
Collections.sort(res, atypeComparator);
for (int i = 0; i < res.size(); i++) {
if (res.get(i).getConfidence() < confidenceThreshold) {
res.remove(i);
i--;
}
}
if (res.size() == 0)
res.add(AnswerType.constructFromString("NONE"));
return res;
}
示例2: initialize
import info.ephyra.questionanalysis.atype.QuestionClassifier; //导入依赖的package包/类
public void initialize() throws Exception
{
// return if already initialized
if (isInitialized()) return;
if (languagePair == null)
throw new Exception("languagePair must be set before calling initialize");
super.initialize();
Properties properties = Properties.loadFromClassName(this.getClass().getName());
properties = properties.mapProperties().get(languagePair.getFirst()+"_"+languagePair.getSecond());
String classifierClassNames = properties.get("classifierTypes").trim();
if (classifierClassNames == null)
throw new RuntimeException("Required property classifierTypes is undefined");
String[] classNames = classifierClassNames.split(",");
classifiers = new ArrayList<QuestionClassifier>();
for (String className : classNames) {
QuestionClassifier classifier = (QuestionClassifier)Class.forName(className).newInstance();
classifier.setLanguagePair(languagePair);
classifier.initialize();
classifiers.add(classifier);
}
String mergeResultsStr = properties.get("mergeResults").trim();
if (mergeResultsStr == null)
throw new RuntimeException("Required property mergeResults is undefined");
mergeResults = Boolean.parseBoolean(mergeResultsStr);
String confidenceThresholdStr = properties.get("confidenceThreshold").trim();
if (mergeResultsStr == null)
throw new RuntimeException("Required property confidenceThreshold is undefined");
confidenceThreshold = Double.parseDouble(confidenceThresholdStr);
setInitialized(true);
}