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

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

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

Instance.<init>介绍

[英]In certain unusual circumstances, you might want to create an Instance without sending it through a pipe.
[中]在某些特殊情况下,您可能希望创建实例而不通过管道发送它。

代码示例

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

public Instance shallowCopy ()
{
  Instance ret = new Instance (data, target, name, source);
  ret.locked = locked;
  ret.properties = properties;
  return ret;
}

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

public Instance next ()
{
  File nextFile = subIterator.next();
  fileCount++;
  return new Instance (nextFile, null, nextFile.toURI(), null);
}

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

public Instance next ()
{
  URI uri = null;
  try { uri = new URI ("array:" + index); }
  catch (Exception e) { e.printStackTrace(); throw new IllegalStateException(); }
  return new Instance (data[index++], null, uri, null);
}

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

public Instance next ()
{
  URI uri = null;
  try { uri = new URI ("array:" + index); }
  catch (Exception e) { e.printStackTrace(); throw new IllegalStateException(); }
  return new Instance (data[index++], null, uri, null);
}

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

public Instance next ()
{
  Segment nextSegment = (Segment) subIterator.next();
  return new Instance (nextSegment, nextSegment.getTruth (), null, null);
}

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

public Instance next ()
{
  Segment nextSegment = (Segment) subIterator.next();
  return new Instance (nextSegment, nextSegment.getTruth (), null, null);
}

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

public Instance next ()
{
  Instance carrier = new Instance (nextGroup, null, 
                                   "parengroup"+(groupIdx++), 
                                   null);
  nextGroup = getNextGroup ();
  return carrier;
}

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

public Instance next ()
{
 assert (nextElement != null);
 Instance carrier = new Instance (nextElement, null, "element"+elementIndex++,
                  null);
 nextElement = getNextElement ();
 return carrier;
}

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

private Tokenization doTokenize (Object obj)
{
 Instance toked = new Instance (obj, null, null, null);
 tokenizationPipe.pipe (toked);
 return (Tokenization) toked.getData ();
}

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

void addInstance(int[] features, boolean positive) {
 FeatureVector featureVector = new FeatureVector(dataAlphabet, features);
 Instance instance = new Instance(featureVector, positive ? posLabel : negLabel,
   null, null);
 iList.add(instance);
}

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

/**
 * Compute the maxent classification of an instance.
 *
 * @param classifier the classifier
 * @param features the features that are on for this instance
 * @return the classification
 */
static public Classification classify(Classifier classifier,
                   String[] features) {
  return classifier.classify(
      new Instance(new TokenSequence(features), null, null, null));
}

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

/** Pipe the object through this classifier's pipe, then classify the resulting instance. */
public Classification classify (Object obj)
{
  if (obj instanceof Instance)
    return classify ((Instance)obj);
  return classify (instancePipe.instanceFrom(new Instance (obj, null, null, null)));
}

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

/**
 * Compute the maxent classification of an instance.
 *
 * @param classifier the classifier
 * @param features the features that are on for this instance
 * @return the classification
 */
static public Classification classify(Classifier classifier,
                   String[] features) {
  return classifier.classify(
      new Instance(new TokenSequence(features), null, null, null));
}

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

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.mallet/mallet

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.mallet/mallet

/**
     Calculates the confidence in the tagging of a {@link Segment}.
   */
  public double estimateConfidenceFor (Segment segment, SumLatticeDefault cachedLattice) {		
    Classification c = this.meClassifier.classify (pipe.instanceFrom(new Instance (
                                                     segment, segment.getTruth(), null, null)));
    return c.getLabelVector().value (this.correct);
  }
}

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

public void testPipesAreStupid ()
{
 Pipe p1 = new StupidPipe ();
 Pipe p2 = new SimpleTaggerSentence2TokenSequence ();
 // initialize p2's dict
 p2.instanceFrom(new Instance (data, null, null, null));
 Pipe serial = new SerialPipes (new Pipe[] { p1, p2 });
 try {
  serial.getDataAlphabet ();
  assertTrue ("Test failed: Should have generated exception.", false);
 } catch (IllegalStateException e) {}
}

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

public void testConcatenateNullPipes ()
{
 Pipe p1 = new StupidPipe ();
 Pipe p2 = new SimpleTagger.SimpleTaggerSentence2FeatureVectorSequence ();
 Pipe serial = PipeUtils.concatenatePipes (p1, p2);
 p2.instanceFrom(new Instance (data, null, null, null));
 assertEquals (3, serial.getDataAlphabet ().size ());
}

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

public void testConcatenatePipes ()
{
 Pipe p1 = new StupidPipe ();
 Pipe p2 = new SimpleTagger.SimpleTaggerSentence2FeatureVectorSequence ();
 // initialize p2's dict
 p2.instanceFrom(new Instance (data, null, null, null));
 assertEquals (3, p2.getDataAlphabet ().size());
 Pipe serial = PipeUtils.concatenatePipes (p1, p2);
 Alphabet dict = serial.getDataAlphabet ();
 assertEquals (3, dict.size ());
 assertTrue (dict == p2.getDataAlphabet ());
}

相关文章