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


Java FileUtils类代码示例

本文整理汇总了Java中cc.mallet.util.FileUtils的典型用法代码示例。如果您正苦于以下问题:Java FileUtils类的具体用法?Java FileUtils怎么用?Java FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: train

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public boolean train (ACRF acrf, InstanceList trainingList, InstanceList validationList, InstanceList testSet,
                      ACRFEvaluator eval, int numIter, Optimizable.ByGradientValue macrf)
{
  if (wrongWrongType == NO_WRONG_WRONG) {
    return super.train (acrf, trainingList, validationList, testSet, eval, numIter, macrf);
  } else {
    Maxable bipwMaxable = (Maxable) macrf;
    // add wrong wrongs after 5 iterations
    logger.info ("BiconditionalPiecewiseACRFTrainer: Initial training");
    super.train (acrf, trainingList, validationList, testSet, eval, wrongWrongIter, macrf);
    FileUtils.writeGzippedObject (new File (outputPrefix, "initial-acrf.ser.gz"), acrf);
    logger.info ("BiconditionalPiecewiseACRFTrainer: Adding wrong-wrongs");
    bipwMaxable.addWrongWrong (trainingList);
    logger.info ("BiconditionalPiecewiseACRFTrainer: Adding wrong-wrongs");
    boolean converged = super.train (acrf, trainingList, validationList, testSet, eval, numIter, macrf);
    reportTrainingLikelihood (acrf, trainingList);
    return converged;
  }
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:20,代码来源:PwplACRFTrainer.java

示例2: main

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public static void main (String[] args) throws FileNotFoundException
{
  File trainFile = new File (args[0]);
  File testFile = new File (args[1]);
  File crfFile = new File (args[2]);

  Pipe pipe = new SerialPipes (new Pipe[] {
      new GenericAcrfData2TokenSequence (2),
      new TokenSequence2FeatureVectorSequence (true, true),
  });

  InstanceList training = new InstanceList (pipe);
  training.addThruPipe (new LineGroupIterator (new FileReader (trainFile),
                                       Pattern.compile ("\\s*"),
                                       true));

  InstanceList testing = new InstanceList (pipe);
  testing.addThruPipe (new LineGroupIterator (new FileReader (testFile),
                                       Pattern.compile ("\\s*"),
                                       true));

  ACRF.Template[] tmpls = new ACRF.Template[] {
          new ACRF.BigramTemplate (0),
          new ACRF.BigramTemplate (1),
          new ACRF.PairwiseFactorTemplate (0,1),
          new CrossTemplate1 (0,1)
  };

  ACRF acrf = new ACRF (pipe, tmpls);

  ACRFTrainer trainer = new DefaultAcrfTrainer ();
  trainer.train (acrf, training, null, testing, 99999);

  FileUtils.writeGzippedObject (crfFile, acrf);
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:36,代码来源:SimpleCrfExample.java

示例3: makeOutputFile

import cc.mallet.util.FileUtils; //导入依赖的package包/类
protected File makeOutputFile ()
{
	try {
		String name = GeneralUtils.classShortName (this);
		return FileUtils.uniqueFile (outputPrefix, name, ".log");
	} catch (java.io.IOException e) {
		throw new RuntimeException (e);
	}
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:ACRFEvaluator.java

示例4: evaluate

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public boolean evaluate (ACRF acrf, int iter, InstanceList training, InstanceList validation, InstanceList testing)
{
  if (iter > 0 && iter % interval == 0) {
    ACRFExtractor extor = new ACRFExtractor (acrf, tokPipe, featurePipe);
    FileUtils.writeGzippedObject (new File (directory, "extor."+iter+".ser.gz"), extor);
  }
  return true;
}
 
开发者ID:mimno,项目名称:GRMM,代码行数:9,代码来源:ACRFExtractorTrainer.java

示例5: main

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public static void main (String[] args) throws FileNotFoundException
{
  File trainFile = new File (args[0]);
  File testFile = new File (args[1]);
  File crfFile = new File (args[2]);

  Pipe pipe = new SerialPipes (new Pipe[] {
      new GenericAcrfData2TokenSequence (2),
      new TokenSequence2FeatureVectorSequence (true, true),
  });

  InstanceList training = new InstanceList (pipe);
  training.addThruPipe (new LineGroupIterator (new FileReader (trainFile),
                                       Pattern.compile ("\\s*"),
                                       true));

  InstanceList testing = new InstanceList (pipe);
  training.addThruPipe (new LineGroupIterator (new FileReader (testFile),
                                       Pattern.compile ("\\s*"),
                                       true));

  ACRF.Template[] tmpls = new ACRF.Template[] {
          new ACRF.BigramTemplate (0),
          new ACRF.BigramTemplate (1),
          new ACRF.PairwiseFactorTemplate (0,1),
          new CrossTemplate1 (0,1)
  };

  ACRF acrf = new ACRF (pipe, tmpls);

  ACRFTrainer trainer = new DefaultAcrfTrainer ();
  trainer.train (acrf, training, null, testing, 99999);

  FileUtils.writeGzippedObject (crfFile, acrf);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:36,代码来源:SimpleCrfExample.java

示例6: skiptestOldCrf

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public void skiptestOldCrf() {
	CRF crf = (CRF) FileUtils.readObject(new File(oldCrfFile));
	Instance inst = crf.getInputPipe().instanceFrom(
			new Instance(testString, null, null, null));
	Sequence output = crf.transduce((Sequence) inst.getData());
	String std = output.toString();
	assertEquals(" B-PER I-PER O O", std);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:9,代码来源:TestCRF.java

示例7: testPlusEqualsFromSaved

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public void testPlusEqualsFromSaved () throws IOException, ClassNotFoundException
{
  HashedSparseVector s1 = (HashedSparseVector) FileUtils.readObject (oldSv);
  HashedSparseVector s2 = new HashedSparseVector (new int[] { 1 }, new double[] { 1.0 });

  s1.plusEqualsSparse (s2, 1.0);
  assertEquals (1.0, s1.value (0), 1e-5);
  assertEquals (0.0, s1.value (1), 1e-5);
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:10,代码来源:TestHashedSparseVector.java

示例8: ignoretestPlusEqualsFromSaved

import cc.mallet.util.FileUtils; //导入依赖的package包/类
public void ignoretestPlusEqualsFromSaved () throws IOException, ClassNotFoundException
{
  HashedSparseVector s1 = (HashedSparseVector) FileUtils.readObject (oldSv);
  HashedSparseVector s2 = new HashedSparseVector (new int[] { 1 }, new double[] { 1.0 });

  s1.plusEqualsSparse (s2, 1.0);
  assertEquals (1.0, s1.value (0), 1e-5);
  assertEquals (0.0, s1.value (1), 1e-5);
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:10,代码来源:TestHashedSparseVector.java


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