本文整理匯總了Java中edu.stanford.nlp.objectbank.ReaderIteratorFactory類的典型用法代碼示例。如果您正苦於以下問題:Java ReaderIteratorFactory類的具體用法?Java ReaderIteratorFactory怎麽用?Java ReaderIteratorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ReaderIteratorFactory類屬於edu.stanford.nlp.objectbank包,在下文中一共展示了ReaderIteratorFactory類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runTaggerSGML
import edu.stanford.nlp.objectbank.ReaderIteratorFactory; //導入依賴的package包/類
public void runTaggerSGML(BufferedReader reader, BufferedWriter writer, OutputStyle outputStyle)
throws IOException
{
Timing t = new Timing();
//Counts
int numWords = 0;
int numSentences = 0;
if (outputStyle == OutputStyle.XML ||
outputStyle == OutputStyle.INLINE_XML) {
writer.write("<?xml version=\"1.0\" encoding=\"" +
config.getEncoding() + "\"?>\n");
writer.write("<pos>\n");
}
// this uses NER codebase technology to read/write SGML-ish files
PlainTextDocumentReaderAndWriter<CoreLabel> readerAndWriter = new PlainTextDocumentReaderAndWriter<CoreLabel>();
ObjectBank<List<CoreLabel>> ob = new ObjectBank<List<CoreLabel>>(new ReaderIteratorFactory(reader), readerAndWriter);
PrintWriter pw = new PrintWriter(writer);
for (List<CoreLabel> sentence : ob) {
ArrayList<CoreLabel> s = new ArrayList<CoreLabel>(sentence);
numWords += s.size();
ArrayList<TaggedWord> taggedSentence = tagSentence(s, false);
Iterator<CoreLabel> origIter = sentence.iterator();
for (TaggedWord tw : taggedSentence) {
CoreLabel cl = origIter.next();
cl.set(CoreAnnotations.AnswerAnnotation.class, tw.tag());
}
readerAndWriter.printAnswers(sentence, pw, outputStyle, true);
++numSentences;
}
if (outputStyle == OutputStyle.XML ||
outputStyle == OutputStyle.INLINE_XML) {
writer.write("</pos>\n");
}
writer.flush();
long millis = t.stop();
printErrWordsPerSec(millis, numWords);
}