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


Java UIMAFramework.produceAnalysisEngine方法代码示例

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


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

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

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

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

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

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

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

示例7: setup

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
    if (cas != null)
        return;
    String path = new File(".").getCanonicalPath();
    if(!path.endsWith("client")) {
        rootDirectory = "client/";
        inDir = new File(rootDirectory + "src/test/resources/inputDirectory");
    }
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(
            SampleService.simpleServiceDefinition().getAnalysisEngineDescription()
    );
    cas = ae.newCAS();
    cas.setDocumentText("012345678901234567890123456789");
    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,代码行数:22,代码来源:SimpleCsvListenerTest.java

示例8: testRunSimpleCsvListenerTest

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
@Test
public void testRunSimpleCsvListenerTest() throws Exception {
    StringWriter writer = new StringWriter();
    SimpleCsvListener listener = new SimpleCsvListener(writer);
    assertNotNull(listener);
    listener.setInputType(Token.class.getCanonicalName());
    assertTrue(listener.getInputType()[0].equals(Token.class.getCanonicalName()));
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(
            SampleService.simpleServiceDefinition().getAnalysisEngineDescription()
    );
    RandomStringCollectionReader reader = new RandomStringCollectionReader(10).setMaxStringLength(16);
    int counter = 0;
    ProcessTrace pTrace = null;
    while(reader.hasNext()) {
        CAS cas = ae.newCAS();
        reader.getNext(cas);
        listener.onBeforeMessageSend(new UimaASProcessStatusImpl(new ProcessTrace_impl(), cas, "" + counter++));
        pTrace = ae.process(cas);
        listener.entityProcessComplete(cas, new EntityProcessStatusImpl(pTrace));
    }
    listener.collectionProcessComplete(new EntityProcessStatusImpl(pTrace));
    assertEquals(counter, listener.getNumReceived());
    assertTrue(StringUtils.isNotBlank(writer.toString()));
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:25,代码来源:SimpleCsvListenerTest.java

示例9: 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 {
    String path = new File(".").getCanonicalPath();
    if (!path.endsWith("client")) {
        rootDirectory = "client/";
    }

    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);
    Class.forName(dbConnectionInfo.getDriver()).newInstance();

    conn = DriverManager.getConnection(dbConnectionInfo.getUrl(), dbConnectionInfo.getUsername(), dbConnectionInfo.getPassword());
    conn.createStatement().execute("CREATE TABLE DUMMY_TABLE ( col1 varchar(100), col2 varchar(100), col3 varchar(100))");
}
 
开发者ID:department-of-veterans-affairs,项目名称:Leo,代码行数:29,代码来源:BaseDatabaseListenerTest.java

示例10: createAnalysisEngine

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
@Deprecated
public static AnalysisEngine createAnalysisEngine(@Nullable UimaContext c,
		Map<String, Object> tuples, Class<? extends AnalysisComponent> comp)
		throws ResourceInitializationException {
	Object[] params = getParamList(tuples);
	AnalysisEngineDescription aeDesc = AnalysisEngineFactory
			.createPrimitiveDescription(comp, params);
	StringBuilder sb = new StringBuilder(comp.getSimpleName());
	if (params.length > 0) {
		appendMethodSignature(sb, tuples);
	}
	aeDesc.getAnalysisEngineMetaData().setName(sb.toString());
	System.out.println("\t- " + sb.toString());
	AnalysisEngine ae;
	if (c != null) {
		ae = UIMAFramework.produceAnalysisEngine(aeDesc,
				((UimaContextAdmin) c).getResourceManager(), null);
	} else {
		ae = UIMAFramework.produceAnalysisEngine(aeDesc);
	}
	return ae;
}
 
开发者ID:oaqa,项目名称:bagpipes-old,代码行数:23,代码来源:ExperimentBuilder.java

