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


Java CasCreationUtils.createCas方法代码示例

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


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

示例1: indexDocument

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
void indexDocument(Path documentPath) throws NlpTabException {
    try (InputStream inputStream = Files.newInputStream(documentPath)) {
        CAS cas = CasCreationUtils.createCas(typeSystem, null, null, tuningProperties, resourceManager);

        if (systemIndexingSettings.useXCas()) {
            XCASDeserializer.deserialize(inputStream, cas);
        } else {
            XmiCasDeserializer.deserialize(inputStream, cas);
        }

        CasProcessorSettings casProcessorSettings = new CasProcessorSettings(systemIndexingSettings.getIndex(),
                typeSystemInfo, systemIndexFSProcessorDelegateProvider, systemIndexCasViewProcessorDelegate);

        casProcessorFactory.create(casProcessorSettings, cas).process();
    } catch (ResourceInitializationException | IOException | SAXException e) {
        throw new NlpTabException(e);
    }
}
 
开发者ID:nlpie,项目名称:nlptab,代码行数:19,代码来源:SystemIndexing.java

示例2: run

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
private void run() throws ResourceInitializationException, IOException, SAXException {
    Collection<File> inputFiles =
            FileUtils.listFiles(inputDir, FileFilterUtils.suffixFileFilter(".xml"), null);
    if (inputFiles.isEmpty()) {
        return;
    }
    TypeSystemDescription tsd = TypeSystemDescriptionFactory
            .createTypeSystemDescription(typeSystemDescName);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    for (File inputFile : inputFiles) {
        AXMLReader.read(inputFile, cas);
        File outFile = getOutputFile(inputFile);
        OutputStream out = FileUtils.openOutputStream(outFile);
        try {
            XmiCasSerializer.serialize(cas, null, out, true, null);
        } finally {
            out.close();
            cas.reset();
        }
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:22,代码来源:AXML2XMI.java

示例3: setUp

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    daoDesc = ExternalResourceFactory.createExternalResourceDescription(
            XmiFileTreeCorpusDAOResource.class, corpusPathString);
    tsd = CasCreationUtils
            .mergeTypeSystems(Sets.newHashSet(
                    XmiFileTreeCorpusDAO.getTypeSystem(corpusPathString),
                    TypeSystemDescriptionFactory
                            .createTypeSystemDescription(),
                    TokenizerAPI.getTypeSystemDescription(),
                    SentenceSplitterAPI.getTypeSystemDescription()));
    readerDesc = CollectionReaderFactory.createReaderDescription(
            CorpusDAOCollectionReader.class, tsd,
            CorpusDAOCollectionReader.CORPUS_DAO_KEY, daoDesc);
    CAS aCAS = CasCreationUtils.createCas(tsd, null, null, null);
    tokenizerSentenceSplitterDesc = AnalysisEngineFactory
            .createEngineDescription(Unitizer.createTokenizerSentenceSplitterAED());
    unitAnnotatorDesc = AnalysisEngineFactory.createEngineDescription(
            UnitAnnotator.class, UnitAnnotator.PARAM_UNIT_TYPE_NAMES,
            unitTypes);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:22,代码来源:UnitAnnotatorTest.java

示例4: test3

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Test
@DirtiesContext
public void test3() throws UIMAException {
    // the same as test2 but with exactMatch invoked
    Type t1 = ts.getType("test.TestFirst");
    CAS cas = CasCreationUtils.createCas(ts, null, null, null);
    cas.setDocumentText(TXT);
    AnnotationFS g1 = cas.createAnnotation(t1, 0, 9);
    AnnotationFS s1 = cas.createAnnotation(t1, 0, 9);
    AnnotationFS s2 = cas.createAnnotation(t1, 0, 18);
    AnnotationFS s3 = cas.createAnnotation(t1, 6, 12);
    evaluator.onDocumentChange("1");
    evaluator.onExactMatch(g1, s1);
    evaluator.onPartialMatch(g1, s2);
    evaluator.onPartialMatch(g1, s3);
    evaluator.onDocumentChange(null);
    RecognitionMeasures m = evaluator.getMeasures();
    assertEquals(1f, m.getMatchedScore(), 0.001f);
    assertEquals(2f, m.getSpuriousScore(), 0.001f);
    assertEquals(0f, m.getMissedScore(), 0.001f);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:22,代码来源:BestMatchEvaluatorBaseTest.java

示例5: testCount

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的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

示例6: testCount

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的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

示例7: test

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的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

示例8: test

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的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

示例9: testTestCorpus

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的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

示例10: runPipeline

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的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

示例11: setUriShouldFailIfThereIsNoMeta

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Test
public void setUriShouldFailIfThereIsNoMeta() throws ResourceInitializationException {
    CAS cas = CasCreationUtils.createCas(inputTS, null, null);
    cas.setDocumentText("Some text");
    assertEquals(null, DocumentUtils.getDocumentUri(cas));
    try {
        DocumentUtils.setDocumentUri(cas, "uri1", false);
    } catch (IllegalStateException e) {
        return;
    }
    fail();
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:13,代码来源:DocumentUtilsTest.java

示例12: setUriShouldCreateIfThereIsNoMeta

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Test
public void setUriShouldCreateIfThereIsNoMeta() throws ResourceInitializationException {
    CAS cas = CasCreationUtils.createCas(inputTS, null, null);
    cas.setDocumentText("Some text");
    assertEquals(null, DocumentUtils.getDocumentUri(cas));
    DocumentUtils.setDocumentUri(cas, "uri1", true);
    assertEquals("uri1", DocumentUtils.getDocumentUri(cas));
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:9,代码来源:DocumentUtilsTest.java

示例13: setUriShouldChangeUri

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Test
public void setUriShouldChangeUri() throws ResourceInitializationException, CASException {
    CAS cas = CasCreationUtils.createCas(inputTS, null, null);
    {
        JCas jCas = cas.getJCas();
        DocumentMetadata dm = new DocumentMetadata(jCas, 0, 0);
        dm.setSourceUri("old_uri");
        dm.addToIndexes();
    }
    cas.setDocumentText("Some text");
    assertEquals("old_uri", DocumentUtils.getDocumentUri(cas));
    DocumentUtils.setDocumentUri(cas, "uri1", false);
    assertEquals("uri1", DocumentUtils.getDocumentUri(cas));
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:15,代码来源:DocumentUtilsTest.java

示例14: setUriShouldFailIfNoTypeDefined

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Test
public void setUriShouldFailIfNoTypeDefined() throws ResourceInitializationException {
    TypeSystemDescription inputTS = new TypeSystemDescription_impl();
    CAS cas = CasCreationUtils.createCas(inputTS, null, null);
    cas.setDocumentText("Some text");
    assertEquals(null, DocumentUtils.getDocumentUri(cas));
    try {
        DocumentUtils.setDocumentUri(cas, "uri1", true);
    } catch (IllegalStateException e) {
        return;
    }
    fail();
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:14,代码来源:DocumentUtilsTest.java

示例15: testGetDocumentCas

import org.apache.uima.util.CasCreationUtils; //导入方法依赖的package包/类
@Test
public void testGetDocumentCas() throws ResourceInitializationException,
        IOException, SAXException, URISyntaxException, ParserConfigurationException {
    CAS aCAS = CasCreationUtils.createCas(
            XmiFileTreeCorpusDAO.getTypeSystem(corpusPathString), null,
            null, null);
    corpusDAO.getDocumentCas(new URI("62007.txt"), "1", aCAS);
    assertThat(aCAS.getDocumentText(), containsString("РИА Новости"));
    assertEquals(6, CasUtil.selectAll(aCAS).size());
    assertEquals(
            1,
            CasUtil.select(
                    aCAS,
                    CasUtil.getAnnotationType(aCAS,
                            "ru.kfu.itis.issst.evex.Weapon")).size());

    aCAS = CasCreationUtils.createCas(
            XmiFileTreeCorpusDAO.getTypeSystem(corpusPathString), null,
            null, null);
    corpusDAO.getDocumentCas(new URI("62007.txt"), "5", aCAS);
    assertThat(aCAS.getDocumentText(), containsString("РИА Новости"));
    assertThat(CasUtil.selectAll(aCAS).size(), equalTo(5));
    assertEquals(
            0,
            CasUtil.select(
                    aCAS,
                    CasUtil.getAnnotationType(aCAS,
                            "ru.kfu.itis.issst.evex.Weapon")).size());
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:30,代码来源:XmiFileTreeCorpusDAOTest.java


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