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


Java Instance.setProperty方法代码示例

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


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

示例1: add

import cc.mallet.types.Instance; //导入方法依赖的package包/类
/**
 * Add instances. The exact way of how the target is created to the instances depends on which
 * parameters are given and which are null. The parameter sequenceAS must always be null for this
 * corpus representation since this corpus representation is not usable for sequence tagging
 * algorithms If the parameter classAS is non-null then instances for a sequence tagging task are
 * created, in that case targetFeatureName must be null. If targetFeatureName is non-null then
 * instances for a regression or classification problem are created (depending on targetType) and
 * classAS must be null. if the parameter nameFeatureName is non-null, then a Mallet instance name
 * is added from the source document and annotation.
 *
 * @param instancesAS
 * @param inputAS
 * @param nameFeatureName
 */
@Override
public void add(AnnotationSet instancesAS, AnnotationSet sequenceAS, AnnotationSet inputAS, AnnotationSet classAS, String targetFeatureName, TargetType targetType, String instanceWeightFeature, String nameFeatureName, SeqEncoder seqEncoder) {
  if(sequenceAS != null) {
    throw new GateRuntimeException("LF invalid call to CorpusRepresentationMallet.add: sequenceAS must be null "+
            " for document "+inputAS.getDocument().getName());
  }
  List<Annotation> instanceAnnotations = instancesAS.inDocumentOrder();
  for (Annotation instanceAnnotation : instanceAnnotations) {
    Instance inst = extractIndependentFeaturesHelper(instanceAnnotation, inputAS, featureInfo, pipe);
    if (classAS != null) {
      // extract the target as required for sequence tagging
      FeatureExtraction.extractClassForSeqTagging(inst, pipe.getTargetAlphabet(), classAS, instanceAnnotation, seqEncoder);
    } else {
      if(targetType == TargetType.NOMINAL) {
        FeatureExtraction.extractClassTarget(inst, pipe.getTargetAlphabet(), targetFeatureName, instanceAnnotation, inputAS);
      } else if(targetType == TargetType.NUMERIC) {
        FeatureExtraction.extractNumericTarget(inst, targetFeatureName, instanceAnnotation, inputAS);
      }
    }
    // if a nameFeature is specified, add the name informatin to the instance
    if(nameFeatureName != null) {
      FeatureExtraction.extractName(inst, instanceAnnotation, inputAS.getDocument());
    }
    if(instanceWeightFeature != null && !instanceWeightFeature.isEmpty()) {
      // If the instanceWeightFeature is not specified we do not set any weight, but if it is 
      // specified then we either try to convert the value to double or use 1.0.
      double score = LFUtils.anyToDoubleOrElse(instanceAnnotation.getFeatures().get(instanceWeightFeature), 1.0);
      inst.setProperty("instanceWeight", score);
    }
    if(!FeatureExtraction.ignoreInstanceWithMV(inst)) {
      instances.add(inst);
    }
  }
}
 
开发者ID:GateNLP,项目名称:gateplugin-LearningFramework,代码行数:49,代码来源:CorpusRepresentationMalletTarget.java

示例2: pipe

import cc.mallet.types.Instance; //导入方法依赖的package包/类
public Instance pipe (Instance carrier)
{
  Tokenization tok = (Tokenization) carrier.getData ();
  carrier.setProperty ("TOKENIZATION", tok);
  return carrier;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:7,代码来源:RememberTokenizationPipe.java


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