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


Java UIMAFramework类代码示例

本文整理汇总了Java中org.apache.uima.UIMAFramework的典型用法代码示例。如果您正苦于以下问题:Java UIMAFramework类的具体用法?Java UIMAFramework怎么用?Java UIMAFramework使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        long start = System.currentTimeMillis();
        long now = 0;
        String modelDirectory = "src/test/resources/model/";
        String language = "en";
        File nerTrain = new File("src/main/resources/ner/ner_eng.train");
        File nerTest = new File("src/main/resources/ner/ner_eng.dev");
        new File(modelDirectory).mkdirs();
        now = System.currentTimeMillis();
        UIMAFramework.getLogger().log(Level.INFO, "Starting 'writing model' Time: " + (now - start) + "ms");
        writeModel(nerTrain, modelDirectory, language);
        now = System.currentTimeMillis();
        UIMAFramework.getLogger().log(Level.INFO, "Starting 'training model' Time: " + (now - start) + "ms");
        trainModel(modelDirectory);
        now = System.currentTimeMillis();
        UIMAFramework.getLogger().log(Level.INFO, "Starting 'classifying model' Time: " + (now - start) + "ms");
        classifyTestFile(modelDirectory, nerTest, language);
        now = System.currentTimeMillis();
        UIMAFramework.getLogger().log(Level.INFO, "All done! Time: " + (now - start) + "ms");
    }
 
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:22,代码来源:ExecuteNER.java

示例2: initialize

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
  boolean ret = super.initialize(aSpecifier, aAdditionalParams);
  // initialize delegate
  CustomResourceSpecifier delegateResourceSpecifier = new CustomResourceSpecifier_impl();
  delegateResourceSpecifier.setResourceClassName(delegateClass.getCanonicalName());
  delegate = delegateClass.cast(UIMAFramework.produceResource(delegateClass,
          delegateResourceSpecifier, aAdditionalParams));
  // initialize mapdb
  File file = new File((String) getParameterValue("db-file"));
  db = DBMaker.newFileDB(file).compressionEnable().commitFileSyncDisable().cacheSize(128)
          .closeOnJvmShutdown().make();
  String map = (String) getParameterValue("map-name");
  id2synonyms = db.getHashMap(map);
  return ret;
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:18,代码来源:CachedUtsSynonymExpansionProvider.java