示例11: main

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  String dictionaryResourceName = DICTIONARY_RESOURCE_NAME;
  if (args.length == 2) {
    // do nothing
  } else if (args.length == 3) {
    dictionaryResourceName = args[2];
  } else {
    usage();
    System.exit(17);
  }
  AnalysisEngineDescription conceptMapperDesc = UIMAFramework.getXMLParser()
          .parseAnalysisEngineDescription(new XMLInputSource(args[0]));
  AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(conceptMapperDesc);
  DictionaryResource_impl dict = (DictionaryResource_impl) ae.getResourceManager().getResource(
  		dictionaryResourceName);

  FileOutputStream output = new FileOutputStream(args[1]);
  dict.serializeEntries(output);
  output.close();
  ae.destroy();
  // for some reason JVM won't exit normally,
  // probably because CPM threads are alive?
  System.exit(0);
}
 
开发者ID:NUNLP,项目名称:uima-components,代码行数:25,代码来源:CompileDictionary.java

示例12: getAnalysisEngine

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
/**
 * Returns a new UIMA Analysis Engine (AE). This method ensures that only
 * one instance of an AE is created.
 * 
 * <p>
 * An Analysis Engine is a component responsible for analyzing unstructured
 * information, discovering and representing semantic content. Unstructured
 * information includes, but is not restricted to, text documents.
 * </p>
 * 
 * @param aeDescriptor
 *            pathname for XML file including an AnalysisEngineDescription
 *            that contains all of the information needed to instantiate and
 *            use an AnalysisEngine.
 * @param umlsUser
 *            UMLS username for NLM database
 * @param umlsPass
 *            UMLS password for NLM database
 * @return an Analysis Engine for analyzing unstructured information.
 * @throws IOException
 *             if any I/O error occurs.
 * @throws InvalidXMLException
 *             if the input XML is not valid or does not specify a valid
 *             ResourceSpecifier.
 * @throws ResourceInitializationException
 *             if a failure occurred during production of the resource.
 * @throws URISyntaxException
 *             if URL of the resource is not formatted strictly according to
 *             to RFC2396 and cannot be converted to a URI.
 */
public static AnalysisEngine getAnalysisEngine(String aeDescriptor,
		String umlsUser, String umlsPass) throws IOException,
		InvalidXMLException, ResourceInitializationException,
		URISyntaxException {
	// UMLS user ID and password.
	String aeDescriptorPath = CTAKESUtils.class.getResource(aeDescriptor)
			.toURI().getPath();

	// get Resource Specifier from XML
	XMLInputSource aeIputSource = new XMLInputSource(aeDescriptorPath);
	ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser()
			.parseResourceSpecifier(aeIputSource);

	// UMLS user ID and password
	if ((umlsUser != null) && (!umlsUser.isEmpty()) && (umlsPass != null)
			&& (!umlsPass.isEmpty())) {
		/*
		 * It is highly recommended that you change UMLS credentials in the
		 * XML configuration file instead of giving user and password using
		 * CTAKESConfig.
		 */
		System.setProperty(CTAKES_UMLS_USER, umlsUser);
		System.setProperty(CTAKES_UMLS_PASS, umlsPass);
	}

	// create AE
	AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);

	return ae;
}
 
开发者ID:theyiwenliu,项目名称:CTAKESContentToMetadataHandler,代码行数:61,代码来源:CTAKESUtils.java

示例13: getAnalysisEngine

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
/**
 * Returns a new UIMA Analysis Engine (AE). This method ensures that only
 * one instance of an AE is created.
 * 
 * <p>
 * An Analysis Engine is a component responsible for analyzing unstructured
 * information, discovering and representing semantic content. Unstructured
 * information includes, but is not restricted to, text documents.
 * </p>
 * 
 * @param aeDescriptor
 *            pathname for XML file including an AnalysisEngineDescription
 *            that contains all of the information needed to instantiate and
 *            use an AnalysisEngine.
 * @param umlsUser
 *            UMLS username for NLM database
 * @param umlsPass
 *            UMLS password for NLM database
 * @return an Analysis Engine for analyzing unstructured information.
 * @throws IOException
 *             if any I/O error occurs.
 * @throws InvalidXMLException
 *             if the input XML is not valid or does not specify a valid
 *             ResourceSpecifier.
 * @throws ResourceInitializationException
 *             if a failure occurred during production of the resource.
 * @throws URISyntaxException
 *             if URL of the resource is not formatted strictly according to
 *             to RFC2396 and cannot be converted to a URI.
 */
