本文整理汇总了Java中edu.uw.easysrl.util.Util.findAllFiles方法的典型用法代码示例。如果您正苦于以下问题:Java Util.findAllFiles方法的具体用法?Java Util.findAllFiles怎么用?Java Util.findAllFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.uw.easysrl.util.Util
的用法示例。
在下文中一共展示了Util.findAllFiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readCorpus
import edu.uw.easysrl.util.Util; //导入方法依赖的package包/类
Table<String, Integer, TreebankParse> readCorpus(final File folder)
throws IOException {
final Table<String, Integer, TreebankParse> result = HashBasedTable
.create();
for (final File file : Util.findAllFiles(folder, ".*.(mrg|MRG)")) {
final String name = file.getName().substring(0,
file.getName().length() - 4).toLowerCase();
// System.out.println(name);
final Iterator<String> lines = Util.readFileLineByLine(file);
int sentenceNumber = 0;
while (lines.hasNext()) {
result.put(name, sentenceNumber, readParse(lines));
sentenceNumber++;
}
}
return result;
}
示例2: readCorpus
import edu.uw.easysrl.util.Util; //导入方法依赖的package包/类
Table<String, Integer, SyntacticDependencyParse> readCorpus(File folder)
throws IOException {
Table<String, Integer, SyntacticDependencyParse> result = HashBasedTable
.create();
for (File file : Util.findAllFiles(folder, ".*.deps")) {
String name = file.getName().substring(0,
file.getName().indexOf("."));
// System.out.println(name);
Iterator<String> lines = Util.readFileLineByLine(file);
int sentenceNumber = 0;
while (lines.hasNext()) {
result.put(name, sentenceNumber, readParse(lines));
sentenceNumber++;
}
}
return result;
}
示例3: loadCorpus
import edu.uw.easysrl.util.Util; //导入方法依赖的package包/类
public static List<DependencyParse> loadCorpus(final File folder, final Partition partition) throws IOException {
final String regex = partition == Partition.DEV ? CCGBankParseReader.devRegex
: partition == Partition.TRAIN ? CCGBankParseReader.trainRegex : CCGBankParseReader.testRegex;
final List<File> autoFiles = Util.findAllFiles(folder, regex + ".*.auto");
Collections.sort(autoFiles);
final List<File> pargFiles = Util.findAllFiles(folder, regex + ".*.parg");
Collections.sort(pargFiles);
if (pargFiles.size() == 0) {
return null;
}
final List<DependencyParse> result = new ArrayList<>();
// Preconditions.checkArgument(pargFiles.size() == autoFiles.size());
for (int i = 0; i < autoFiles.size(); i++) {
final File autoFile = autoFiles.get(i);
final File pargFile = pargFiles.get(i);
Preconditions.checkState(
Files.getNameWithoutExtension(autoFile.getName()).equals(
Files.getNameWithoutExtension(pargFile.getName())),
autoFile.getName() + " vs. " + pargFile.getName());
result.addAll(getDependencyParses(autoFile, pargFile));
}
return result;
}
示例4: loadCorpus
import edu.uw.easysrl.util.Util; //导入方法依赖的package包/类
public static Iterator<SyntaxTreeNode> loadCorpus(final File folder, final String regex) throws IOException {
final List<File> autoFilesList = Util.findAllFiles(folder, regex);
Collections.sort(autoFilesList);
return new Iterator<SyntaxTreeNode>() {
Iterator<File> autoFiles = ImmutableList.copyOf(autoFilesList).iterator();
Iterator<String> autoLines = Util.readFileLineByLine(autoFiles.next());
@Override
public boolean hasNext() {
return autoLines.hasNext() || autoFiles.hasNext();
}
@Override
public SyntaxTreeNode next() {
// Breaks if the last parse is a failure...
if (autoLines.hasNext()) {
String line = autoLines.next();
while (autoLines.hasNext() && line.startsWith("ID=")) {
line = autoLines.next();
}
if (!line.startsWith("ID=")) {
final SyntaxTreeNode result = parse(line);
return result;
} else {
return next();
}
} else {
final File autoFile = autoFiles.next();
try {
autoLines = Util.readFileLineByLine(autoFile);
} catch (final IOException e) {
throw new RuntimeException(e);
}
return next();
}
}
};
}