Java Code Examples for org.apache.uima.UIMAFramework#newDefaultResourceManager()
The following examples show how to use
org.apache.uima.UIMAFramework#newDefaultResourceManager() .
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: Jg.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Creates the resource manager. * * @return the resource manager */ public ResourceManager createResourceManager() { ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager(); if (classPath != null && classPath.trim().length() > 0) { try { resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true); } catch (MalformedURLException e1) { error.newError(IError.ERROR, getString("Internal Error", null), e1); } } else { resourceManager.setExtensionClassLoader(this.getClass().getClassLoader(), true); } return resourceManager; }
Example 2
Source File: UIMAClassLoaderTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testSimpleRsrcMgrCLassLoaderCreation() throws Exception { ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager(); assertNull(rsrcMgr.getExtensionClassLoader()); rsrcMgr.setExtensionClassPath("../this/is/a/simple/test.jar", false); ClassLoader cl = rsrcMgr.getExtensionClassLoader(); assertNotNull(cl); //assertTrue(cl != cl.getClassLoadingLock("Aclass")); Class classOfLoader = cl.getClass().getSuperclass(); while (!(classOfLoader.getName().equals("java.lang.ClassLoader"))) { classOfLoader = classOfLoader.getSuperclass(); } if (!Misc.isJava9ea) { // skip for java 9 Method m = classOfLoader.getDeclaredMethod("getClassLoadingLock", String.class); m.setAccessible(true); Object o = m.invoke(cl, "someString"); Object o2 = m.invoke(cl, "s2"); assertTrue(o != o2); assertTrue(cl != o); } }
Example 3
Source File: ResourceManager_implTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testOverrides() throws Exception { try { final String TEST_DATAPATH = JUnitExtension.getFile("AnnotatorContextTest").getPath(); File descFile = JUnitExtension.getFile("ResourceManagerImplTest/ResourceTestAggregate.xml"); AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(descFile)); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); resMgr.setDataPath(TEST_DATAPATH); UIMAFramework.produceAnalysisEngine(desc, resMgr, null); URL url = resMgr.getResourceURL("/Annotator1/TestFileResource"); assertTrue(url.toString().endsWith("testDataFile2.dat")); } catch (Exception e) { JUnitExtension.handleException(e); } }
Example 4
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 5
Source File: PearCasPoolTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Create multiple processors which have to process multiple documents * * @throws Exception - */ public void testCasPool() throws Exception { ResourceManager rm = UIMAFramework.newDefaultResourceManager(); // check temporary working directory if (this.pearInstallDir == null) throw new FileNotFoundException("PEAR install directory not found"); // get pear files to install // relative resolved using class loader File pearFile = JUnitExtension.getFile("pearTests/pearForCPMtest.pear"); Assert.assertNotNull(pearFile); // Install PEAR packages installedPear = PackageInstaller.installPackage(this.pearInstallDir, pearFile, false); Assert.assertNotNull(installedPear); core(10, 2, 3, null); core(10, 2, 2, null); core(10, 3, 3, null); core(10, 3, 4, null); core(10, 3, 5, null); core(10, 4, 4, null); core(10, 4, 5, null); core(10, 2, 3, rm); core(10, 2, 2, rm); core(10, 3, 3, rm); core(10, 3, 4, rm); core(10, 3, 5, rm); core(10, 4, 4, rm); core(10, 4, 5, rm); System.out.println(""); //final new line }
Example 6
Source File: CpeImportTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Test a CPE descriptor using import by name and requiring data patht o be set */ public void testImportsWithDataPath() throws Exception { CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription( new XMLInputSource(JUnitExtension.getFile("CollectionProcessingEngineImplTest/CpeImportDataPathTest.xml"))); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); File dataPathDir = JUnitExtension.getFile("CollectionProcessingEngineImplTest/imports"); resMgr.setDataPath(dataPathDir.getAbsolutePath()); CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, resMgr, null); TestStatusCallbackListener listener = new TestStatusCallbackListener(); cpe.addStatusCallbackListener(listener); cpe.process(); // wait until CPE has finished while (!listener.isFinished()) { Thread.sleep(5); } // check that components were called final int documentCount = 1000; //this is the # of documents produced by the test CollectionReader Assert.assertEquals("StatusCallbackListener", documentCount, listener .getEntityProcessCompleteCount()); Assert.assertEquals("CasConsumer process Count", documentCount, FunctionErrorStore .getCasConsumerProcessCount()); Assert.assertEquals("Annotator process count", documentCount, FunctionErrorStore .getAnnotatorProcessCount()); Assert.assertEquals("Collection reader getNext count", documentCount, FunctionErrorStore .getCollectionReaderGetNextCount()); }
Example 7
Source File: AnalysisEngineDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public Map<String, ResourceSpecifier> getAllComponentSpecifiers(ResourceManager aResourceManager) throws InvalidXMLException { if (aResourceManager == null) { aResourceManager = UIMAFramework.newDefaultResourceManager(); } resolveImports(aResourceManager); Map<String, ResourceSpecifier> map = new LinkedHashMap<>(mDelegateAnalysisEngineSpecifiers); if (getFlowControllerDeclaration() != null) { map.put(getFlowControllerDeclaration().getKey(), getFlowControllerDeclaration() .getSpecifier()); } return Collections.unmodifiableMap(map); }
Example 8
Source File: CasCreationUtilsTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void testCreateCasCollectionPropertiesResourceManager() throws Exception { try { // parse an AE descriptor File taeDescriptorWithImport = JUnitExtension .getFile("CasCreationUtilsTest/TaeWithImports.xml"); AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(taeDescriptorWithImport)); // create Resource Manager & set data path - necessary to resolve imports ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); String pathSep = System.getProperty("path.separator"); resMgr.setDataPath(JUnitExtension.getFile("TypeSystemDescriptionImplTest/dataPathDir") .getAbsolutePath() + pathSep + JUnitExtension.getFile("TypePrioritiesImplTest/dataPathDir").getAbsolutePath() + pathSep + JUnitExtension.getFile("FsIndexCollectionImplTest/dataPathDir").getAbsolutePath()); // call method ArrayList<AnalysisEngineDescription> descList = new ArrayList<>(); descList.add(desc); CAS cas = CasCreationUtils.createCas(descList, UIMAFramework .getDefaultPerformanceTuningProperties(), resMgr); // check that imports were resolved correctly assertNotNull(cas.getTypeSystem().getType("DocumentStructure")); assertNotNull(cas.getTypeSystem().getType("NamedEntity")); assertNotNull(cas.getTypeSystem().getType("TestType3")); assertNotNull(cas.getIndexRepository().getIndex("TestIndex")); assertNotNull(cas.getIndexRepository().getIndex("ReverseAnnotationIndex")); assertNotNull(cas.getIndexRepository().getIndex("DocumentStructureIndex")); // check of type priority AnnotationFS fs1 = cas.createAnnotation(cas.getTypeSystem().getType("Paragraph"), 0, 1); AnnotationFS fs2 = cas.createAnnotation(cas.getTypeSystem().getType("Sentence"), 0, 1); assertTrue(cas.getAnnotationIndex().compare(fs1, fs2) < 0); } catch (Exception e) { JUnitExtension.handleException(e); } }
Example 9
Source File: InstallationTester.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * returns a valid ResourceManager with the information from the PackageBrowser object. * * @param pkgBrowser * packageBrowser object of an installed PEAR package * * @return a ResourceManager object with the information from the PackageBrowser object. * * @throws IOException passthru */ private static ResourceManager getResourceManager(PackageBrowser pkgBrowser) throws IOException { ResourceManager resourceMgr = UIMAFramework.newDefaultResourceManager(); // set component data path if (pkgBrowser.getComponentDataPath() != null) { resourceMgr.setDataPath(pkgBrowser.getComponentDataPath()); } // set component classpath if (pkgBrowser.buildComponentClassPath() != null) { resourceMgr.setExtensionClassPath(pkgBrowser.buildComponentClassPath(), true); } return resourceMgr; }
Example 10
Source File: PearMergerTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Runs test for org.apache.uima.pear.merger.PMController class by merging 2 sample input PEARs * into the output aggregate PEAR. Then, the output PEAR is installed by using * org.apache.uima.pear.tools.InstallationController, and the installed component is verified by * instantiating the aggregate TAE and creating CAS object. * * @throws Exception - */ public void testPearMerger() throws Exception { // check temporary working directory if (_tempWorkingDir == null) throw new FileNotFoundException("temp directory not found"); // check sample PEAR files File[] inpPearFiles = new File[2]; inpPearFiles[0] = JUnitExtension.getFile(TEST_FOLDER + File.separator + INP_PEAR_1_FILE); if (!inpPearFiles[0].isFile()) throw new FileNotFoundException("sample PEAR 1 not found"); inpPearFiles[1] = JUnitExtension.getFile(TEST_FOLDER + File.separator + INP_PEAR_2_FILE); if (!inpPearFiles[1].isFile()) throw new FileNotFoundException("sample PEAR 2 not found"); // specify output aggregate PEAR file File outPearFile = new File(_tempWorkingDir, OUT_PEAR_ID + ".pear"); // create PMController instance and perform merging operation PMController.setLogFileEnabled(false); PMController pmController = new PMController(inpPearFiles, OUT_PEAR_ID, outPearFile); boolean done = pmController.mergePears(); // check merging results Assert.assertTrue(done); Assert.assertTrue(outPearFile.isFile()); // install the output PEAR file and check the results InstallationController insController = new InstallationController(OUT_PEAR_ID, outPearFile, _tempWorkingDir); InstallationDescriptor insDesc = insController.installComponent(); Assert.assertTrue(insDesc != null); Assert.assertTrue(OUT_PEAR_ID.equals(insDesc.getMainComponentId())); // verify the installed component // customize ResourceManager by adding component CLASSPATH ResourceManager resMngr = UIMAFramework.newDefaultResourceManager(); String compClassPath = InstallationController.buildComponentClassPath(insDesc .getMainComponentRoot(), insDesc, false); // instantiate the aggregate AE resMngr.setExtensionClassPath(compClassPath, true); String compDescFilePath = insDesc.getMainComponentDesc(); XMLParser xmlPaser = UIMAFramework.getXMLParser(); XMLInputSource xmlInput = new XMLInputSource(compDescFilePath); AnalysisEngineDescription aeSpec = xmlPaser.parseAnalysisEngineDescription(xmlInput); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpec, resMngr, null); Assert.assertTrue(ae != null); // create CAS object CAS cas = ae.newCAS(); Assert.assertTrue(cas != null); //process CAS cas.setDocumentText("Sample text for testing"); ae.process(cas); // clean-up the results pmController.cleanUp(); }
Example 11
Source File: ResourceManagerFactory.java From uima-uimafit with Apache License 2.0 | 4 votes |
@Override public ResourceManager newResourceManager() throws ResourceInitializationException { UimaContext activeContext = UimaContextHolder.getContext(); if (activeContext != null) { // If we are already in a UIMA context, then we re-use it. Mind that the JCas cannot // handle switching across more than one classloader. // This can be done since UIMA 2.9.0 and starts being handled in uimaFIT 2.3.0 // See https://issues.apache.org/jira/browse/UIMA-5056 return ((UimaContextAdmin) activeContext).getResourceManager(); } else { // If there is no UIMA context, then we create a new resource manager // UIMA core still does not fall back to the context classloader in all cases. // This was the default behavior until uimaFIT 2.2.0. ResourceManager resMgr; if (Thread.currentThread().getContextClassLoader() != null) { // If the context classloader is set, then we want the resource manager to fallb // back to it. However, it may not reliably do that that unless we explictly pass // null here. See. UIMA-6239. resMgr = new ResourceManager_impl(null); } else { resMgr = UIMAFramework.newDefaultResourceManager(); } // Since UIMA Core version 2.10.3 and 3.0.1 the thread context classloader is taken // into account by the core framework. Thus, we no longer have to explicitly set a // classloader these or more recent versions. (cf. UIMA-5802) short maj = UimaVersion.getMajorVersion(); short min = UimaVersion.getMinorVersion(); short rev = UimaVersion.getBuildRevision(); boolean uimaCoreIgnoresContextClassloader = (maj == 2 && (min < 10 || (min == 10 && rev < 3))) || // version < 2.10.3 (maj == 3 && ((min == 0 && rev < 1))); // version < 3.0.1 if (uimaCoreIgnoresContextClassloader) { try { resMgr.setExtensionClassPath(ClassUtils.getDefaultClassLoader(), "", true); } catch (MalformedURLException e) { throw new ResourceInitializationException(e); } } return resMgr; } }
Example 12
Source File: PearInstallerTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void testPearInstall() throws Exception { // check temporary working directory if (this.tempInstallDir == null) throw new FileNotFoundException("temp directory not found"); // check sample PEAR files //get pear file to install File pearFile = JUnitExtension.getFile("pearTests/DateTime.pear"); Assert.assertNotNull(pearFile); // Install PEAR package PackageBrowser instPear = PackageInstaller.installPackage( this.tempInstallDir, pearFile, true); //check pear PackageBrowser object Assert.assertNotNull(instPear); //check PEAR component ID String componentID = instPear.getInstallationDescriptor().getMainComponentId(); Assert.assertEquals("uima.example.DateTimeAnnotator", componentID); //check PEAR datapath setting //pear file contains (uima.datapath = $main_root/my/test/data/path) File datapath = new File(this.tempInstallDir, "uima.example.DateTimeAnnotator/my/test/data/path"); File pearDatapath = new File(instPear.getComponentDataPath()); Assert.assertEquals(datapath, pearDatapath); // Create resouce manager and set PEAR package classpath ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager(); // Create analysis engine from the installed PEAR package XMLInputSource in = new XMLInputSource(instPear.getComponentPearDescPath()); ResourceSpecifier specifier = UIMAFramework.getXMLParser() .parseResourceSpecifier(in); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine( specifier, rsrcMgr, null); Assert.assertNotNull(ae); // Create a CAS with a sample document text and process the CAS CAS cas = ae.newCAS(); cas.setDocumentText("Sample text to process with a date 05/29/07 and a time 9:45 AM"); cas.setDocumentLanguage("en"); ae.process(cas); }
Example 13
Source File: PearAnalysisEngineWrapper.java From uima-uimaj with Apache License 2.0 | 4 votes |
private synchronized ResourceManager createRM(StringPair sp, PackageBrowser pkgBrowser, ResourceManager parentResourceManager) throws MalformedURLException { // create UIMA resource manager and apply pear settings // ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager(); ResourceManager rsrcMgr; if (null == parentResourceManager) { // could be null for top level Pear not in an aggregate rsrcMgr = UIMAFramework.newDefaultResourceManager(); } else { rsrcMgr = ((ResourceManager_impl) parentResourceManager).copy(); // newPearsParent.set((ResourceManager_impl) parentResourceManager); // rsrcMgr = UIMAFramework.newDefaultResourceManagerPearWrapper(); // newPearsParent.remove(); // ((ResourceManagerPearWrapper)rsrcMgr).initializeFromParentResourceManager(parentResourceManager); } rsrcMgr.setExtensionClassPath(sp.classPath, true); if (parentResourceManager != null) { rsrcMgr.setCasManager(parentResourceManager.getCasManager()); // shares the same merged type system } UIMAFramework.getLogger(this.getClass()).logrb( Level.CONFIG, this.getClass().getName(), "createRM", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_classpath__CONFIG", new Object[] { sp.classPath, pkgBrowser.getRootDirectory().getName() }); // get and set uima.datapath if specified if (sp.dataPath != null) { rsrcMgr.setDataPath(sp.dataPath); UIMAFramework.getLogger(this.getClass()).logrb( Level.CONFIG, this.getClass().getName(), "createRM", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_datapath__CONFIG", new Object[] { sp.dataPath, pkgBrowser.getRootDirectory().getName() }); } return rsrcMgr; }
Example 14
Source File: MultiprocessingAnalysisEngine_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see org.apache.uima.resource.Resource#initialize(org.apache.uima.resource.ResourceSpecifier, * java.util.Map) */ public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { // Read parameters from the aAdditionalParams map. // (First copy it so we can modify it and send the parameters on to // each Analysis Engine in the pool.) if (aAdditionalParams == null) { aAdditionalParams = new HashMap<>(); } else { aAdditionalParams = new HashMap<>(aAdditionalParams); } // get or create ResourceManager // This ResourceManager is shared among all the AEs in the pool, and also used by // this MultiprocessingAE instance // https://issues.apache.org/jira/browse/UIMA-2078 ResourceManager resMgr = (ResourceManager) aAdditionalParams.get(Resource.PARAM_RESOURCE_MANAGER); if (resMgr == null) { resMgr = UIMAFramework.newDefaultResourceManager(); aAdditionalParams.put(Resource.PARAM_RESOURCE_MANAGER, resMgr); } // Share the configMgr so that (re)configure actions affect all instances ConfigurationManager configMgr = (ConfigurationManager) aAdditionalParams.get(Resource.PARAM_CONFIG_MANAGER); if (configMgr == null) { configMgr = UIMAFramework.newConfigurationManager(); aAdditionalParams.put(Resource.PARAM_CONFIG_MANAGER, configMgr); } super.initialize(aSpecifier, aAdditionalParams); // determine size of Analysis Engine pool and timeout period Integer poolSizeInteger = (Integer) aAdditionalParams.get(PARAM_NUM_SIMULTANEOUS_REQUESTS); int poolSize = (poolSizeInteger != null) ? poolSizeInteger : DEFAULT_NUM_SIMULTANEOUS_REQUESTS; Integer timeoutInteger = (Integer) aAdditionalParams.get(PARAM_TIMEOUT_PERIOD); mTimeout = (timeoutInteger != null) ? timeoutInteger : DEFAULT_TIMEOUT_PERIOD; // Share resource manager, but don't share uima-context // // add UimaContext to params map so that all AEs in pool will share it // aAdditionalParams.put(PARAM_UIMA_CONTEXT, getUimaContextAdmin()); // create pool (REMOVE pool size parameter from map so we don't try to // fill pool with other MultiprocessingAnalysisEngines!) aAdditionalParams.remove(PARAM_NUM_SIMULTANEOUS_REQUESTS); mPool = new AnalysisEnginePool("", poolSize, aSpecifier, aAdditionalParams); // update metadata from pool (this gets the merged type system for aggregates) this.setMetaData(mPool.getMetaData()); return true; }
Example 15
Source File: CPMImpl.java From uima-uimaj with Apache License 2.0 | 4 votes |
public CPMImpl() throws Exception { this(UIMAFramework.newDefaultResourceManager()); }
Example 16
Source File: Preprocessor.java From termsuite-core with Apache License 2.0 | 4 votes |
private PreprocessorService asService(Lang lang, CorpusMetadata corpusMetadata) { PreprocessingPipelineBuilder builder = PreprocessingPipelineBuilder .create(lang, taggerPath) .setNbDocuments(corpusMetadata.getNbDocuments()) .setCorpusSize(corpusMetadata.getTotalSize()); if(tagger.isPresent()) builder.setTagger(tagger.get()); if(documentLoggingEnabled.isPresent()) builder.setDocumentLoggingEnabled(documentLoggingEnabled.get()); if(fixedExpressionEnabled.isPresent()) builder.setFixedExpressionEnabled(fixedExpressionEnabled.get()); if(listener.isPresent()) builder.addPipelineListener(listener.get()); for(AnalysisEngineDescription customAE:customAEs) builder.addCustomAE(customAE); if(resourceOptions.isPresent()) builder.setResourceConfig(resourceOptions.get()); if(history.isPresent()) builder.setHistory(history.get()); final AnalysisEngine aae; try { logger.info("Initializing analysis engine"); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); AnalysisEngineDescription aaeDesc; aaeDesc = createEngineDescription(builder.create()); // Instantiate AAE aae = UIMAFramework.produceAnalysisEngine(aaeDesc, resMgr, null); } catch (ResourceInitializationException e) { throw new TermSuiteException(e); } return Guice.createInjector( new TermSuiteModule(), new PreprocessingModule(lang, aae)) .getInstance(PreprocessorService.class); }
Example 17
Source File: CasCreationUtilsTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void testAggregateWithImports() throws Exception { try { String pathSep = System.getProperty("path.separator"); ResourceManager resMgr = UIMAFramework.newDefaultResourceManager(); resMgr.setDataPath(JUnitExtension.getFile("TypeSystemDescriptionImplTest/dataPathDir") .getAbsolutePath() + pathSep + JUnitExtension.getFile("TypePrioritiesImplTest/dataPathDir").getAbsolutePath() + pathSep + JUnitExtension.getFile("FsIndexCollectionImplTest/dataPathDir").getAbsolutePath()); File taeDescriptorWithImport = JUnitExtension .getFile("CasCreationUtilsTest/AggregateTaeWithImports.xml"); AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription( new XMLInputSource(taeDescriptorWithImport)); ArrayList<AnalysisEngineDescription> mdList = new ArrayList<>(); mdList.add(desc); CAS tcas = CasCreationUtils.createCas(mdList, UIMAFramework .getDefaultPerformanceTuningProperties(), resMgr); // check that imports were resolved correctly assertNotNull(tcas.getTypeSystem().getType("DocumentStructure")); assertNotNull(tcas.getTypeSystem().getType("NamedEntity")); assertNotNull(tcas.getTypeSystem().getType("TestType3")); assertNotNull(tcas.getTypeSystem().getType("Sentence")); assertNotNull(tcas.getIndexRepository().getIndex("TestIndex")); assertNotNull(tcas.getIndexRepository().getIndex("ReverseAnnotationIndex")); assertNotNull(tcas.getIndexRepository().getIndex("DocumentStructureIndex")); // Check elementType and multipleReferencesAllowed for array feature Feature arrayFeat = tcas.getTypeSystem().getFeatureByFullName("Paragraph:sentences"); assertNotNull(arrayFeat); assertFalse(arrayFeat.isMultipleReferencesAllowed()); Type sentenceArrayType = arrayFeat.getRange(); assertNotNull(sentenceArrayType); assertTrue(sentenceArrayType.isArray()); assertEquals(tcas.getTypeSystem().getType("Sentence"), sentenceArrayType.getComponentType()); Feature arrayFeat2 = tcas.getTypeSystem().getFeatureByFullName( "Paragraph:testMultiRefAllowedFeature"); assertNotNull(arrayFeat2); assertTrue(arrayFeat2.isMultipleReferencesAllowed()); // test imports aren't resolved more than once Object spec1 = desc.getDelegateAnalysisEngineSpecifiers().get("Annotator1"); assertNotNull(spec1); Object spec2 = desc.getDelegateAnalysisEngineSpecifiers().get("Annotator1"); assertTrue(spec1 == spec2); // test removal desc.getDelegateAnalysisEngineSpecifiersWithImports().remove("Annotator1"); assertTrue(desc.getDelegateAnalysisEngineSpecifiers().isEmpty()); } catch (Exception e) { JUnitExtension.handleException(e); } }
Example 18
Source File: UimaContext_implTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
protected void setUp() throws Exception { try { // configure ResourceManager to allow test components to locate their resources ResourceManager rm = UIMAFramework.newDefaultResourceManager(); rm.setDataPath(TEST_DATAPATH); rm.setExtensionClassPath(TEST_EXTENSION_CLASSPATH, true); // create a UimaContext with Config Params and Resources UIMAFramework.getXMLParser().enableSchemaValidation(true); CasConsumerDescription ccDesc = UIMAFramework.getXMLParser().parseCasConsumerDescription( new XMLInputSource(JUnitExtension .getFile("UimaContextTest/CasConsumerForUimaContextTest.xml"))); CasConsumer cc = UIMAFramework.produceCasConsumer(ccDesc, rm, null); mContext = cc.getUimaContext(); // create a UimaContext with Config Params in Groups but no resources XMLInputSource in = new XMLInputSource(JUnitExtension .getFile("AnnotatorContextTest/AnnotatorWithConfigurationGroups.xml")); AnalysisEngineDescription taeDesc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in); AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(taeDesc, rm, null); mContext2 = ae.getUimaContext(); // create a UimaContext with Groups and Groupless Parameters XMLInputSource in2 = new XMLInputSource(JUnitExtension .getFile("AnnotatorContextTest/AnnotatorWithGroupsAndNonGroupParams.xml")); AnalysisEngineDescription taeDesc2 = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in2); AnalysisEngine ae2 = UIMAFramework.produceAnalysisEngine(taeDesc2, rm, null); mContext3 = ae2.getUimaContext(); // create a UimaContext with duplicate configuration groups XMLInputSource in3 = new XMLInputSource(JUnitExtension .getFile("TextAnalysisEngineImplTest/AnnotatorWithDuplicateConfigurationGroups.xml")); AnalysisEngineDescription taeDesc3 = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in3); AnalysisEngine ae3 = UIMAFramework.produceAnalysisEngine(taeDesc3, rm, null); mContext4 = ae3.getUimaContext(); super.setUp(); // create a UimaContext for a CAS Multiplier XMLInputSource in4 = new XMLInputSource(JUnitExtension .getFile("TextAnalysisEngineImplTest/NewlineSegmenter.xml")); AnalysisEngineDescription taeDesc4 = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in4); AnalysisEngine ae4 = UIMAFramework.produceAnalysisEngine(taeDesc4); mContext5 = ae4.getUimaContext(); super.setUp(); } catch (Exception e) { JUnitExtension.handleException(e); } }
Example 19
Source File: UIMAClassLoaderTest.java From uima-uimaj with Apache License 2.0 | 3 votes |
public void testAdvancedRsrcMgrCLassLoaderCreation() throws Exception { ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager(); assertNull(rsrcMgr.getExtensionClassLoader()); rsrcMgr.setExtensionClassPath("../this/is/a/simple/test.jar", true); assertNotNull(rsrcMgr.getExtensionClassLoader()); }
Example 20
Source File: AnnotatorTester.java From uima-uimaj with Apache License 2.0 | 2 votes |
/** * Constructor save the specified descriptor file path and initialize the * analysis engine. * * @param descFilePath * descriptor file path * @throws Exception passthru * if an analysis engine initialize error occurs. */ public AnnotatorTester(String descFilePath) throws Exception { this.descFile = new File(descFilePath); this.mgr = UIMAFramework.newDefaultResourceManager(); setup(); }