当前位置: 首页>>代码示例>>Java>>正文


Java QuestionClassifier类代码示例

本文整理汇总了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;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:25,代码来源:HybridQuestionClassifier.java

示例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);
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:38,代码来源:HybridQuestionClassifier.java


注:本文中的info.ephyra.questionanalysis.atype.QuestionClassifier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。