本文整理汇总了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();
}
示例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();
}
示例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();
}
示例4: saveFile
import edu.stanford.nlp.util.StringUtils; //导入方法依赖的package包/类
public static void saveFile(File file, String contents) {
StringUtils.printToFile(file, contents);
}