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


Java Pipe.instanceFrom方法代码示例

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


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

示例1: testConcatenatePipes

import cc.mallet.pipe.Pipe; //导入方法依赖的package包/类
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 ());
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:16,代码来源:TestPipeUtils.java

示例2: testPrinting

import cc.mallet.pipe.Pipe; //导入方法依赖的package包/类
public static void testPrinting ()
{
  Alphabet dict = dictOfSize (3);
  FeatureVector[] vecs = new FeatureVector[] {
    new FeatureVector (dict, new int[] { 0, 1 }),
    new FeatureVector (dict, new int[] { 0, 2 }),
    new FeatureVector (dict, new int[] { 2 }),
    new FeatureVector (dict, new int[] { 1, 2 }),
  };

  LabelAlphabet ld = labelDictOfSize (3);
  LabelSequence lbls = new LabelSequence (ld, new int [] { 0, 2, 0, 1});

  FeatureVectorSequence fvs = new FeatureVectorSequence (vecs);
  StringWriter sw = new StringWriter ();
  PrintWriter w = new PrintWriter (sw);
  Pipe p = new SequencePrintingPipe (w);

  // pipe the instance
  p.instanceFrom(new Instance (fvs, lbls, null, null));

  // Do a second one
  FeatureVectorSequence fvs2 = new FeatureVectorSequence (new FeatureVector[] {
    new FeatureVector (dict, new int[] { 1 }),
    new FeatureVector (dict, new int[] { 0 }),
  });
  LabelSequence lbls2 = new LabelSequence (ld, new int[] { 2, 1 });
  p.instanceFrom(new Instance (fvs2, lbls2, null, null));

  w.close();

  assertEquals ("LABEL0 feature0 feature1\n" +
          "LABEL2 feature0 feature2\n" +
          "LABEL0 feature2\n" +
          "LABEL1 feature1 feature2\n" +
          "\n" +
          "LABEL2 feature1\n" +
          "LABEL1 feature0\n\n",
          sw.toString());
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:41,代码来源:TestSequencePrintingPipe.java

示例3: testPipesAreStupid

import cc.mallet.pipe.Pipe; //导入方法依赖的package包/类
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) {}
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:14,代码来源:TestPipeUtils.java

示例4: testConcatenateNullPipes

import cc.mallet.pipe.Pipe; //导入方法依赖的package包/类
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 ());
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:11,代码来源:TestPipeUtils.java


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