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


Java StringUtils.printToFile方法代码示例

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


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

示例1: getDescription

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public String getDescription(int numDigits) {
  NumberFormat nf = NumberFormat.getNumberInstance();
  nf.setMaximumFractionDigits(numDigits);

  StringBuilder sb = new StringBuilder();
  sb.append("--- Accuracy Stats ---").append('\n');
  sb.append("accuracy: ").append(nf.format(accuracy)).append('\n');
  sb.append("optimal fn accuracy: ").append(nf.format(optAccuracy)).append('\n');
  sb.append("confidence weighted accuracy :").append(nf.format(confWeightedAccuracy)).append('\n');
  sb.append("optimal confidence weighted accuracy: ").append(nf.format(optConfWeightedAccuracy)).append('\n');
  sb.append("log-likelihood: ").append(logLikelihood).append('\n');
  if (saveFile != null) {
    String f = saveFile + '-' + saveIndex;
    sb.append("saving accuracy info to ").append(f).append(".accuracy\n");
    StringUtils.printToFile(f + ".accuracy", toStringArr(accrecall));
    sb.append("saving optimal accuracy info to ").append(f).append(".optimal_accuracy\n");
    StringUtils.printToFile(f + ".optimal_accuracy", toStringArr(optaccrecall));
    saveIndex++;
    //sb.append("accuracy coverage: ").append(toStringArr(accrecall)).append("\n");
    //sb.append("optimal accuracy coverage: ").append(toStringArr(optaccrecall));
  }
  return sb.toString();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:24,代码来源:AccuracyStats.java

示例2: getDescription

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public String getDescription(int numDigits) {
  NumberFormat nf = NumberFormat.getNumberInstance();
  nf.setMaximumFractionDigits(numDigits);

  StringBuilder sb = new StringBuilder();
  double confWeightedAccuracy = confidenceWeightedAccuracy();
  sb.append("--- Accuracy Stats ---").append("\n");
  sb.append("accuracy: ").append(nf.format(accuracy)).append(" (").append(correct).append("/").append(total).append(")\n");
  sb.append("confidence weighted accuracy :").append(nf.format(confWeightedAccuracy)).append("\n");
  sb.append("log-likelihood: ").append(logLikelihood).append("\n");
  if (saveFile != null) {
    String f = saveFile + "-" + saveIndex;
    sb.append("saving accuracy info to ").append(f).append(".accuracy\n");
    StringUtils.printToFile(f + ".accuracy", AccuracyStats.toStringArr(getAccCoverage()));
    saveIndex++;
    //sb.append("accuracy coverage: ").append(toStringArr(accrecall)).append("\n");
    //sb.append("optimal accuracy coverage: ").append(toStringArr(optaccrecall));
  }
  return sb.toString();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:21,代码来源:MultiClassAccuracyStats.java

示例3: iterator

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
/**
 * Returns an Iterator over the input sources in the underlying Collection.
 *
 * @return an Iterator over the input sources in the underlying Collection.
 */
@Override
public Iterator<Reader> iterator() {
  Collection<Object> newCollection = new ArrayList<Object>();
  for (Object o : c) {
    if (o instanceof Reader) {
      String name = o.toString()+".tmp";
      File tmpFile;
      try {
        tmpFile = File.createTempFile(name,"");
      } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
      }
      tmpFile.deleteOnExit();
      StringUtils.printToFile(tmpFile, IOUtils.slurpReader((Reader)o),
                              false, false, enc);
      newCollection.add(tmpFile);
    } else {
      newCollection.add(o);
    }
  }
  c = newCollection;
  return new ReaderIterator();
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:29,代码来源:ResettableReaderIteratorFactory.java

示例4: saveFile

import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void saveFile(File file, String contents) {
  StringUtils.printToFile(file, contents);
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:4,代码来源:NERGUI.java


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