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

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

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

InstanceList.get介绍

[英]Returns the Alphabet mapping features of the data to integers.
[中]返回数据到整数的Alphabet映射特征。

代码示例

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

/** Returns the <code>Instance</code> at the specified index. If
 * this Instance is not in memory, swap a block of instances back
 * into memory. */
public Instance get (int index) {
  InstanceList page = getPageForIndex (index, false);
  return page.get (index % this.instancesPerPage);
}

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

public InstanceList getInstances() 
{ 
  InstanceList ret = new InstanceList(m_ilist.getPipe());
  for (int ii = 0; ii < m_instIndices.length; ii++)
    ret.add(m_ilist.get(m_instIndices[ii]));
  return ret; 
}

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

/** Returns the <code>Instance</code> at the specified index. If
 * this Instance is not in memory, swap a block of instances back
 * into memory. */
public Instance get (int index) {
  InstanceList page = getPageForIndex (index, false);
  return page.get (index % this.instancesPerPage);
}

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

/** Return an list of instances with a particular label. */
public InstanceList getCluster(int label) {		
  InstanceList cluster = new InstanceList(instances.getPipe());		
  for (int n=0 ; n<instances.size() ; n++) 
  if (labels[n] == label)
      cluster.add(instances.get(n));			
  return cluster;
}

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

public double getInstanceWeight (int index) {
  if (index > this.size()) {
    throw new IllegalArgumentException("Index out of bounds: index="+index+" size="+this.size());
  }
  if (instWeights != null) {
    Double value = instWeights.get(get(index));
    if (value != null) {
      return value;
    }
  }
  return 1.0;
}

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

public List getBestLabels (InstanceList lst)
{
 List ret = new ArrayList (lst.size());
 for (int i = 0; i < lst.size(); i++) {
  ret.add (getBestLabels (lst.get (i)));
 }
 return ret;
}

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

public void sampleTopicsForDocs (int start, int length, Randoms r)
{
  assert (start+length <= docTopicCounts.length);
  double[] topicWeights = new double[numTopics];
  // Loop over every word in the corpus
  for (int di = start; di < start+length; di++) {
    sampleTopicsForOneDoc ((FeatureSequence)ilist.get(di).getData(),
                topics[di], docTopicCounts[di], topicWeights, r);
  }
}

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

public void sampleTopicsForAllDocs (Randoms r)
{
  double[] topicWeights = new double[numTopics];
  // Loop over every word in the corpus
  for (int di = 0; di < topics.length; di++) {
    sampleTopicsForOneDoc ((FeatureSequence)ilist.get(di).getData(),
                topics[di], docTopicCounts[di], topicWeights, r);
  }
}

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

public InstanceList sampleWithReplacement (java.util.Random r, int numSamples)
{
  InstanceList ret = this.cloneEmpty();
  for (int i = 0; i < numSamples; i++)
    ret.add (this.get(r.nextInt(this.size())));
  return ret;
}

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

public InstanceList subList (double proportion)
{
  if (proportion > 1.0)
    throw new IllegalArgumentException ("proportion must by <= 1.0");
  InstanceList other = (InstanceList) clone();
  other.shuffle(new java.util.Random());
  proportion *= other.size();
  for (int i = 0; i < proportion; i++)
    other.add (get(i));
  return other;
}

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

public Void call() throws Exception {
  for (int ii = start; ii < end; ii++) {
   if (instancesWithConstraints.get(ii)) {
    SumLattice lattice = lattices.get(ii);
    FeatureVectorSequence fvs = (FeatureVectorSequence)data.get(ii).getData();
    new GELattice(fvs, lattice.getGammas(), lattice.getXis(),
     crf, reverseTrans, reverseTransIndices, gradient,this.constraints, false);
   }
  }
  return null;
 }
}

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

public Double call() throws Exception {
  double value = 0;
for (int ii = start; ii < end; ii++) {
 Instance inst = trainingSet.get(ii);
    Sequence input = (Sequence) inst.getData();
    // logZ			
    value -= new SumLatticePR(crf, ii, input, null, modelCopy, cachedDots[ii], true, null, null, false).getTotalWeight();
  }
return value;
}

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

public void collectConstraints (InstanceList ilist)
{
 for (int inum = 0; inum < ilist.size(); inum++) {
  logger.finest ("*** Collecting constraints for instance "+inum);
  Instance inst = ilist.get (inum);
  ACRF.UnrolledGraph unrolled = new ACRF.UnrolledGraph (inst, templates, null, true);
  Assignment assn = unrolled.getAssignment ();
  collectConstraintsForGraph (unrolled, assn);
 }
}

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

public void dumpUnrolledGraphs (InstanceList lst)
{
 for (int i = 0; i < lst.size(); i++) {
  Instance inst = lst.get (i);
  System.out.println("INSTANCE "+i+" : "+inst.getName ());
  UnrolledGraph unrolled = unroll (inst);
  dumpOneGraph (unrolled);
 }
}

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

private void collectWeightsPresent (InstanceList ilist, BitSet[] weightsPresent)
{
 for (int inum = 0; inum < ilist.size(); inum++) {
  Instance inst = ilist.get (inum);
  UnrolledGraph unrolled = new UnrolledGraph (inst, new Template[] { this }, null, false);
  collectTransitionsPresentForGraph (unrolled);
  collectWeightsPresentForGraph (unrolled, weightsPresent);
 }
}

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

public Sequence pipeInput (Object input)
 {
  InstanceList all = new InstanceList (getFeaturePipe ());
  all.add (input, null, null, null);
  return (Sequence) all.get (0).getData();
 }
}

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

public Sequence pipeInput (Object input)
 {
  InstanceList all = new InstanceList (getFeaturePipe ());
  all.add (input, null, null, null);
  return (Sequence) all.get (0).getData();
 }
}

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

public void testFixedNumLabels () throws IOException, ClassNotFoundException
{
 Pipe p = new GenericAcrfData2TokenSequence (2);
 InstanceList training = new InstanceList (p);
 training.addThruPipe (new LineGroupIterator (new StringReader (sampleFixedData), Pattern.compile ("^$"), true));
 assertEquals (1, training.size ());
 Instance inst1 = training.get (0);
 LabelsSequence ls1 = (LabelsSequence) inst1.getTarget ();
 assertEquals (4, ls1.size ());
}

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

public static void main(String[] args) {
  String htmldir = args[0];
  Pipe pipe = new SerialPipes(new Pipe[] { new Input2CharSequence(),
      new CharSequenceRemoveHTML() });
  InstanceList list = new InstanceList(pipe);
  list.addThruPipe(new FileIterator(htmldir, FileIterator.STARTING_DIRECTORIES));
  for (int index = 0; index < list.size(); index++) {
    Instance inst = list.get(index);
    System.err.println(inst.getData());
  }
}

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

public static void main(String[] args) {
  String htmldir = args[0];
  Pipe pipe = new SerialPipes(new Pipe[] { new Input2CharSequence(),
      new CharSequenceRemoveHTML() });
  InstanceList list = new InstanceList(pipe);
  list.addThruPipe(new FileIterator(htmldir, FileIterator.STARTING_DIRECTORIES));
  for (int index = 0; index < list.size(); index++) {
    Instance inst = list.get(index);
    System.err.println(inst.getData());
  }
}

相关文章

微信公众号

最新文章

更多