public static AnalysisEngine getAnalysisEngine(String aeDescriptor,
		String umlsUser, String umlsPass) throws IOException,
		InvalidXMLException, ResourceInitializationException,
		URISyntaxException {
	if (ae == null) {
		// UMLS user ID and password.
		String aeDescriptorPath = CTAKESUtils.class
				.getResource(aeDescriptor).toURI().getPath();

		// get Resource Specifier from XML
		XMLInputSource aeIputSource = new XMLInputSource(aeDescriptorPath);
		ResourceSpecifier aeSpecifier = UIMAFramework.getXMLParser()
				.parseResourceSpecifier(aeIputSource);

		// UMLS user ID and password
		if ((umlsUser != null) && (!umlsUser.isEmpty())
				&& (umlsPass != null) && (!umlsPass.isEmpty())) {
			/*
			 * It is highly recommended that you change UMLS credentials in
			 * the XML configuration file instead of giving user and
			 * password using CTAKESConfig.
			 */
			System.setProperty(CTAKES_UMLS_USER, umlsUser);
			System.setProperty(CTAKES_UMLS_PASS, umlsPass);
		}

		// create AE
		ae = UIMAFramework.produceAnalysisEngine(aeSpecifier);
	}
	return ae;
}
 
开发者ID:giuseppetotaro,项目名称:CTAKESContentHadler,代码行数:62,代码来源:CTAKESUtils.java

示例14: main

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

		Stopwatch sw = Stopwatch.createUnstarted();
		long last = 0;
		for(Boolean allowOverlappingOccurrence:Booleans.asList(false, true)) {
			for(Boolean useCache:Booleans.asList(false, true)) {
				AnalysisEngineDescription aeDesc = createAE(allowOverlappingOccurrence, useCache);
				AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeDesc);
				System.out.println("--------------------------------");
				System.out.println("allowOverlappingOccurrence: " + allowOverlappingOccurrence);
				System.out.println("useCache:                   " + useCache);
				for(int i= 0; i < NB_ITERATIONS; i++) {
					JCas cas = createCAS();
					sw.start();
					ae.process(cas);
					sw.stop();
					
					System.out.format("%4d. %10d %10d - words: %d terms: %d %n", 
							i+1, 
							sw.elapsed(TimeUnit.MILLISECONDS),
							sw.elapsed(TimeUnit.MILLISECONDS) - last,
							count(cas, "WordAnnotation"),
							count(cas, "TermOccAnnotation")
							);
					last = sw.elapsed(TimeUnit.MILLISECONDS);
					
				}
				
			}	
		}
	}
 
开发者ID:nantesnlp,项目名称:uima-tokens-regex,代码行数:32,代码来源:Benchmark.java

示例15: setup

import org.apache.uima.UIMAFramework; //导入方法依赖的package包/类
@Before
public void setup() throws UIMAException, MalformedURLException {
AnalysisEngineDescription ae = AnalysisEngineFactory.createEngineDescription(RecogEngine.class);
	ExternalResourceDescription mwtRulesResources = ExternalResourceFactory.createExternalResourceDescription(
			RegexListResource.class,
			AutomatonTests.RESOURCES.resolve("regex-files/multiple-type-use-case.regex").toUri().toURL().toString()
	);
	ExternalResourceFactory.bindResource(
			ae,
			TokenRegexAE.TOKEN_REGEX_RULES,
			mwtRulesResources);
	engine = UIMAFramework.produceAnalysisEngine(ae);
	setupCas();
}
 
开发者ID:nantesnlp,项目名称:uima-tokens-regex,代码行数:15,代码来源:MultitypeFunctionalSpec.java


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