Java Code Examples for org.apache.uima.collection.CollectionReader#close()
The following examples show how to use
org.apache.uima.collection.CollectionReader#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PubmedWebServiceCollectionReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test public void testCat() throws Exception { CollectionReader cr = createReader( PubmedWebServiceCollectionReader.class,// PARAM_QUERY, "mouse", PARAM_MAX_NR_RESULTS, 20); List<JCas> results = BlueCasUtil.asList(cr); assertEquals("20 results", 20, results.size()); for (JCas jCas : results) { Header header = selectSingle(jCas, Header.class); LOG.debug("pmid: {}, text: {}", header.getDocId(), jCas.getDocumentText()); assertNotNull(header.getDocId()); } cr.close(); }
Example 2
Source File: PubmedWebServiceCollectionReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test public void testNervousSystem() throws Exception { CollectionReader cr = PubmedWebServiceCollectionReader.getCR( "nervous system[mesh]", 20); int cnt = 0; Iterator<JCas> it = BlueCasUtil.iterator(cr); while (it.hasNext()) { JCas jCas = it.next(); Header header = selectSingle(jCas, Header.class); LOG.debug("pmid: {}, text: {}", header.getDocId(), jCas.getDocumentText()); assertNotNull(header.getDocId()); ++cnt; } assertEquals("20 results", 20, cnt); cr.close(); }
Example 3
Source File: PubmedCentralCollectionReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test @Ignore // FIXME public void testCount() throws Exception { CollectionReader cr = PubmedCentralCollectionReader.getCR("pmc_test_archive"); int i = 0; while (cr.hasNext()) { CAS cas = CasCreationUtils.createCas(cr .getProcessingResourceMetaData()); cr.getNext(cas); i++; } cr.close(); assertEquals(6, i); }
Example 4
Source File: BioNLPGeniaEventsReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test public void testCount() throws Exception { CollectionReader cr = CollectionReaderFactory.createReader( BioNLPGeniaEventsCollectionReader.class, BlueUima.PARAM_INPUT_DIRECTORY, TEST_DIR); int i = 0; while (cr.hasNext()) { CAS cas = CasCreationUtils.createCas(cr .getProcessingResourceMetaData()); cr.getNext(cas); LOG.debug(To.string("cas nr " + i, cas.getJCas())); i++; } cr.close(); assertEquals(3, i); }
Example 5
Source File: BioNLPGeniaEventsCollectionReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test public void test() throws Exception { CollectionReader cr = CollectionReaderFactory.createReader( BioNLPGeniaEventsCollectionReader.class); int i = 0; while (cr.hasNext()) { CAS cas = CasCreationUtils.createCas(cr .getProcessingResourceMetaData()); cr.getNext(cas); // if (createHtml) // viewer.createHtml(cas.getJCas(), cas.getTypeSystem(), // styleMapFile, new File("target/" + i)); i++; } cr.close(); assertEquals(259, i); }
Example 6
Source File: XmlTestcaseCollectionReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test public void test() throws Exception { CollectionReader cr = createReader(XmlTestcaseCollectionReader.class, PARAM_INPUT_FILE, "testcases/example.xml"); CAS cas = CasCreationUtils .createCas(cr.getProcessingResourceMetaData()); cr.getNext(cas); cr.close(); Collection<CellTypeProteinConcentration> prots = JCasUtil.select( cas.getJCas(), CellTypeProteinConcentration.class); assertTrue(prots.size() > 1); Prin.t(prots); // TODO assert on object }
Example 7
Source File: Biocreative2GeneCollectionReaderTest.java From bluima with Apache License 2.0 | 6 votes |
@Test public void testTestCorpus() throws Exception { CollectionReader cr = CollectionReaderFactory.createReader( Biocreative2GeneCollectionReader.class, BlueUima.PARAM_MODE, "test"); CAS cas = CasCreationUtils .createCas(cr.getProcessingResourceMetaData()); cr.getNext(cas); Collection<BioEntityMention> genes = JCasUtil.select(cas.getJCas(), BioEntityMention.class); assertEquals(2, genes.size()); cr.close(); }
Example 8
Source File: PdfCollectionReaderTest.java From bluima with Apache License 2.0 | 5 votes |
@Test @Ignore // LATER public void testFails() throws Exception { CollectionReader cr = createReader(PdfCollectionReader.class, PARAM_INPUT_DIRECTORY, "pdf_fail"); for (JCas jCas : asList(cr)) { LOG.warn("docid:{}, text:{}", getHeaderDocId(jCas), jCas.getDocumentText()); } cr.close(); }
Example 9
Source File: GeniaCorpusCollectionReaderTest.java From bluima with Apache License 2.0 | 5 votes |
@Test public void testFaster() throws Exception { CollectionReader cr = createReader(GeniaCorpusCollectionReader.class); cr.hasNext(); CAS cas = createCas(cr.getProcessingResourceMetaData()); cr.getNext(cas); assertEquals("Activation of the CD", cas.getJCas().getDocumentText() .substring(0, 20)); cr.close(); }
Example 10
Source File: JCasCollectionReader_ImplBaseTest.java From uima-uimafit with Apache License 2.0 | 5 votes |
/** * Test using a simple reader reading one text file. * * @throws Exception * if an error occurs. */ @Test public void test() throws Exception { File file = folder.newFile("test.txt"); FileUtils.write(file, "Aaa Bbbb Cc Dddd eeee ff .", "UTF-8"); CollectionReader reader = createReader(SingleTextReader.class, SingleTextReader.PARAM_FILE, file.getPath()); CAS cas = CasCreationUtils.createCas(reader.getProcessingResourceMetaData()); reader.getNext(cas); reader.close(); assertEquals(FileUtils.readFileToString(file, "UTF-8"), cas.getDocumentText()); }
Example 11
Source File: AggregateCollectionReader.java From bluima with Apache License 2.0 | 4 votes |
public void close() throws IOException { for (CollectionReader reader : readers) { reader.close(); } }