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


Java CollectionReader.getNext方法代码示例

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


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

示例1: readWebAnnoTSV

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
public static JCas readWebAnnoTSV(String aPath, TypeSystemDescription aType)
    throws UIMAException, IOException
{
    CollectionReader reader = createReader(WebannoTsv2Reader.class,
            WebannoTsv2Reader.PARAM_SOURCE_LOCATION, "src/test/resources/" + aPath);
    JCas jcas;
    if (aType != null) {
        TypeSystemDescription builtInTypes = TypeSystemDescriptionFactory
                .createTypeSystemDescription();
        List<TypeSystemDescription> allTypes = new ArrayList<>();
        allTypes.add(builtInTypes);
        allTypes.add(aType);
        jcas = JCasFactory.createJCas(CasCreationUtils.mergeTypeSystems(allTypes));
    }
    else {
        jcas = JCasFactory.createJCas();
    }

    reader.getNext(jcas.getCas());

    return jcas;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:23,代码来源:DiffUtils.java

示例2: readXMI

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
public static JCas readXMI(String aPath, TypeSystemDescription aType)
    throws UIMAException, IOException
{
    CollectionReader reader = createReader(XmiReader.class, XmiReader.PARAM_SOURCE_LOCATION,
            "src/test/resources/" + aPath);
    JCas jcas;
    if (aType != null) {
        TypeSystemDescription builtInTypes = TypeSystemDescriptionFactory
                .createTypeSystemDescription();
        List<TypeSystemDescription> allTypes = new ArrayList<>();
        allTypes.add(builtInTypes);
        allTypes.add(aType);
        jcas = JCasFactory.createJCas(CasCreationUtils.mergeTypeSystems(allTypes));
    }
    else {
        jcas = JCasFactory.createJCas();
    }

    reader.getNext(jcas.getCas());

    return jcas;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:23,代码来源:DiffUtils.java

示例3: test

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

    CollectionReader reader = createReader(LineOrientedTextReader.class,
            LineOrientedTextReader.PARAM_SOURCE_LOCATION, "LICENSE.txt");

    reader.getNext(doc.getCas());
    
    // select(doc, Sentence.class).forEach(s -> System.out.println(s.getCoveredText()));
    
    assertEquals(169, select(doc, Sentence.class).size());
    assertEquals(0, select(doc, Token.class).size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:17,代码来源:LineOrientedTextReaderTest.java

示例4: test

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@Test
public void test() throws Exception, JDOMException {
  CollectionReader reader = FilesCollectionReader.getCollectionReaderWithView(
      this.inputFile.getPath(),
      TimeMlGoldAnnotator.TIMEML_VIEW_NAME);
  AnalysisEngine annotator = AnalysisEngineFactory.createEngine(TimeMlGoldAnnotator.getDescription());
  AnalysisEngine writer = AnalysisEngineFactory.createEngine(TempEval2007Writer.getDescription(this.outputDirectory.getPath()));

  reader.getNext(this.jCas.getCas());
  annotator.process(this.jCas);
  writer.process(this.jCas);
  reader.close();
  annotator.collectionProcessComplete();
  writer.collectionProcessComplete();

  String expected = FileUtils.file2String(this.inputFile);
  String actual = FileUtils.file2String(this.outputFile);
  this.assertEquals(this.getRoot(expected), this.getRoot(actual));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:20,代码来源:TempEval2007WriterTest.java

示例5: testGetNext

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@Test
public void testGetNext() throws Exception{
    CollectionReader ecr = new ExternalCollectionReader(descriptor).produceCollectionReader();
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(SampleService
            .simpleServiceDefinition()
            .getAnalysisEngineDescription());
    CAS mockCas = ae.newCAS();
    ecr.getNext(mockCas);
    FSIterator<AnnotationFS> csiIterator = mockCas.getAnnotationIndex(mockCas.getTypeSystem().getType(CSI.class.getCanonicalName())).iterator();
    assertTrue(csiIterator.hasNext());
    CSI csi = (CSI) csiIterator.next();
    assertTrue("text1.txt".equals(csi.getID()));
    //System.out.println(csi.getLocator());
    assertTrue(csi.getLocator().endsWith(rootDirectory + "src/test/resources/inputDirectory/text1.txt"));
    assertNull(csi.getPropertiesKeys());
    assertNull(csi.getRowData());
    assertTrue(RESULTS.equals(mockCas.getDocumentText()));
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:19,代码来源:ExternalFileCollectionReaderTest.java

示例6: test

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    String out = "target/BinaryCasWriterTest_" + currentTimeMillis() + "/";

    // WRITING
    CollectionReader cr = createReader(SingleAbstractReader.class);
    AnalysisEngine writer = createEngine(BinaryCasWriter.class,
            PARAM_OUTPUT_DIR, out);
    runPipeline(cr, createEngine(NaiveSentenceSplitterAnnotator.class),
            createEngine(RegexTokenizerAnnotator.class), writer);

    assertTrue(new File(out + "1/957/687.gz").exists());

    // READING
    CollectionReader reader = createReader(BinaryCasReader.class,
            PARAM_INPUT_DIRECTORY, out);
    CAS cas = createCas(createTypeSystemDescription(), null, null);
    reader.getNext(cas);

    assertEquals(SingleAbstractReader.getText(), cas.getDocumentText());
    assertEquals(SingleAbstractReader.getPmId(),
            getHeaderIntDocId(cas.getJCas()));
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:24,代码来源:BinaryCasWriterTest.java

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: test

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

示例12: testTestCorpus

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

示例13: 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

示例14: testGenerateBratJsonGetDocument

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
/**
 * generate brat JSON data for the document
 */
@Test
public void testGenerateBratJsonGetDocument() throws Exception
{
    MappingJackson2HttpMessageConverter jsonConverter = 
            new MappingJackson2HttpMessageConverter();
    String jsonFilePath = "target/test-output/output_cas_to_json_document.json";
    String file = "src/test/resources/tcf04-karin-wl.xml";
    
    CAS cas = JCasFactory.createJCas().getCas();
    CollectionReader reader = CollectionReaderFactory.createReader(TcfReader.class,
            TcfReader.PARAM_SOURCE_LOCATION, file);
    reader.getNext(cas);
    JCas jCas = cas.getJCas();

    AnnotatorState state = new AnnotatorStateImpl(Mode.ANNOTATION);
    state.getPreferences().setWindowSize(10);
    state.setFirstVisibleUnit(WebAnnoCasUtil.getFirstSentence(jCas));

    state.setProject(project);

    
    VDocument vdoc = new VDocument();
    preRenderer.render(vdoc, state, jCas, annotationSchemaService.listAnnotationLayer(project));

    GetDocumentResponse response = new GetDocumentResponse();
    BratRenderer.render(response, state, vdoc, jCas, annotationSchemaService);

    JSONUtil.generatePrettyJson(jsonConverter, response, new File(jsonFilePath));

    String reference = FileUtils.readFileToString(new File(
            "src/test/resources/output_cas_to_json_document_expected.json"), "UTF-8");
    String actual = FileUtils.readFileToString(new File(jsonFilePath), "UTF-8");
    assertTrue(IOUtils.contentEqualsIgnoreEOL(new StringReader(reference),
            new StringReader(actual)));
}
 
开发者ID:webanno,项目名称:webanno,代码行数:39,代码来源:CasToBratJsonTest.java

示例15: testSimpleSymbolicRules

import org.apache.uima.collection.CollectionReader; //导入方法依赖的package包/类
@Test
public void testSimpleSymbolicRules()
    throws Exception
{
    ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream(
            "src/test/resources/rules/symbolic1.rules"));
    Parse p = parser.Parse();

    ParsedConstraints constraints = p.accept(new ParserVisitor());

    JCas jcas = JCasFactory.createJCas();

    CollectionReader reader = createReader(Conll2006Reader.class,
            Conll2006Reader.PARAM_SOURCE_LOCATION, "src/test/resources/text/1.conll");
    
    reader.getNext(jcas.getCas());

    POS pos = new POS(jcas, 8, 9);
    pos.setPosValue("pronoun");
    pos.addToIndexes();
    
    Evaluator constraintsEvaluator = new ValuesGenerator();

    Lemma lemma = select(jcas, Lemma.class).iterator().next();
    
    List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(lemma,
            "value", constraints);

    List<PossibleValue> expectedOutput = new ArrayList<>();
    expectedOutput.add(new PossibleValue("good", true));

    assertEquals(expectedOutput, possibleValues);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:34,代码来源:SymbolicRulesTest.java


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