示例3: initialize

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Override
public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams)
        throws ResourceInitializationException {
  boolean ret = super.initialize(aSpecifier, aAdditionalParams);
  // initialize delegate
  CustomResourceSpecifier delegateResourceSpecifier = new CustomResourceSpecifier_impl();
  delegateResourceSpecifier.setResourceClassName(delegateClass.getCanonicalName());
  delegate = delegateClass.cast(UIMAFramework.produceResource(delegateClass,
          delegateResourceSpecifier, aAdditionalParams));
  // initialize mapdb
  File file = new File((String) getParameterValue("db-file"));
  db = DBMaker.newFileDB(file).compressionEnable().commitFileSyncDisable().cacheSize(128)
          .closeOnJvmShutdown().make();
  String map = (String) getParameterValue("map-name");
  string2concept = db.getHashMap(map);
  return ret;
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:18,代码来源:CachedUtsConceptSearchProvider.java

示例4: main

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	// A collection reader that reads XMIs
	CollectionReader reader = CollectionReaderFactory.createReader(XReader.class, null, XReader.PARAM_ROOT_FILE,
			args[0]);

	// The pipeline of annotators
	AggregateBuilder builder = new AggregateBuilder();

	// other annotators, if needed
	builder.add(UIMAFramework.getXMLParser().parseAnalysisEngineDescription(
			new XMLInputSource("src/main/resources/org/ie4opendata/octroy/SimpleFrenchTokenAndSentenceAnnotator.xml")));

	// Use this to get the parameters for the descriptor
	//System.out.println(ReasonAnnotator.getClassifierDescription("org/ie4opendata/octroy/reason/model.jar"));
	//System.exit(0);
	// The reason classifier annotator, configured to write training data
	builder.add(ReasonAnnotator.getWriterDescription("src/main/resources/org/ie4opendata/octroy/reason"));

	// Run the pipeline of annotators on each of the CASes produced by the reader
	SimplePipeline.runPipeline(reader, builder.createAggregateDescription());

	// Train a classifier on the training data, and package it into a .jar file
	Train.main("src/main/resources/org/ie4opendata/octroy/reason");
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:25,代码来源:ReasonTrainer.java

示例5: main

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
public static void main(String[] args) throws IOException, UIMAException,
        CpeDescriptorException {
    if (args.length != 1) {
        System.err.println("Usage: <cpeDescriptorPath>");
        return;
    }
    String cpeDescPath = args[0];

    XMLInputSource cpeDescSource = new XMLInputSource(cpeDescPath);
    CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(cpeDescSource);

    // produce
    CollectionProcessingEngine cpe = UIMAFramework
            .produceCollectionProcessingEngine(cpeDesc);
    cpe.addStatusCallbackListener(new ReportingStatusCallbackListener(cpe));

    // run
    cpe.process();
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:20,代码来源:CpeLauncher.java

示例6: test

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Test
public void test() throws Exception {
    TypeSystemDescription tsd = TypeSystemDescriptionFactory
            .createTypeSystemDescription("desc.types.test-TypeSystem");

    CollectionReaderDescription colReaderDesc = CollectionReaderFactory.createReaderDescription(
            XmiCollectionReader.class, tsd,
            XmiCollectionReader.PARAM_INPUTDIR, inputFileXMIDir);

    // configure AE
    XMLInputSource aeDescInput = new XMLInputSource(U2BAggregateDesc);
    AnalysisEngineDescription aeDesc = UIMAFramework.getXMLParser()
            .parseAnalysisEngineDescription(aeDescInput);

    SimplePipeline.runPipeline(colReaderDesc, aeDesc);
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:17,代码来源:U2BTest.java

示例7: createCollectionReader

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
/**
 * Create a new Collection Reader
 */
private CollectionReader createCollectionReader() throws BaleenException{
	String className = BuilderUtils.getClassNameFromConfig(collectionReaderConfig);
	Map<String, Object> params = BuilderUtils.flattenConfig(null, BuilderUtils.getParamsFromConfig(collectionReaderConfig));

	if (className == null || className.isEmpty()) {
		throw new InvalidParameterException("Collection Reader class not specified");
	}

	Map<String, Object> nonNullParams = params;
	if (nonNullParams == null) {
		nonNullParams = Collections.emptyMap();
	}

	try {
		Class<? extends CollectionReader> clazz = BuilderUtils.getClassFromString(className, getDefaultReaderPackage());
		Map<String, ExternalResourceDescription> crResources = getOrCreateResources(clazz);
		Object[] paramArr = BuilderUtils.mergeAndExtractParams(globalConfig, nonNullParams, ignoreParams, crResources);

		return UIMAFramework.produceCollectionReader(CollectionReaderFactory.createReaderDescription(clazz, paramArr), resourceManager, null);
	} catch (ResourceInitializationException e) {
		throw new BaleenException("Couldn't initialize collection reader", e);
	}
}
 
开发者ID:dstl,项目名称:baleen,代码行数:27,代码来源:PipelineBuilder.java

示例8: createAE

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
private AnalysisEngine createAE(String automataRule)
		throws Exception {
	Path templatePath = Paths.get("src", "test", "resources", "template-mwt-rules.regex");
	File mwtRulesFile = root.newFile();
	String template = TestUtils.readFile(templatePath, Charsets.UTF_8);
	String mwtText = template.replace("RULE_PATTERN", automataRule);
	TestUtils.writeToFile(mwtRulesFile, Charsets.UTF_8, mwtText);
	AnalysisEngineDescription ae = AnalysisEngineFactory.createEngineDescription(RecogEngine.class);
	ExternalResourceDescription	mwtRulesResources = ExternalResourceFactory.createExternalResourceDescription(
			RegexListResource.class,
			mwtRulesFile.toURI().toURL().toString()
		);
	ExternalResourceFactory.bindResource(
			ae, 
			TokenRegexAE.TOKEN_REGEX_RULES, 
			mwtRulesResources);
	AnalysisEngine engine = UIMAFramework.produceAnalysisEngine(ae);
	return engine;
}
 
开发者ID:nantesnlp,项目名称:uima-tokens-regex,代码行数:20,代码来源:OnCasFunctionalSpec.java

示例9: testConTextAnnotator

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Test
public void testConTextAnnotator() throws Exception {
    //Get the UIMA analysis engine
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(conTextPipeline.getAnalysisEngineDescription());

    //Setup the CAS and process the document text
    String testDoc = FileUtils.readFileToString(new File("src/test/resources/data-001.txt"));
    JCas jcas = ae.newJCas();
    jcas.setDocumentText(testDoc);
    ae.process(jcas);

    Collection<Context> conTexts = AnnotationLibrarian.getAllAnnotationsOfType(jcas, Context.type);
    /**
     * TODO CREATE ASSESSMENTS ON FEATURE VALUES AND NUMBER OF ANNOTATIONS
     */
    for(Context context : conTexts) {
        System.out.println(context.getCoveredText());
    }
}
 
开发者ID:Blulab-Utah,项目名称:ConText,代码行数:20,代码来源:ConTextAnnotatorTest.java

示例10: init

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
/**
 * Initialize the client engine and application context.
 *
 * @param uabs Listeners that will catch Service callback events
 * @throws Exception if any data required for the client is missing.
 */
protected void init(UimaAsBaseCallbackListener... uabs) throws Exception {
    if (uabs != null) {
        for (UimaAsBaseCallbackListener uab : uabs) {
            this.addUABListener(uab);
        }//for
    }//if
    validateData();

    //Add Broker URL
    if (this.mBrokerURL != null)
        mAppCtx.put(UimaAsynchronousEngine.ServerUri, this.mBrokerURL);
    //Add endpoint
    if (this.mEndpoint != null)
        mAppCtx.put(UimaAsynchronousEngine.ENDPOINT, this.mEndpoint);
    //Add timeouts in milliseconds
    mAppCtx.put(UimaAsynchronousEngine.Timeout, mCCTimeout * 1000);
    mAppCtx.put(UimaAsynchronousEngine.GetMetaTimeout, mInitTimeout * 1000);
    mAppCtx.put(UimaAsynchronousEngine.CpcTimeout, mCCTimeout * 1000);
    //Add Cas Pool Size
    mAppCtx.put(UimaAsynchronousEngine.CasPoolSize, mCasPoolSize);
    //Add FS heap size
    mAppCtx.put(UIMAFramework.CAS_INITIAL_HEAP_SIZE, Integer.valueOf(mFSHeapSize / 4).toString());
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:30,代码来源:Client.java

示例11: testGetNext

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

示例12: testBatchProcessing

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Test
public void testBatchProcessing() throws Exception{
    BatchDatabaseCollectionReader reader = (BatchDatabaseCollectionReader) new BatchDatabaseCollectionReader(dbConnectionInfo,
                    new DataQueryInformation(query, "note", "id"), MIN_RECORD_NUMBER, TEST_CORPUS_SIZE, BATCH_SIZE)
                    .produceCollectionReader();
    assertNotNull(reader);
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(
            SampleService.simpleServiceDefinition()
                         .getAnalysisEngineDescription()
    );
    CAS mockCas;
    FSIterator<AnnotationFS> csiIterator;
    CSI csi;
    //Iterate through the collection
    for(int i = 10; i < (TEST_CORPUS_SIZE+10); i++) {
        mockCas = ae.newCAS();
        if(reader.hasNext()) {
            reader.getNext(mockCas);
            csiIterator = mockCas.getAnnotationIndex(mockCas.getTypeSystem().getType(CSI.class.getCanonicalName())).iterator();
            assertTrue(csiIterator.hasNext());
            csi = (CSI) csiIterator.next();
            assertEquals("Expected : " + i + ", but got: " + csi.getID(), csi.getID(), "" + i);
        }
    }
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:26,代码来源:BatchDatabaseCollectionReaderTest.java

示例13: setup

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
/**
 * Setup an in-memory db to test against with a simple schema.
 *
 * @throws Exception
 */
@Before
public void setup() throws Exception {
    if(cas != null)
        return;
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(
            SampleService.simpleServiceDefinition().getAnalysisEngineDescription()
    );
    cas = ae.newCAS();
    cas.setDocumentText("a b c");
    CSI csi = new CSI(cas.getJCas());
    csi.setID("1");
    csi.setBegin(0);
    csi.setEnd(5);
    csi.addToIndexes();
    ae.process(cas);
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:22,代码来源:BaseDatabaseInsertErrorTest.java

示例14: setup

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    if(cas != null)
        return;
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(
            SampleService.simpleServiceDefinition().getAnalysisEngineDescription()
    );
    cas = ae.newCAS();
    cas.setDocumentText("a b c");
    CSI csi = new CSI(cas.getJCas());
    csi.setID("1");
    csi.setBegin(0);
    csi.setEnd(29);
    csi.addToIndexes();
    ae.process(cas);
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:17,代码来源:CSVBaseListenerTest.java

示例15: setup

import org.apache.uima.UIMAFramework; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    String path = new File(".").getCanonicalPath();
    System.out.println(path);
    if (!path.endsWith("client")) {
        rootDirectory = "client/";
        aggregateDescriptor = new File(rootDirectory + "src/test/resources/aggSimpleXmiListenerTest.xml");
        outDir = new File(rootDirectory + "src/test/resources/xmi-listener-test");
        inDir = new File(rootDirectory + "src/test/resources/inputDirectory");
    }
    if (!outDir.exists())
        outDir.mkdir();

    if (ae != null)
        return;
    aggDesc = SampleService.simpleServiceDefinition();
    ae = UIMAFramework.produceAnalysisEngine(
            aggDesc.getAnalysisEngineDescription()
    );
    aggDesc.setDescriptorLocator(aggregateDescriptor.toURI()).toXML();
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:22,代码来源:SimpleXmiListenerTest.java


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