cc.mallet.types.Instance.getTarget()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中cc.mallet.types.Instance.getTarget()方法的一些代码示例,展示了Instance.getTarget()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getTarget()方法的具体详情如下:
包路径:cc.mallet.types.Instance
类名称:Instance
方法名:getTarget

Instance.getTarget介绍

暂无

代码示例

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance pipe (Instance carrier) {
  if (carrier.getTarget() != null) {
    if (! (carrier.getTarget() instanceof String)) {
      throw new IllegalArgumentException ("Target must be a string for conversion to Double");
    }
    carrier.setTarget( new Double((String) carrier.getTarget()) );
  }
  return carrier;
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Instance pipe (Instance carrier) {
  if (carrier.getTarget() != null) {
    if (! (carrier.getTarget() instanceof String)) {
      throw new IllegalArgumentException ("Target must be a string for conversion to Double");
    }
    carrier.setTarget( new Double((String) carrier.getTarget()) );
  }
  return carrier;
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance pipe (Instance carrier) {
  if (carrier.getTarget() != null) {
    if (! (carrier.getTarget() instanceof String)) {
      throw new IllegalArgumentException ("Target must be a String for conversion to Integer");
    }
    carrier.setTarget( new Integer((String) carrier.getTarget()) );
  }
  return carrier;
}

代码示例来源:origin: cc.mallet/mallet

public Instance pipe (Instance carrier)
{
  if (carrier.getTarget() != null) {
    if (carrier.getTarget() instanceof Label)
      throw new IllegalArgumentException ("Already a label.");
    LabelAlphabet ldict = (LabelAlphabet) getTargetAlphabet();
    carrier.setTarget(ldict.lookupLabel (carrier.getTarget()));
  }
  return carrier;
}

代码示例来源:origin: com.github.steveash.jg2p/jg2p-core

@Override
public Instance pipe(Instance inst) {
 List<String> source = (List<String>) inst.getData();
 inst.setData(makeTokenSeq(source));
 if (inst.getTarget() != null && updateTarget) {
  List<String> target = (List<String>) inst.getTarget();
  Preconditions.checkState(target.size() == source.size(), "target %s source %s", target, source);
  inst.setTarget(makeTokenSeq(target));
 }
 return inst;
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public Instance pipe (Instance carrier)
 {
  LabelsSequence lbls = (LabelsSequence) carrier.getTarget ();
  carrier.setTarget (new LabelsAssignment (lbls));
  return carrier;
 }
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public LabelsSequence getBestLabels (Instance inst)
{
 Assignment assn = bestAssignment (inst);
 LabelsAssignment gold = (LabelsAssignment) inst.getTarget ();
 return gold.toLabelsSequence (assn);
}

代码示例来源:origin: cc.mallet/mallet

public InstanceWithConfidence (Instance inst, double c, Sequence predicted) {
  this.instance = inst;
  this.confidence = c;
  this.correct = true;
  Sequence truth = (Sequence) inst.getTarget ();
  for (int i=0; i < truth.size(); i++) {
    if (!truth.get(i).equals (predicted.get(i))) {
      this.correct = false;
      break;
    }                
  }
}

代码示例来源:origin: com.github.steveash.mallet/mallet

public FeatureVectorIterator (Iterator<Instance> inputIterator) {
  superInstance = inputIterator.next();
  dataSubiterator = ((FeatureVectorSequence)superInstance.getData()).iterator();
  targetSubiterator = ((LabelSequence)superInstance.getTarget()).iterator();
}
public Instance next () {

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public FeatureVectorIterator (Iterator<Instance> inputIterator) {
  superInstance = inputIterator.next();
  dataSubiterator = ((FeatureVectorSequence)superInstance.getData()).iterator();
  targetSubiterator = ((LabelSequence)superInstance.getTarget()).iterator();
}
public Instance next () {

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public InstanceWithConfidence (Instance inst, double c, Sequence predicted) {
  this.instance = inst;
  this.confidence = c;
  this.correct = true;
  Sequence truth = (Sequence) inst.getTarget ();
  for (int i=0; i < truth.size(); i++) {
    if (!truth.get(i).equals (predicted.get(i))) {
      this.correct = false;
      break;
    }                
  }
}

代码示例来源:origin: com.github.steveash.jg2p/jg2p-core

@Override
 public Instance pipe(Instance inst) {
  LabelSequence seq = (LabelSequence) inst.getTarget();
  LabelsSequence sseq = new LabelsSequence(seq);
  LabelsAssignment labels = new LabelsAssignment(sseq);
  inst.setTarget(labels);
  return inst;
 }
}

代码示例来源:origin: cc.mallet/mallet

private static void printTrialClassification(Trial trial)
{
  for (Classification c : trial) {
    Instance instance = c.getInstance();
    System.out.print(instance.getName() + " " + instance.getTarget() + " ");
    Labeling labeling = c.getLabeling();
    for (int j = 0; j < labeling.numLocations(); j++){
      System.out.print(labeling.getLabelAtRank(j).toString() + ":" + labeling.getValueAtRank(j) + " ");
    }
    System.out.println();
  }
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

private static void printTrialClassification(Trial trial)
{
  for (Classification c : trial) {
    Instance instance = c.getInstance();
    System.out.print(instance.getName() + " " + instance.getTarget() + " ");
    Labeling labeling = c.getLabeling();
    for (int j = 0; j < labeling.numLocations(); j++){
      System.out.print(labeling.getLabelAtRank(j).toString() + ":" + labeling.getValueAtRank(j) + " ");
    }
    System.out.println();
  }
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Instance next ()
{
 Instance inst = subIt.next ();
 inst = pipe.pipe (inst);
 return new Instance (inst.getData (), inst.getTarget (), inst.getName (), inst.getSource ());
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

public Instance next ()	{
  if (currentIndex >= currentTokenSequence.size()) {
    currentInstance = source.next();
    currentTokenSequence = (TokenSequence) currentInstance.getData();
  }
  Instance ret = new Instance (currentTokenSequence.get(currentIndex),
      ((LabelSequence)currentInstance.getTarget()).getLabelAtPosition(currentIndex),
      null, null);
  currentIndex++;
  return ret;
}
public boolean hasNext ()	{

代码示例来源:origin: com.github.steveash.jg2p/jg2p-core

@Override
 public Instance pipe(Instance inst) {
  TokenSequence seq = (TokenSequence) inst.getData();
  seq.add("<END>");
  TokenSequence maybe = (TokenSequence) inst.getTarget();
  if (maybe != null) {
   maybe.add("<END>");
   Preconditions.checkState(maybe.size() == seq.size());
  }
  return inst;
 }
}

代码示例来源:origin: cc.mallet/mallet

private static void printTrialClassification(Trial trial)
{
  for (int i = 0; i < trial.size(); i++) {
    Instance instance = trial.get(i).getInstance();
    System.out.print(instance.getName() + " " + instance.getTarget() + " ");
    Labeling labeling = trial.get(i).getLabeling();
    for (int j = 0; j < labeling.numLocations(); j++){
      System.out.print(labeling.getLabelAtRank(j).toString() + ":" + labeling.getValueAtRank(j) + " ");
    }
    System.out.println();
  }
}

代码示例来源:origin: cc.mallet/mallet

public void unhideAllLabels ()
{
  for (int i = 0; i < this.size(); i++) {
    Instance instance = this.get(i);
    Object t;
    if (instance.getTarget() == null && (t=instance.getProperty(TARGET_PROPERTY)) != null) {
      instance.unLock();
      instance.setTarget(t);
      instance.lock();
    }
  }
}

代码示例来源:origin: cc.mallet/mallet

public void test(InstanceList gold, List returned, String description)
{
 TestResults results = new TestResults (segmentStartTags, segmentContinueTags);
 for (int i = 0; i < gold.size(); i++) {
  Instance instance = gold.get(i);
  Sequence trueOutput = processTrueOutput ((Sequence) instance.getTarget());
  Sequence predOutput = slice ((LabelsSequence) returned.get (i), slice);
  assert (predOutput.size() == trueOutput.size());
  results.incrementCounts (trueOutput, predOutput);
 }
 results.logResults (description);
}

相关文章