当前位置: 首页>>代码示例>>Java>>正文


Java CollectionReader.hasNext方法代码示例

本文整理汇总了Java中org.apache.uima.collection.CollectionReader.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionReader.hasNext方法的具体用法?Java CollectionReader.hasNext怎么用?Java CollectionReader.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.uima.collection.CollectionReader的用法示例。


在下文中一共展示了CollectionReader.hasNext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@Test
public void test() throws Exception {

    CollectionReader cr = createReader(PubmedWholeDatabaseCR.class);

    CAS cas = createCas(cr.getProcessingResourceMetaData());
    cr.getNext(cas);

    for (int i = 0; i < 10000; i++) {
        cr.hasNext();
        cas = createCas(cr.getProcessingResourceMetaData());
        cr.getNext(cas);
        System.err.println(cas.getDocumentText());
    }

    // FIXME hangs up cr.close();

    Collection<Header> h = select(cas.getJCas(), Header.class);
    assertResultsContains(h, "DocId", "1");
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:21,代码来源:PubmedWholeDatabaseCRTest.java

示例2: testCount

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@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);
   }
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:18,代码来源:PubmedCentralCollectionReaderTest.java

示例3: testCount

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@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);
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:19,代码来源:BioNLPGeniaEventsReaderTest.java

示例4: test

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@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);

   }
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:23,代码来源:BioNLPGeniaEventsCollectionReaderTest.java

示例5: runPipeline

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
/**
 * Provides a simple way to run a pipeline for a given collection reader and sequence of
 * analysis engines. After processing all CASes provided by the reader, the method calls
 * {@link AnalysisEngine#collectionProcessComplete() collectionProcessComplete()} on the
 * engines.
 *
 * @param reader
 *            a collection reader
 * @param engines
 *            a sequence of analysis engines
 * @throws UIMAException
 * @throws IOException
 */
public static void runPipeline(final CollectionReader reader, final AnalysisEngine... engines)
    throws UIMAException, IOException {
  final List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
  metaData.add(reader.getMetaData());
  for (AnalysisEngine engine : engines) {
    metaData.add(engine.getMetaData());
  }

  final CAS cas = CasCreationUtils.createCas(metaData);
  try {
    while (reader.hasNext()) {
      reader.getNext(cas);
      runPipeline(cas, engines);
      cas.reset();
    }
  } finally {
    collectionProcessComplete(engines);
    destroy(reader);
  }
}
 
开发者ID:oaqa,项目名称:bagpipes-old,代码行数:34,代码来源:SimplePipelineRev803.java

示例6: testFaster

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@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();
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:11,代码来源:GeniaCorpusCollectionReaderTest.java

示例7: importCasFromFile

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@Override
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public JCas importCasFromFile(File aFile, Project aProject, String aFormat)
        throws UIMAException, IOException, ClassNotFoundException
    {
        Class readerClass = getReadableFormats().get(aFormat);
        if (readerClass == null) {
            throw new IOException("No reader available for format [" + aFormat + "]");
        }
        
        // Prepare a CAS with the project type system
        TypeSystemDescription builtInTypes = TypeSystemDescriptionFactory
                .createTypeSystemDescription();
        List<TypeSystemDescription> projectTypes = annotationService.getProjectTypes(aProject);
        projectTypes.add(builtInTypes);
        TypeSystemDescription allTypes = CasCreationUtils.mergeTypeSystems(projectTypes);
        CAS cas = JCasFactory.createJCas(allTypes).getCas();

        // Convert the source document to CAS
        CollectionReader reader = CollectionReaderFactory.createReader(readerClass,
                ResourceCollectionReaderBase.PARAM_SOURCE_LOCATION, aFile.getParentFile()
                        .getAbsolutePath(), ResourceCollectionReaderBase.PARAM_PATTERNS,
                new String[] { "[+]" + aFile.getName() });
        if (!reader.hasNext()) {
            throw new FileNotFoundException(
                    "Source file [" + aFile.getName() + "] not found in [" + aFile.getPath() + "]");
        }
        reader.getNext(cas);
        JCas jCas = cas.getJCas();

        // Create sentence / token annotations if they are missing
        boolean hasTokens = JCasUtil.exists(jCas, Token.class);
        boolean hasSentences = JCasUtil.exists(jCas, Sentence.class);

//        if (!hasTokens || !hasSentences) {
//            AnalysisEngine pipeline = createEngine(createEngineDescription(
//                    BreakIteratorSegmenter.class, 
//                    BreakIteratorSegmenter.PARAM_WRITE_TOKEN, !hasTokens,
//                    BreakIteratorSegmenter.PARAM_WRITE_SENTENCE, !hasSentences));
//            pipeline.process(jCas);
//        }
        
        if (!hasSentences) {
            splitSentences(jCas);
        }

        if (!hasTokens) {
            tokenize(jCas);
        }
        
        if (!JCasUtil.exists(jCas, Token.class) || !JCasUtil.exists(jCas, Sentence.class)) {
            throw new IOException("The document appears to be empty. Unable to detect any "
                    + "tokens or sentences. Empty documents cannot be imported.");
        }
        
        return jCas;
    }
 
开发者ID:webanno,项目名称:webanno,代码行数:58,代码来源:ImportExportServiceImpl.java

示例8: testTrainCorpus

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
/**
 * <pre>
 * GENE.eval
 * P00001606T0076|14 33|alkaline phosphatases
 * P00001606T0076|37 50|5-nucleotidase
 * 
 * train.in:
 * P00001606T0076 Comparison with alkaline phosphatases and 5-nucleotidase
 * </pre>
 */
@Test
public void testTrainCorpus() throws Exception {

    CollectionReader cr = CollectionReaderFactory.createReader(
            Biocreative2GeneCollectionReader.class,
            BlueUima.PARAM_MODE, "train");

    CAS cas = CasCreationUtils
            .createCas(cr.getProcessingResourceMetaData());
    cr.getNext(cas);

    Collection<BioEntityMention> genes = JCasUtil.select(cas.getJCas(),
            BioEntityMention.class);
    assertEquals(2, genes.size());
    Iterator<BioEntityMention> iterator = genes.iterator();
    BioEntityMention gene = iterator.next();
    assertEquals("alkaline phosphatases", gene.getCoveredText());
    gene = iterator.next();
    assertEquals("5-nucleotidase", gene.getCoveredText());

    // move to 'P00027739T0000 Serum gamma glutamyltransferase in the
    // diagnosis of liver disease in cattle.' to test ALTGENE annotations
    for (int i = 0; i < 11; i++) {
        cas = CasCreationUtils
                .createCas(cr.getProcessingResourceMetaData());
        cr.hasNext();
        cr.getNext(cas);
        Header header = JCasUtil.selectSingle(cas.getJCas(), Header.class);
        LOG.debug("docid:{}, text:{}", header.getDocId(),
                cas.getDocumentText());
    }

    genes = JCasUtil.select(cas.getJCas(), BioEntityMention.class);
    iterator = genes.iterator();

    // check the 2 alternate forms
    assertEquals(2, genes.size());
    gene = iterator.next();
    LOG.debug(gene.getCoveredText());
    assertEquals("Serum gamma glutamyltransferase", gene.getCoveredText());
    gene = iterator.next();
    LOG.debug(gene.getCoveredText());
    assertEquals("gamma glutamyltransferase", gene.getCoveredText());
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:55,代码来源:Biocreative2GeneCollectionReaderTest.java


注:本文中的org.apache.uima.collection.CollectionReader.hasNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。