uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: Sharing the same ExternalResource instance between a CollectionReader and Annotators
Date Thu, 06 Feb 2014 07:55:53 GMT
Thanks for the report. This hasn't been noticed so far.

I am afraid that SimplePipeline currently does not support sharing
a resource between the reader and the components.

Internally, SimplePipeline instantiates the reader and the components
separately, thus they end up with different resource managers.
Resources can only be shared by components that use the same resource

As a workaround, you could try the following:

- Create the reader and component descriptions as usual with uimaFIT.
- Use UIMAFramework.newDefaultResourceManager() to create a resource manager.
- Use UIMAFramework.produceCollectionReader() and UIMAFramework.produceAnalysisEngine()
to create CollectionReader and AnalysisEngine instances from the descriptors and with your
resource manager.
- Pass the CollectionReader and AnalysisEngine instances as parameters to SimplePipeline.
- Mind that you'll have to call the "collectionProcessComplete" and "destroy" methods manually
on the instances after SimplePipeline is complete - if you need these events.

I think that should work, but I currently have no time to try it out.

Sounds like something that should be fixable for the next uimaFIT release. Would you mind
opening a bug for that on the Apache Jira?


-- Richard

On 06.02.2014, at 07:10, swirl <lriwswirl@gmail.com> wrote:

> I am creating a pipeline as follows:
> a. CollectionReader
> b. AnnotatorA
> c. AnnotatorB
> All the above (including the CollectionReader and the 2 annotators) have a 
> dependency on an ExternalResource.
> Here's a shortened code that I used:
> // create the external resource desc 
> ExternalResourceDescription myExternalResourceDesc = 
> createExternalResourceDescription();
> // create the CollectionReaderDescription, with the external resource desc
> CollectionReaderDescription myCollectionReaderDesc = 
> createDescription(myExternalResourceDesc);
> // create the MyAnnotatorA desc, with the external resource desc 
> AnalysisEngineDescription myAnnotatorADesc = 
> createPrimitiveDescription(myExternalResourceDesc);
> // create the MyAnnotatorB desc, with the external resource desc 
> AnalysisEngineDescription myAnnotatorBDesc = 
> createPrimitiveDescription(myExternalResourceDesc);
> // run 
> SimplePipeline.runPipeline(myCollectionReaderDesc, myAnnotatorADesc,				
> myAnnotatorBDesc);
> In the initialize(UimaContext context) method of collection reader and 
> annotator, I print out the instance of the ExternalResource:
> MyCollectionReader:com.example.MyExternalResource@26a7dd39
> MyAnnotatorA:com.example.MyExternalResource@6ee1dac2
> MyAnnotatorB:com.example.MyExternalResource@6ee1dac2
> As you can see, MyAnnotatorA and MyAnnotatorB got the same instance of the 
> ExternalResource, but MyCollectionReader got a different instance.
> How can I ensure that the CollectionReader and the annotators got hold of 
> the same instance of the ExternalResource?
> Thanks.

View raw message