Conll2003GoldReader extends JCasCollectionReader_ImplBase { public void close() throws IOException { reader.close(); }  void initialize(UimaContext context); void getNext(JCas jCas); void close(); Progress[] getProgress(); boolean hasNext(); void setDataFileName(String dataFileName); void setLoadNamedEntities(boolean loadNamedEntities); static final String PARAM_DATA_FILE_NAME; static final String PARAM_LOAD_NAMED_ENTITIES; static final String DOCSTART; }
@Test public void testFakeTrainDocs() throws Exception { CollectionReaderDescription desc = CollectionReaderFactory.createReaderDescription( Conll2003GoldReader.class, Conll2003GoldReader.PARAM_DATA_FILE_NAME, "src/test/resources/data/conll2003/eng.train", Conll2003GoldReader.PARAM_LOAD_NAMED_ENTITIES, true); Iterator<JCas> iterator = new JCasIterable(desc).iterator(); JCas jcas = iterator.next(); ViewUriUtil.getURI(jcas).toURL().openStream().close(); FSIndex<Annotation> sentenceIndex = jcas.getAnnotationIndex(Sentence.type); Assert.assertEquals(1, sentenceIndex.size()); Sentence firstSentence = JCasUtil.selectByIndex(jcas, Sentence.class, 0); Assert.assertEquals("ee rrrr ggg ccc tt bbbb BBBBBBB llll . ", firstSentence.getCoveredText()); Assert.assertEquals(9, JCasUtil.selectCovered(jcas, Token.class, firstSentence).size()); Token token = JCasUtil.selectByIndex(jcas, Token.class, 0); Assert.assertEquals("A", token.getPos()); Chunk chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 0); Assert.assertEquals("ee", chunk.getCoveredText()); Assert.assertEquals("A", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 1); Assert.assertEquals("rrrr", chunk.getCoveredText()); Assert.assertEquals("B", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 2); Assert.assertEquals("ggg ccc", chunk.getCoveredText()); Assert.assertEquals("N", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 3); Assert.assertEquals("tt bbbb", chunk.getCoveredText()); Assert.assertEquals("T", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 4); Assert.assertEquals("BBBBBBB llll", chunk.getCoveredText()); Assert.assertEquals("BB", chunk.getChunkType()); NamedEntityMention nem = JCasUtil.selectByIndex(jcas, NamedEntityMention.class, 0); NamedEntity ne = nem.getMentionedEntity(); Assert.assertEquals("ee", nem.getCoveredText()); Assert.assertEquals("NAM", nem.getMentionType()); Assert.assertEquals("OOO", ne.getEntityType()); nem = JCasUtil.selectByIndex(jcas, NamedEntityMention.class, 1); ne = nem.getMentionedEntity(); Assert.assertEquals("ggg", nem.getCoveredText()); Assert.assertEquals("MM", ne.getEntityType()); nem = JCasUtil.selectByIndex(jcas, NamedEntityMention.class, 2); ne = nem.getMentionedEntity(); Assert.assertEquals("BBBBBBB", nem.getCoveredText()); Assert.assertEquals("MM", ne.getEntityType()); jcas = iterator.next(); ViewUriUtil.getURI(jcas).toURL().openStream().close(); sentenceIndex = jcas.getAnnotationIndex(Sentence.type); Assert.assertEquals(1, sentenceIndex.size()); firstSentence = JCasUtil.selectByIndex(jcas, Sentence.class, 0); Assert.assertEquals("CCCCC ssss tttt rrrrr fff TTTTTT ttttt . ", firstSentence.getCoveredText()); Assert.assertEquals(8, JCasUtil.selectCovered(jcas, Token.class, firstSentence).size()); token = JCasUtil.selectByIndex(jcas, Token.class, 0); Assert.assertEquals("PPP", token.getPos()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 0); Assert.assertEquals("CCCCC", chunk.getCoveredText()); Assert.assertEquals("PP", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 1); Assert.assertEquals("ssss", chunk.getCoveredText()); Assert.assertEquals("VV", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 2); Assert.assertEquals("tttt", chunk.getCoveredText()); Assert.assertEquals("NN", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 3); Assert.assertEquals("rrrrr", chunk.getCoveredText()); Assert.assertEquals("AAAA", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 4); Assert.assertEquals("fff", chunk.getCoveredText()); Assert.assertEquals("PP", chunk.getChunkType()); chunk = JCasUtil.selectByIndex(jcas, Chunk.class, 5); Assert.assertEquals("TTTTTT ttttt", chunk.getCoveredText()); Assert.assertEquals("NN", chunk.getChunkType()); nem = JCasUtil.selectByIndex(jcas, NamedEntityMention.class, 0); ne = nem.getMentionedEntity(); Assert.assertEquals("CCCCC", nem.getCoveredText()); Assert.assertEquals("NAM", nem.getMentionType()); Assert.assertEquals("LL", ne.getEntityType()); nem = JCasUtil.selectByIndex(jcas, NamedEntityMention.class, 1); ne = nem.getMentionedEntity(); Assert.assertEquals("TTTTTT", nem.getCoveredText()); Assert.assertEquals("LL", ne.getEntityType()); }