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

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

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

InstanceList.<init>介绍

[英]Creates a list consisting of randomly-generated FeatureVectors.
[中]创建由随机生成的FeatureVectors组成的列表。

代码示例

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

BinaryTestData(int numFeatures) {
 LabelAlphabet labelAlphabet = new LabelAlphabet();
 posLabel = labelAlphabet.lookupLabel("pos", true);
 negLabel = labelAlphabet.lookupLabel("neg", true);
 List<String> featureNames = new ArrayList<String>();
 for (int i = 0; i < numFeatures; i++) {
  featureNames.add(Integer.toString(i));
 }
 dataAlphabet = new Alphabet(featureNames.toArray());
 iList = new InstanceList(dataAlphabet, labelAlphabet);
}

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

public InstanceList pipeInstances (Iterator<Instance> source)
{
 // I think that pipes should be associated neither with InstanceLists, nor
 //  with Instances. -cas
 InstanceList toked = new InstanceList (tokenizationPipe);
 toked.addThruPipe (source);
 InstanceList piped = new InstanceList (getFeaturePipe ());
 piped.addThruPipe (toked.iterator());
 return piped;
}

代码示例来源:origin: cc.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/julielab-topic-modeling

public InstanceList malletPreprocess(List<TokenSequence> data) {
  ArrayList<Pipe> pipeList = new ArrayList<>();
  pipeList.add(new TokenSequenceRemoveStopwords(false, false));
  pipeList.add(new TokenSequence2FeatureSequence());
  InstanceList instances = new InstanceList(new SerialPipes(pipeList));
  ArrayIterator dataListIterator = new ArrayIterator(data);
  instances.addThruPipe(dataListIterator);
  return instances;
}

代码示例来源: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: cc.mallet/mallet

public static InstanceList getInstances(String dbName) throws Exception {
  DBInstanceIterator dbIterator = new DBInstanceIterator(dbName);
  InstanceList instances = new InstanceList(dbIterator.getPipe());
  instances.addThruPipe(dbIterator);
  dbIterator.cleanup();
  return instances;
}

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

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 void testSetGetParameters ()
{
   MaxEntTrainer trainer = new MaxEntTrainer();
  Alphabet fd = dictOfSize (6);
  String[] classNames = new String[] {"class0", "class1", "class2"};
  InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20);
  Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist);
  TestOptimizable.testGetSetParameters (maxable);
}

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

/**
   Iterates over {@link Segment}s for only one {@link Instance}.
 */
public SegmentIterator (Transducer model, Instance instance, Object[] segmentStartTags,
                        Object[] segmentContinueTags) {
  InstanceList ilist = new InstanceList (new Noop (instance.getDataAlphabet(), instance.getTargetAlphabet()));
  ilist.add (instance);
  setSubIterator (model, ilist, segmentStartTags, segmentContinueTags);
}

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

/**
 *
 * @param i
 * @param j
 * @return A new {@link InstanceList} containing the two argument {@link Instance}s.
 */
public static InstanceList makeList (Instance i, Instance j) {
  InstanceList list = new InstanceList(new Noop(i.getDataAlphabet(), i.getTargetAlphabet()));
  list.add(i);
  list.add(j);
  return list;
}

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

public void testRandomTrained ()
{
 Pipe p = new SerialPipes (new Pipe[]	{
     new TokenSequence2FeatureSequence (),
     new FeatureSequence2FeatureVector (),
     new Target2Label()});
 double testAcc1 = testRandomTrainedOn (new InstanceList (p));
 double testAcc2 = testRandomTrainedOn (new PagedInstanceList (p, 700, 200, new File(".")));
 assertEquals (testAcc1, testAcc2, 0.01);
}

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

/**
 *
 * @param i
 * @param j
 * @return A new {@link InstanceList} containing the two argument {@link Instance}s.
 */
public static InstanceList makeList (Instance i, Instance j) {
  InstanceList list = new InstanceList(new Noop(i.getDataAlphabet(), i.getTargetAlphabet()));
  list.add(i);
  list.add(j);
  return list;
}

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

public void testOneFromSerialized () throws IOException, ClassNotFoundException
{
 Pipe p = createPipe ();
 Pipe clone = (Pipe) TestSerializable.cloneViaSerialization (p);
 InstanceList ilist = new InstanceList (clone);
 ilist.addThruPipe(new StringArrayIterator(data));
   assertTrue (ilist.size() == 3);
}

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

public void testRandomMaximizable ()
{
  MaxEntTrainer trainer = new MaxEntTrainer();
  Alphabet fd = dictOfSize (6);
  String[] classNames = new String[] {"class0", "class1"};
  InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20);
  Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist);
  TestOptimizable.testValueAndGradient (maxable);
}

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

/**
 *
 * @param i
 * @param j
 * @return A new {@link InstanceList} containing the two argument {@link Instance}s.
 */
public static InstanceList makeList (Instance i, Instance j) {
  InstanceList list = new InstanceList(new Noop(i.getDataAlphabet(), i.getTargetAlphabet()));
  list.add(i);
  list.add(j);
  return list;
}

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

/**
   Iterates over {@link Segment}s for only one {@link Instance}.
 */
public SegmentIterator (Transducer model, Instance instance, Object[] segmentStartTags,
                        Object[] segmentContinueTags) {
  InstanceList ilist = new InstanceList (new Noop (instance.getDataAlphabet(), instance.getTargetAlphabet()));
  ilist.add (instance);
  setSubIterator (model, ilist, segmentStartTags, segmentContinueTags);
}

代码示例来源: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: cc.mallet/mallet

public void testTrainedMaximizable ()
{
  MaxEntTrainer trainer = new MaxEntTrainer();
  Alphabet fd = dictOfSize (6);
  String[] classNames = new String[] {"class0", "class1"};
  InstanceList ilist = new InstanceList (new Randoms(1), fd, classNames, 20);
  MaxEnt me = (MaxEnt)trainer.train(ilist);
  Optimizable.ByGradientValue maxable = trainer.getOptimizable (ilist, me);
  TestOptimizable.testValueAndGradientCurrentParameters (maxable);
}

代码示例来源:origin: com.github.steveash.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());
  }
}

相关文章

微信公众号

最新文章

更多