當前位置: 首頁>>代碼示例>>Java>>正文


Java ReaderIteratorFactory類代碼示例

本文整理匯總了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);
}
 
開發者ID:benblamey,項目名稱:stanford-nlp,代碼行數:43,代碼來源:MaxentTagger.java


注:本文中的edu.stanford.nlp.objectbank.ReaderIteratorFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。