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


Java Classifier.classify方法代码示例

本文整理汇总了Java中cc.mallet.classify.Classifier.classify方法的典型用法代码示例。如果您正苦于以下问题:Java Classifier.classify方法的具体用法?Java Classifier.classify怎么用?Java Classifier.classify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.mallet.classify.Classifier的用法示例。


在下文中一共展示了Classifier.classify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyModel

import cc.mallet.classify.Classifier; //导入方法依赖的package包/类
@Override
public List<ModelApplication> applyModel(
        AnnotationSet instanceAS, AnnotationSet inputAS, AnnotationSet sequenceAS, String parms) {
  // NOTE: the crm should be of type CorpusRepresentationMalletClass for this to work!
  if(!(corpusRepresentation instanceof CorpusRepresentationMalletTarget)) {
    throw new GateRuntimeException("Cannot perform classification with data from "+corpusRepresentation.getClass());
  }
  CorpusRepresentationMalletTarget data = (CorpusRepresentationMalletTarget)corpusRepresentation;
  data.stopGrowth();
  List<ModelApplication> gcs = new ArrayList<ModelApplication>();
  LFPipe pipe = (LFPipe)data.getRepresentationMallet().getPipe();
  Classifier classifier = (Classifier)model;
  // iterate over the instance annotations and create mallet instances 
  for(Annotation instAnn : instanceAS.inDocumentOrder()) {
    Instance inst = data.extractIndependentFeatures(instAnn, inputAS);
    inst = pipe.instanceFrom(inst);
    Classification classification = classifier.classify(inst);
    Labeling labeling = classification.getLabeling();
    LabelVector labelvec = labeling.toLabelVector();
    List<String> classes = new ArrayList<String>(labelvec.numLocations());
    List<Double> confidences = new ArrayList<Double>(labelvec.numLocations());
    for(int i=0; i<labelvec.numLocations(); i++) {
      classes.add(labelvec.getLabelAtRank(i).toString());
      confidences.add(labelvec.getValueAtRank(i));
    }      
    ModelApplication gc = new ModelApplication(instAnn, labeling.getBestLabel().toString(), 
            labeling.getBestValue(), classes, confidences);
    //System.err.println("ADDING GC "+gc);
    // now save the class in our special class feature on the instance as well
    instAnn.getFeatures().put("gate.LF.target",labeling.getBestLabel().toString());
    gcs.add(gc);
  }
  data.startGrowth();
  return gcs;
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:36,代码来源:EngineMBMalletClass.java

示例2: classify

import cc.mallet.classify.Classifier; //导入方法依赖的package包/类
/**
 * 
 * @param instance the instance to classify
 * @param useOutOfFold whether to check the instance name and use the out-of-fold classifier
 * if the instance name matches one in the training data
 * @return the token classifier's output
 */
public Classification classify(Instance instance, boolean useOutOfFold)
{
	Object instName = instance.getName();
	
	if (! useOutOfFold || ! m_table.containsKey(instName))
		return m_tokenClassifier.classify(instance);
	
	Classifier classifier = (Classifier) m_table.get(instName);

	return classifier.classify(instance);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:19,代码来源:AddClassifierTokenPredictions.java


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