本文整理汇总了Java中gate.corpora.DocumentStaxUtils类的典型用法代码示例。如果您正苦于以下问题:Java DocumentStaxUtils类的具体用法?Java DocumentStaxUtils怎么用?Java DocumentStaxUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentStaxUtils类属于gate.corpora包,在下文中一共展示了DocumentStaxUtils类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotateDocument
import gate.corpora.DocumentStaxUtils; //导入依赖的package包/类
/**
*
* @param documentToAnnotate the document to be annotated
* @param saveLocation the location the annotated document will be saved.
* @param transducer the transducer that will be used.
* @throws GateException
* @throws IOException
* @throws XMLStreamException
*/
public void annotateDocument(final File documentToAnnotate, String saveLocation, Transducer transducer)
throws GateException, IOException, XMLStreamException {
Document d = loadDocument(documentToAnnotate);
Corpus corpus = Factory.newCorpus("JAPE corpus");
transducer.setCorpus(corpus);
transducer.setDocument(d);
corpus.add(d);
transducer.execute();
String pathname = saveLocation + "/" + documentToAnnotate.getName() + ".xml";
DocumentStaxUtils.writeDocument(d, new File(pathname));
corpus.cleanup();
d.cleanup();
transducer.cleanup();
}
示例2: export
import gate.corpora.DocumentStaxUtils; //导入依赖的package包/类
@Override
public void export(Document doc, OutputStream out, FeatureMap options)
throws IOException {
try {
DocumentStaxUtils.writeDocument(doc, out, "");
} catch(XMLStreamException e) {
throw new IOException(e);
}
}
示例3: writeTo
import gate.corpora.DocumentStaxUtils; //导入依赖的package包/类
@Override
public void writeTo(OutputStream out) throws IOException {
XMLStreamWriter xsw = new StAXDocumentSerializer(out);
try {
try {
xsw.writeStartDocument();
DocumentStaxUtils.writeDocument(document, xsw, "");
} finally {
xsw.close();
}
} catch(XMLStreamException xse) {
throw new IOException(xse);
}
}
示例4: annotateDocumentWithCorpusController
import gate.corpora.DocumentStaxUtils; //导入依赖的package包/类
public void annotateDocumentWithCorpusController(final File documentToAnnotate, String saveLocation, CorpusController controller)
throws GateException, IOException, XMLStreamException {
Document d = loadDocument(documentToAnnotate);
Corpus corpus = annotateDocument(controller, d);
String pathname = saveLocation + "/" + documentToAnnotate.getName() + ".xml";
DocumentStaxUtils.writeDocument(d, new File(pathname));
corpus.cleanup();
d.cleanup();
controller.cleanup();
}