本文整理匯總了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();
}
}
};
}