本文整理汇总了Java中org.apache.uima.fit.util.JCasUtil.toText方法的典型用法代码示例。如果您正苦于以下问题:Java JCasUtil.toText方法的具体用法?Java JCasUtil.toText怎么用?Java JCasUtil.toText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.util.JCasUtil
的用法示例。
在下文中一共展示了JCasUtil.toText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testReader1
import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Test
public void testReader1() throws UIMAException, IOException {
description = CollectionReaderFactory.createReaderDescription(GutenbergDEReader.class,
GutenbergDEReader.PARAM_INPUT, "src/test/resources/test1");
JCasIterator iter = SimplePipeline.iteratePipeline(description, AnalysisEngineFactory
.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION, "target/doc")).iterator();
JCas jcas;
Scene scene;
jcas = iter.next();
// sanity check
// 1.xml
assertEquals("1", JCasUtil.selectSingle(jcas, Drama.class).getDocumentId());
assertTrue(JCasUtil.exists(jcas, Drama.class));
assertTrue(JCasUtil.exists(jcas, Act.class));
assertTrue(JCasUtil.exists(jcas, Scene.class));
assertTrue(JCasUtil.exists(jcas, Speaker.class));
assertTrue(JCasUtil.exists(jcas, DramatisPersonae.class));
assertTrue(JCasUtil.exists(jcas, FrontMatter.class));
assertTrue(JCasUtil.exists(jcas, MainMatter.class));
assertEquals(5, JCasUtil.select(jcas, Act.class).size());
// there are two scenes on
// http://gutenberg.spiegel.de/buch/romeo-und-juliette-2179/26, that's
// why 31 chapters on gutenberg.spiegel.de translate to 31 scenes (the
// first chapter being the front matter)
assertEquals(31, JCasUtil.select(jcas, Scene.class).size());
// 6th scene
scene = JCasUtil.selectByIndex(jcas, Scene.class, 5);
assertEquals("oppeln.]", scene.getCoveredText().substring(scene.getCoveredText().length() - 8));
assertTrue(scene.getCoveredText().endsWith("verdoppeln.]"));
// Balkony scene
scene = JCasUtil.selectByIndex(jcas, Scene.class, 7);
Iterator<Utterance> utteranceIter = JCasUtil.selectCovered(Utterance.class, scene).iterator();
Utterance utter;
utter = utteranceIter.next();
assertTrue(utter.getCoveredText().endsWith("berühren möchte!"));
Set<String> s = new HashSet<String>(JCasUtil.toText(JCasUtil.selectCovered(Speaker.class, scene)));
assertEquals(2, s.size());
assertFalse(iter.hasNext());
}