本文整理汇总了Java中com.google.common.io.Files.asCharSource方法的典型用法代码示例。如果您正苦于以下问题:Java Files.asCharSource方法的具体用法?Java Files.asCharSource怎么用?Java Files.asCharSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.io.Files
的用法示例。
在下文中一共展示了Files.asCharSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uncachedRead
import com.google.common.io.Files; //导入方法依赖的package包/类
private synchronized AnswerKey uncachedRead(final Symbol docid) throws IOException {
final ImmutableList.Builder<AssessedResponse> annotated = ImmutableList.builder();
final ImmutableList.Builder<Response> unannotated = ImmutableList.builder();
final CorefAnnotation.Builder corefBuilder = assessmentCreator.corefBuilder(docid);
final File f = bareOrWithSuffix(directory, docid.asString(), ACCEPTABLE_SUFFIXES);
final CharSource source = Files.asCharSource(f, UTF_8);
for (final String line : source.readLines()) {
try {
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
final String[] parts = line.split("\t");
final List<String> argumentParts = Arrays.asList(parts).subList(1, 11);
final List<String> annotationParts = Arrays.asList(parts).subList(11, parts.length);
if (annotationParts.isEmpty()) {
throw new IOException(String.format(
"The assessment store file for document ID %s appears to be a system " +
"output file with no assessment columns.", docid));
}
final Response response = parseArgumentFields(argumentParts);
final AssessmentCreator.AssessmentParseResult annotation =
parseAnnotation(annotationParts);
if (annotation.assessment().isPresent()) {
annotated.add(AssessedResponse.of(response, annotation.assessment().get()));
} else {
unannotated.add(response);
}
if (annotation.corefId().isPresent()) {
corefBuilder.corefCAS(response.canonicalArgument(), annotation.corefId().get());
} else {
corefBuilder.addUnannotatedCAS(response.canonicalArgument());
}
} catch (Exception e) {
throw new IOException(String.format(
"While reading answer key for document %s, error on line %s", docid, line), e);
}
}
return assessmentCreator.createAnswerKey(docid, annotated.build(), unannotated.build(),
corefBuilder.build());
}