本文整理匯總了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);
}