Ok I am making a mistake. I dont want to use UimaFit to initialize the resource. If I initialize it using uimafit, i will have to run the pipeline using uimafit too. Am I right ?
I want to be able to initialize the external Shared Resource my self, as the number of such resources are unknown, they are passed at run time. So the pipeline has to take in what resources to load from some file and then load them. Is that possible. I see that I can produce a resource using UIMAFramework.produceResource but it requires a resourceSpecifier. I do not know how to initialize a resource specifier. I was trying to use uimafit to first generate the external resource description and then use its resource specifier to call produceResource function. This approach is cumbersome and isnt working!! So is there a way to initialize ResourceSpecifier so that I can use produceResource function from uimaFramework. Sorry for the trouble. Thanks Manisha On Thu, May 30, 2013 at 3:13 PM, Richard Eckart de Castilho < [email protected]> wrote: > Hi, > > since you are using uimaFIT, did you look at the documentation here > > https://code.google.com/p/uimafit/wiki/ExternalResources > > In particular, it makes a difference if the component you want to inject > the resource into uses the uimaFIT @ExternalResource annotation and > inherits from the uimaFIT base classes for resource or invokes > ExternalResourceInitializer itself. If that is the case, the uimaFIT > factory create* factory methdos already create the > ExternalResourceDependency for you. > > If you are using a non-uimaFIT-aware component, you need to use > createDependencyAndBind. > > That said, you seem to try to instantiate the external resource yourself > (maybe as a test?), normally the UIMA ResourceManager should do that for > you when you run a pipeline. At appears to me that ResourceManager_impl is > not using UIMAFramework.produceResource() instantiate the resource (cf. > UIMA 2.4.0 ResourceManager_impl lines 520ff and 290ff). So I suppose there > is a chance it works if you just don't try to instantiate the resource > yourself and leave it to UIMA. > > Cheers, > > -- Richard > > Am 30.05.2013 um 09:43 schrieb Mansi verma <[email protected]>: > > > Hi > > > > I have to load a set of files as external resources in uima. The > annotator > > reads a file containing the list of files to load in the engine as shared > > resource. Since the number of files may change, I cannot bind them in the > > descriptor. > > > > To accomplish this I used the following snippet of code. However it > throws > > an exception of invalid class cast. > > > > ExternalResourceDescription extDesc = ExternalResourceFactory. > > createExternalResourceDescription(key,MyResource_impl.class, > > fileName); > > Map<String, Object> initParams = new HashMap<String, Object>() ; > > MyResource file = > > > (MyResource_impl)UIMAFramework.produceResource(extDep..getResourceSpecifier(), > > initParams); > > > > Now the error is as follows : > > Caused by: java.lang.ClassCastException: > > org.apache.uima.resource.impl.ConfigurableDataResource_impl cannot be > cast > > to org.my.project.resource.MyResource_impl > > > > I tried an alternate approach too wherein I declared > > ExternalResourceDependency but I do not know how to create an external > > resource object using this dependency. The code is as follows > > > > ExternalResourceDependency extDep = > > > UIMAFramework.getResourceSpecifierFactory().createExternalResourceDependency(); > > extDep.setDescription("file for "+key); > > extDep.setInterfaceName(MyResource_impl.class.toString()); > > extDep.setKey(key+"File"); > > extDep.setOptional(false); > > extDep.setSourceUrl(new URL(fileName)); > > > > Thanks > > Manisha > >
