Java Code Examples for org.apache.uima.UIMAFramework#newUimaContext()
The following examples show how to use
org.apache.uima.UIMAFramework#newUimaContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FixedFlowControllerTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { analysisEngineMetaDataMap = new HashMap<>(); AnalysisEngineMetaData delegateMd = new AnalysisEngineMetaData_impl(); delegateMd.setOperationalProperties(new OperationalProperties_impl()); analysisEngineMetaDataMap.put("key1", delegateMd); analysisEngineMetaDataMap.put("key2", delegateMd); analysisEngineMetaDataMap.put("key3", delegateMd); AnalysisEngineMetaData aggregateMd = new AnalysisEngineMetaData_impl(); FixedFlow fixedFlow = new FixedFlow_impl(); fixedFlow.setFixedFlow(new String[]{"key1", "key2", "key3"}); aggregateMd.setFlowConstraints(fixedFlow); OperationalProperties opProps = new OperationalProperties_impl(); aggregateMd.setOperationalProperties(opProps); UimaContextAdmin rootContext = UIMAFramework.newUimaContext( UIMAFramework.getLogger(), UIMAFramework.newDefaultResourceManager(), UIMAFramework.newConfigurationManager()); Map<String, String> aSofaMappings = Collections.emptyMap(); FlowControllerContext fcContext = new FlowControllerContext_impl( rootContext, "_FlowController", aSofaMappings, analysisEngineMetaDataMap, aggregateMd); fixedFlowController = new FixedFlowController(); fixedFlowController.initialize(fcContext); }
Example 2
Source File: CPEFactory.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Create a new CPEFactory on which we will later call parse(String) to parse a CPE descriptor. * * @param aResourceManager the a resource manager */ public CPEFactory(ResourceManager aResourceManager) { if (aResourceManager == null) { aResourceManager = UIMAFramework.newDefaultResourceManager(); } uimaContext = UIMAFramework.newUimaContext(UIMAFramework.getLogger(), aResourceManager, UIMAFramework.newConfigurationManager()); }
Example 3
Source File: SofaTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testGetViewIterator() throws Exception { this.cas.reset(); CAS view1 = this.cas.createView("View1"); CAS view2 = this.cas.createView("View2"); checkViewsExist(this.cas.getViewIterator(), cas, view1, view2); CAS viewE1 = this.cas.createView("EnglishDocument"); CAS viewE2 = this.cas.createView("EnglishDocument.2"); checkViewsExist(this.cas.getViewIterator("EnglishDocument"), viewE1, viewE2); //try with Sofa mappings UimaContextAdmin rootCtxt = UIMAFramework.newUimaContext( UIMAFramework.getLogger(), UIMAFramework.newDefaultResourceManager(), UIMAFramework.newConfigurationManager()); Map<String, String> sofamap = new HashMap<>(); sofamap.put("SourceDocument","EnglishDocument"); UimaContextAdmin childCtxt = rootCtxt.createChild("test", sofamap); cas.setCurrentComponentInfo(childCtxt.getComponentInfo()); checkViewsExist(this.cas.getViewIterator("SourceDocument"), viewE1, viewE2); this.cas.setCurrentComponentInfo(null); //repeat with JCas this.cas.reset(); JCas jcas = this.cas.getJCas(); JCas jview1 = jcas.createView("View1"); JCas jview2 = jcas.createView("View2"); checkViewsExist(jcas.getViewIterator(), jcas, jview1, jview2); JCas jviewE1 = jcas.createView("EnglishDocument"); JCas jviewE2 = jcas.createView("EnglishDocument.2"); checkViewsExist(jcas.getViewIterator("EnglishDocument"), jviewE1, jviewE2); //try with Sofa mappings cas.setCurrentComponentInfo(childCtxt.getComponentInfo()); checkViewsExist(jcas.getViewIterator("SourceDocument"), jviewE1, jviewE2); }
Example 4
Source File: AnalysisEngineDescription_implTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void testMulticoreInitialize() throws Exception { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); ConfigurationManager configManager = UIMAFramework.newConfigurationManager(); Logger logger = UIMAFramework.getLogger(this.getClass()); logger.setResourceManager(resourceManager); UimaContext uimaContext = UIMAFramework.newUimaContext(logger, resourceManager, configManager); final Map<String, Object> p = new HashMap<>(); p.put(UIMAFramework.CAS_INITIAL_HEAP_SIZE, 200); p.put(Resource.PARAM_CONFIG_MANAGER, configManager); p.put(Resource.PARAM_RESOURCE_MANAGER, UIMAFramework.newDefaultResourceManager()); p.put(Resource.PARAM_UIMA_CONTEXT, uimaContext); int numberOfThreads = Math.min(50, Misc.numberOfCores * 5); final AnalysisEngine[] aes = new AnalysisEngine[numberOfThreads]; System.out.format("test multicore initialize with %d threads%n", numberOfThreads); MultiThreadUtils.Run2isb run2isb = new MultiThreadUtils.Run2isb() { public void call(int i, int r, StringBuilder sb) throws Exception { Random random = new Random(); for (int j = 0; j < 2; j++) { aes[i] = UIMAFramework.produceAnalysisEngine(primitiveDesc, p); // System.out.println(sb.toString()); // System.out.print('.'); if ((i % 2) == 0) { Thread.sleep(0, random.nextInt(2000)); } } } }; MultiThreadUtils.tstMultiThread("MultiCoreInitialize", numberOfThreads, 100, run2isb, MultiThreadUtils.emptyReset); assertTrue(!aes[0].equals(aes[1])); run2isb = new MultiThreadUtils.Run2isb() { public void call(int i, int r, StringBuilder sb) throws Exception { Random random = new Random(); for (int j = 0; j < 2; j++) { aes[i] = UIMAFramework.produceAnalysisEngine(aggregateDesc, p); // System.out.println(sb.toString()); // System.out.print('.'); if ((i % 2) == 0) { Thread.sleep(0, random.nextInt(5000)); } } } }; MultiThreadUtils.tstMultiThread("MultiCoreInitialize", numberOfThreads, 100, run2isb, MultiThreadUtils.emptyReset); assertTrue(!aes[0].equals(aes[1])); // System.out.println(""); }