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


Java ExternalResourceFactory.createExternalResourceDescription方法代码示例

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


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

示例1: beforeTest

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Override
public void beforeTest() throws UIMAException {
    super.beforeTest();

    final ExternalResourceDescription tokensDesc = ExternalResourceFactory.createExternalResourceDescription(
            "lexica",
            ClearNlpLexica.class);

    final AnalysisEngineDescription tokeniserDesc = AnalysisEngineFactory.createEngineDescription(
            ClearNlpTokeniser.class,
            "lexica",
            tokensDesc);

    tokeniserAe = AnalysisEngineFactory.createEngine(tokeniserDesc);

    final AnalysisEngineDescription parserDesc = AnalysisEngineFactory.createEngineDescription(ClearNlpParser.class,
            "lexica",
            tokensDesc);

    ae = AnalysisEngineFactory.createEngine(parserDesc);
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:22,代码来源:ClearNlpParserTest.java

示例2: createAnalysisEngines

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Override
protected AnalysisEngine[] createAnalysisEngines() throws ResourceInitializationException {

    // Use OpenNlp to generate the POS etc for us
    final ExternalResourceDescription tokensDesc = ExternalResourceFactory.createExternalResourceDescription(
            "tokens",
            SharedOpenNLPModel.class);
    final ExternalResourceDescription sentencesDesc = ExternalResourceFactory
            .createExternalResourceDescription("sentences", SharedOpenNLPModel.class);
    final ExternalResourceDescription posDesc = ExternalResourceFactory.createExternalResourceDescription("posTags",
            SharedOpenNLPModel.class);
    final ExternalResourceDescription chunksDesc = ExternalResourceFactory
            .createExternalResourceDescription("phraseChunks", SharedOpenNLPModel.class);

    return asArray(
            createAnalysisEngine(OpenNLP.class, "tokens", tokensDesc, "sentences", sentencesDesc, "posTags",
                    posDesc, "phraseChunks", chunksDesc),
            createAnalysisEngine(MaltParser.class));
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:20,代码来源:MaltParserTest.java

示例3: setUp

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws ResourceInitializationException, ResourceAccessException {
    // Create a description of an external resource - a fongo instance, in the same way we would
    // have created a shared mongo resource
    final ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(
            SharedFongoResource.class, "fongo.collection", "test", "fongo.data", "[]");

    // Create the analysis engine
    final AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(MongoPatternSaver.class,
            MongoPatternSaver.KEY_MONGO, erd,
            "collection", "test");
    ae = AnalysisEngineFactory.createEngine(aed);
    ae.initialize(new CustomResourceSpecifier_impl(), Collections.emptyMap());

    sfr = (SharedFongoResource) ae.getUimaContext()
            .getResourceObject(MongoPatternSaver.KEY_MONGO);

}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:19,代码来源:MongoPatternSaverTest.java

示例4: setupClass

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setupClass() throws UIMAException, JMSException {
    //Configuration values
    Object[] configArr = new String[] {
            SharedActiveMQResource.PARAM_PROTOCOL, PROTOCOL_VALUE,
            SharedActiveMQResource.PARAM_HOST, HOST_VALUE,
            SharedActiveMQResource.PARAM_BROKERARGS, BROKERARGS_VALUE
    };

    //Create descriptors
    ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(ACTIVEMQ, SharedActiveMQResource.class, configArr);
    AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(ActiveMQ.class, TypeSystemSingleton.getTypeSystemDescriptionInstance(), ACTIVEMQ, erd, ActiveMQ.PARAM_ENDPOINT, ENDPOINT);

    //Create annotator
    ae = AnalysisEngineFactory.createEngine(aed);
    
    //Get resource so that we can use it to test output
    resource = (SharedActiveMQResource) ae.getUimaContext().getResourceObject(ACTIVEMQ);
    //Subscribe to what will be the output topic
    Session session = resource.getSession();
    topicConsumer = session.createConsumer(session.createTopic(ENDPOINT));
}
 
开发者ID:dstl,项目名称:baleen,代码行数:23,代码来源:ActiveMQTest.java

示例5: makeAE

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
private AnalysisEngine makeAE(boolean removeWordAnnotationFromCas, boolean removeTermOccAnnotationFromCas) throws Exception {
    AnalysisEngineDescription aeDesc = AnalysisEngineFactory.createEngineDescription(
            FixedExpressionSpotter.class,
            FixedExpressionSpotter.FIXED_EXPRESSION_MAX_SIZE, 5,
            FixedExpressionSpotter.REMOVE_WORD_ANNOTATIONS_FROM_CAS, removeWordAnnotationFromCas,
            FixedExpressionSpotter.REMOVE_TERM_OCC_ANNOTATIONS_FROM_CAS, removeTermOccAnnotationFromCas
        );
    
    /*
     * The term index resource
     */
    ExternalResourceDescription fixedExpressionDesc = ExternalResourceFactory.createExternalResourceDescription(
            FixedExpressionResource.FIXED_EXPRESSION_RESOURCE,
            FixedExpressionResource.class, 
            "file:fr/univnantes/termsuite/test/resources/french-fixed-expressions.txt"
    );
    ExternalResourceFactory.bindResource(aeDesc, fixedExpressionDesc);

    AnalysisEngine ae = AnalysisEngineFactory.createEngine(aeDesc);
    return ae;
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:22,代码来源:FixedExpressionSpotterSpec.java

示例6: testCustomStoplist

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Test
public void testCustomStoplist() throws ResourceInitializationException, AnalysisEngineProcessException{
    ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(STOPWORDS, SharedStopwordResource.class);
    AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(RakeKeywords.class, STOPWORDS, erd, RakeKeywords.PARAM_MAX_KEYWORDS, 12, RakeKeywords.PARAM_ADD_BUZZWORDS, false, RakeKeywords.PARAM_STOPLIST, getClass().getResource("exampleStoplist.txt").getPath());

    AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed);

    jCas.setDocumentText("Bill and Ben went off to the shops in London town.");
    ae.process(jCas);

    assertEquals(1, JCasUtil.select(jCas, Metadata.class).size());
    Metadata md = JCasUtil.selectByIndex(jCas, Metadata.class, 0);
    assertEquals("keywords", md.getKey());

    List<String> keywords = Arrays.asList(md.getValue().split(";"));
    assertEquals(1, keywords.size());
    assertTrue(keywords.contains("london town"));

    ae.destroy();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:21,代码来源:RakeKeywordsTest.java

示例7: testLongDocument

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Test
public void testLongDocument() throws Exception{
    ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(STOPWORDS, SharedStopwordResource.class);
    AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(RakeKeywords.class, STOPWORDS, erd, RakeKeywords.PARAM_MAX_KEYWORDS, 12, RakeKeywords.PARAM_ADD_BUZZWORDS, true);

    AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed);

    jCas.setDocumentText(new String(Files.readAllBytes(Paths.get(getClass().getResource("turing.txt").toURI()))));
    ae.process(jCas);

    assertEquals(1, JCasUtil.select(jCas, Metadata.class).size());
    Metadata md = JCasUtil.selectByIndex(jCas, Metadata.class, 0);
    assertEquals("keywords", md.getKey());
    assertNotNull(md.getValue());

    ae.destroy();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:18,代码来源:RakeKeywordsTest.java

示例8: createWordTokenizerAEDesc

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
public static AnalysisEngineDescription createWordTokenizerAEDesc(ResourceConfig resourceConfig, Lang lang) {
    AnalysisEngineDescription ae;
    try {
        ae = AnalysisEngineFactory.createEngineDescription(
                Lexer.class, 
                Lexer.PARAM_TYPE, "fr.univnantes.termsuite.types.WordAnnotation"
            );
    
        ExternalResourceDescription	segmentBank = ExternalResourceFactory.createExternalResourceDescription(
                SegmentBankResource.class,
                getResourceURL(resourceConfig, ResourceType.SEGMENT_BANK, lang)
            );
                
        ExternalResourceFactory.bindResource(
                ae, 
                SegmentBank.KEY_SEGMENT_BANK, 
                segmentBank);
        return ae;	
    } catch (Exception e) {
        throw new TermSuiteException(e);
    }
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:23,代码来源:CustomResourceTermSuiteAEFactory.java

示例9: testmultipleHitsWithText

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Test
public void testmultipleHitsWithText() throws Exception{

    ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(FILE_GAZETTEER, SharedFileResource.class);
    AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(File.class, FILE_GAZETTEER, erd, FILE_NAME, getClass().getResource(GAZETTEER_TXT).getPath(), TYPE, LOCATION);

    AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed);

    // the same search term appears multiple times in text...
    jCas.setDocumentText("Hello world, and hello world again.");
    // but then subset using a Text annotation
    new Text(jCas, 10, jCas.getDocumentText().length()).addToIndexes();

    ae.process(jCas);

    assertEquals(1, JCasUtil.select(jCas, Location.class).size());
    Location l = JCasUtil.selectByIndex(jCas, Location.class, 0);
    assertEquals(WORLD, l.getValue());
    assertEquals(WORLD, l.getCoveredText());
    assertTrue(l.getBegin() > 10);

    ae.destroy();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:24,代码来源:FileTest.java

示例10: createNormalizerAEDesc

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
public static AnalysisEngineDescription createNormalizerAEDesc(ResourceConfig resourceConfig, Lang lang, Tagger tagger) {
    AnalysisEngineDescription ae;
    try {
        ae = AnalysisEngineFactory.createEngineDescription(
                Lexer.class, 
                Lexer.PARAM_TYPE, "fr.univnantes.termsuite.types.WordAnnotation"
            );
    
        ExternalResourceDescription	segmentBank = ExternalResourceFactory.createExternalResourceDescription(
                SegmentBankResource.class,
                getResourceURL(resourceConfig, ResourceType.SEGMENT_BANK, lang)
            );
                
        ExternalResourceFactory.bindResource(
                ae, 
                SegmentBank.KEY_SEGMENT_BANK, 
                segmentBank);
        return ae;	
    } catch (Exception e) {
        throw new TermSuiteException(e);
    }
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:23,代码来源:CustomResourceTermSuiteAEFactory.java

示例11: testReference

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Test
public void testReference() throws Exception{
    //This test demonstrates the case where whitespace is preserved in gazetteer matching.

    ExternalResourceDescription erd = ExternalResourceFactory.createExternalResourceDescription(FILE_GAZETTEER, SharedFileResource.class);
    AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(File.class, FILE_GAZETTEER, erd, FILE_NAME, getClass().getResource(GAZETTEER_TXT).getPath(), TYPE, LOCATION, "exactWhitespace", false);

    AnalysisEngine ae = AnalysisEngineFactory.createEngine(aed);

    // words in term to search for separated by multiple spaces, tabs or newline...
    jCas.setDocumentText("This text mentions New York (also known as NY and the Big Apple).");

    ae.process(jCas);

    // 3 mentions of "New York" and nicknames...
    assertEquals(3, JCasUtil.select(jCas, Location.class).size());
    // ...but they're all the same entity, so only one ReferenceTarget
    assertEquals(1, JCasUtil.select(jCas, ReferenceTarget .class).size());

    Location l = JCasUtil.selectByIndex(jCas, Location.class, 0);
    assertEquals(NEW_YORK, l.getValue());

    ae.destroy();
}
 
开发者ID:dstl,项目名称:baleen,代码行数:25,代码来源:FileTest.java

示例12: beforeTest

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Override
public void beforeTest() throws UIMAException {
    super.beforeTest();

    final ExternalResourceDescription tokensDesc = ExternalResourceFactory.createExternalResourceDescription(
            "lexica",
            ClearNlpLexica.class);

    final AnalysisEngineDescription desc = AnalysisEngineFactory.createEngineDescription(ClearNlpTokeniser.class,
            "lexica",
            tokensDesc);

    ae = AnalysisEngineFactory.createEngine(desc);
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:15,代码来源:ClearNLPTokeniserTest.java

示例13: createAnalysisEngines

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
@Override
protected AnalysisEngine[] createAnalysisEngines() throws ResourceInitializationException {

    final ExternalResourceDescription parserChunkingDesc = ExternalResourceFactory
            .createExternalResourceDescription("parserChunking", SharedOpenNLPModel.class);

    // Add in the OpenNLP implementation too, as its a prerequisite
    // (in theory we should test OpenNLPParser in isolation, but in practise
    // it as this as a
    // dependency
    // so better test they work together)

    final ExternalResourceDescription tokensDesc = ExternalResourceFactory.createExternalResourceDescription(
            "tokens",
            SharedOpenNLPModel.class);
    final ExternalResourceDescription sentencesDesc = ExternalResourceFactory
            .createExternalResourceDescription("sentences", SharedOpenNLPModel.class);
    final ExternalResourceDescription posDesc = ExternalResourceFactory.createExternalResourceDescription("posTags",
            SharedOpenNLPModel.class);
    final ExternalResourceDescription chunksDesc = ExternalResourceFactory
            .createExternalResourceDescription("phraseChunks", SharedOpenNLPModel.class);

    AnalysisEngineFactory.createEngineDescription();

    return asArray(
            createAnalysisEngine(OpenNLP.class, "tokens", tokensDesc, "sentences", sentencesDesc, "posTags",
                    posDesc, "phraseChunks", chunksDesc),
            createAnalysisEngine(OpenNLPParser.class, "parserChunking", parserChunkingDesc));

}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:31,代码来源:OpenNLPParserTest.java

示例14: runFeatureExtractor

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
private File runFeatureExtractor(File luceneFolder)
    throws Exception
{
    File outputPath = folder.newFolder();
    
    Object[] parameters = new Object[] {
            TokenContext.PARAM_TARGET_INDEX, "1",
            TokenContext.PARAM_UNIQUE_EXTRACTOR_NAME,
            EXTRACTOR_NAME, TokenContext.PARAM_SOURCE_LOCATION, luceneFolder.toString(),
            LuceneUniGramMetaCollector.PARAM_TARGET_LOCATION, luceneFolder.toString()
            };

    ExternalResourceDescription featureExtractor = ExternalResourceFactory
            .createExternalResourceDescription(TokenContext.class, parameters);
    List<ExternalResourceDescription> fes = new ArrayList<>();
    fes.add(featureExtractor);

    CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription(
            TestReaderSingleLabel.class, TestReaderSingleLabel.PARAM_LANGUAGE, "en",
            TestReaderSingleLabel.PARAM_SOURCE_LOCATION, "src/test/resources/text/input.txt",
            TestReaderSingleLabel.PARAM_SUPPRESS_DOCUMENT_ANNOTATION, true);

    AnalysisEngineDescription segmenter = AnalysisEngineFactory
            .createEngineDescription(BreakIteratorSegmenter.class);

    AnalysisEngineDescription unitAnno = AnalysisEngineFactory
            .createEngineDescription(EachTokenAsUnitAnnotator.class);

    AnalysisEngineDescription featExtractorConnector = TaskUtils.getFeatureExtractorConnector(
            outputPath.getAbsolutePath(), JsonDataWriter.class.getName(),
            Constants.LM_SINGLE_LABEL, Constants.FM_UNIT, DenseFeatureStore.class.getName(),
            false, false, false, new ArrayList<>(), false, fes);
    
    SimplePipeline.runPipeline(reader, segmenter, unitAnno, featExtractorConnector);

    return outputPath;
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:38,代码来源:LuceneNgramUnitTest.java

示例15: getReader

import org.apache.uima.fit.factory.ExternalResourceFactory; //导入方法依赖的package包/类
public CollectionReaderDescription getReader(String type) throws ResourceInitializationException {
    CollectionReaderDescription reader = null;
    if (type.equals("csv")) {
        reader = CollectionReaderFactory.createReaderDescription(
                NewsleakCsvStreamReader.class, this.typeSystem,
                NewsleakCsvStreamReader.PARAM_DOCUMENT_FILE, this.documentFile,
                NewsleakCsvStreamReader.PARAM_METADATA_FILE, this.metadataFile,
                NewsleakCsvStreamReader.PARAM_INPUTDIR, this.dataDirectory,
                NewsleakCsvStreamReader.PARAM_DEFAULT_LANG, this.defaultLanguage,
                NewsleakCsvStreamReader.PARAM_DEBUG_MAX_DOCS, this.debugMaxDocuments
                );
    } else if (type.equals("hoover")) {
        this.metadataFile = this.hooverTmpMetadata;
        ExternalResourceDescription hooverResource = ExternalResourceFactory.createExternalResourceDescription(
                HooverResource.class, 
                HooverResource.PARAM_METADATA_FILE, this.dataDirectory + File.separator + this.metadataFile,
                HooverResource.PARAM_HOST, this.hooverHost,
                HooverResource.PARAM_CLUSTERNAME, this.hooverClustername,
                HooverResource.PARAM_INDEX, this.hooverIndex,
                HooverResource.PARAM_PORT, this.hooverPort
                );
        reader = CollectionReaderFactory.createReaderDescription(
                HooverElasticsearchReader.class, this.typeSystem,
                HooverElasticsearchReader.RESOURCE_HOOVER, hooverResource,
                HooverElasticsearchReader.PARAM_DEFAULT_LANG, this.defaultLanguage,
                HooverElasticsearchReader.PARAM_DEBUG_MAX_DOCS, this.debugMaxDocuments
                );
    } else {
        this.logger.log(Level.SEVERE, "Unknown reader type: " + type);
        System.exit(1);
    }
    return reader;
}
 
开发者ID:tudarmstadt-lt,项目名称:newsleak-frontend,代码行数:34,代码来源:InformationExtraction2Postgres.java


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