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


Java TransducerEvaluator.evaluate方法代码示例

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


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

示例1: run

import cc.mallet.fst.TransducerEvaluator; //导入方法依赖的package包/类
public static List<String> run(String trainingFilename, String testingFilename)
        throws FileNotFoundException, IOException {
  ArrayList<Pipe> pipes = new ArrayList<Pipe>();

  pipes.add(new SimpleTaggerSentence2TokenSequence());
  pipes.add(new TokenSequence2FeatureSequence());

  Pipe pipe = new SerialPipes(pipes);

  InstanceList trainingInstances = new InstanceList(pipe);
  InstanceList testingInstances = new InstanceList(pipe);

  trainingInstances.addThruPipe(new LineGroupIterator(
          new BufferedReader(new InputStreamReader(new FileInputStream(trainingFilename))),
          Pattern.compile("^\\s*$"), true));
  testingInstances.addThruPipe(new LineGroupIterator(
          new BufferedReader(new InputStreamReader(new FileInputStream(testingFilename))),
          Pattern.compile("^\\s*$"), true));

  HMM hmm = new HMM(pipe, null);
  hmm.addStatesForLabelsConnectedAsIn(trainingInstances);

  HMMTrainerByLikelihood trainer = new HMMTrainerByLikelihood(hmm);
  TransducerEvaluator testingEvaluator = new SegmentationEvaluator(testingInstances, "testing");
  trainer.train(trainingInstances, 100);
  testingEvaluator.evaluate(trainer);

  return testingInstances.stream().map(Instance::getData).map(Sequence.class::cast)
          .map(hmm::transduce)
          .flatMap(output -> IntStream.range(0, output.size()).mapToObj(output::get))
          .map(String.class::cast).collect(toList());

  // hmm.print();
}
 
开发者ID:ziy,项目名称:pkb,代码行数:35,代码来源:HmmTagger.java

示例2: evaluate

import cc.mallet.fst.TransducerEvaluator; //导入方法依赖的package包/类
public void evaluate(File file) throws FileNotFoundException {
	// if (normalize) {
	// normalizeSCLBlock(new InstanceList[] { instances }, limits);
	// }
	InstanceList instances = new InstanceList(pipe);
	instances.addThruPipe(iteratorForFile(file));
	TransducerEvaluator evaluator = new PerClassAccuracyEvaluator(
			instances, "evaluation");
	evaluator.evaluate(trainer);
}
 
开发者ID:siqil,项目名称:udaner,代码行数:11,代码来源:NER.java

示例3: testDualSpaceViewer

import cc.mallet.fst.TransducerEvaluator; //导入方法依赖的package包/类
public void testDualSpaceViewer () throws IOException
{
  Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
  String[] data0 = { TestCRF.data[0] };
  String[] data1 = TestCRF.data;

  InstanceList training = new InstanceList (pipe);
  training.addThruPipe (new ArrayIterator (data0));
  InstanceList testing = new InstanceList (pipe);
  testing.addThruPipe (new ArrayIterator (data1));

  CRF crf = new CRF (pipe, null);
  crf.addFullyConnectedStatesForLabels ();
  CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
  TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator (new InstanceList[] {training, testing}, new String[] {"Training", "Testing"});
  for (int i = 0; i < 5; i++) {
  	crft.train (training, 1);
  	eval.evaluate(crft);
  }

  CRFExtractor extor = hackCrfExtor (crf);
  Extraction e1 = extor.extract (new ArrayIterator (data1));

  Pipe pipe2 = TestMEMM.makeSpacePredictionPipe ();
  InstanceList training2 = new InstanceList (pipe2);
  training2.addThruPipe (new ArrayIterator (data0));
  InstanceList testing2 = new InstanceList (pipe2);
  testing2.addThruPipe (new ArrayIterator (data1));

  MEMM memm = new MEMM (pipe2, null);
  memm.addFullyConnectedStatesForLabels ();
  MEMMTrainer memmt = new MEMMTrainer (memm);
  TransducerEvaluator memmeval = new TokenAccuracyEvaluator (new InstanceList[] {training2, testing2}, new String[] {"Training2", "Testing2"});
  memmt.train (training2, 5);
  memmeval.evaluate(memmt);

  CRFExtractor extor2 = hackCrfExtor (memm);
  Extraction e2 = extor2.extract (new ArrayIterator (data1));

  if (!htmlDir.exists ()) htmlDir.mkdir ();
  LatticeViewer.viewDualResults (htmlDir, e1, extor, e2, extor2);

}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:44,代码来源:TestLatticeViewer.java

示例4: ignoretestDualSpaceViewer

import cc.mallet.fst.TransducerEvaluator; //导入方法依赖的package包/类
public void ignoretestDualSpaceViewer () throws IOException
{
  Pipe pipe = TestMEMM.makeSpacePredictionPipe ();
  String[] data0 = { TestCRF.data[0] };
  String[] data1 = TestCRF.data;

  InstanceList training = new InstanceList (pipe);
  training.addThruPipe (new ArrayIterator (data0));
  InstanceList testing = new InstanceList (pipe);
  testing.addThruPipe (new ArrayIterator (data1));

  CRF crf = new CRF (pipe, null);
  crf.addFullyConnectedStatesForLabels ();
  CRFTrainerByLabelLikelihood crft = new CRFTrainerByLabelLikelihood (crf);
  TokenAccuracyEvaluator eval = new TokenAccuracyEvaluator (new InstanceList[] {training, testing}, new String[] {"Training", "Testing"});
  for (int i = 0; i < 5; i++) {
  	crft.train (training, 1);
  	eval.evaluate(crft);
  }

  CRFExtractor extor = hackCrfExtor (crf);
  Extraction e1 = extor.extract (new ArrayIterator (data1));

  Pipe pipe2 = TestMEMM.makeSpacePredictionPipe ();
  InstanceList training2 = new InstanceList (pipe2);
  training2.addThruPipe (new ArrayIterator (data0));
  InstanceList testing2 = new InstanceList (pipe2);
  testing2.addThruPipe (new ArrayIterator (data1));

  MEMM memm = new MEMM (pipe2, null);
  memm.addFullyConnectedStatesForLabels ();
  MEMMTrainer memmt = new MEMMTrainer (memm);
  TransducerEvaluator memmeval = new TokenAccuracyEvaluator (new InstanceList[] {training2, testing2}, new String[] {"Training2", "Testing2"});
  memmt.train (training2, 5);
  memmeval.evaluate(memmt);

  CRFExtractor extor2 = hackCrfExtor (memm);
  Extraction e2 = extor2.extract (new ArrayIterator (data1));

  if (!htmlDir.exists ()) htmlDir.mkdir ();
  LatticeViewer.viewDualResults (htmlDir, e1, extor, e2, extor2);

}
 
开发者ID:cmoen,项目名称:mallet,代码行数:44,代码来源:TestLatticeViewer.java


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