use of edu.stanford.nlp.objectbank.ResettableReaderIteratorFactory in project CoreNLP by stanfordnlp.
the class AbstractSequenceClassifier method makeObjectBankFromFiles.
public ObjectBank<List<IN>> makeObjectBankFromFiles(String baseDir, String filePattern, DocumentReaderAndWriter<IN> readerAndWriter) {
File path = new File(baseDir);
FileFilter filter = new RegExFileFilter(Pattern.compile(filePattern));
File[] origFiles = path.listFiles(filter);
Collection<File> files = new ArrayList<>();
for (File file : origFiles) {
if (file.isFile()) {
if (flags.announceObjectBankEntries) {
log.info("Getting data from " + file + " (" + flags.inputEncoding + " encoding)");
}
files.add(file);
}
}
if (files.isEmpty()) {
throw new RuntimeException("No matching files: " + baseDir + '\t' + filePattern);
}
// TODO get rid of ObjectBankWrapper
return new ObjectBankWrapper<>(flags, new ObjectBank<>(new ResettableReaderIteratorFactory(files, flags.inputEncoding), readerAndWriter), knownLCWords);
}
Aggregations