uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <eck...@ukp.informatik.tu-darmstadt.de>
Subject Re: DataResources
Date Sat, 17 Mar 2012 10:18:27 GMT
Hi Stephan,

let's see if I can help you out here.

1) For a resource with parameters set statically in the descriptor, your resource should extend

   from Resource_ImplBase (implements DataResource).

2) For a resource that needs to load data from aURL, you resource class can be anything and
   implement SharedResourceObject. It's also possible to set parameters statically in the
   descriptor (see below).

3) If you do not know the values of the parameters at the time you write the descriptor, then
   you need to use a ParameterizedDataResource. You can get an instance of such a resource
   within your AE using 

     getContext().getResourceObject("theResource", new String[] { param1, param2, param3...

Resources of the type 1 and 2 are instantiated when the pipeline components are instantiated.
The type 3 resource is instantiated when you try to access it using getResourceObject().

Now to the descriptors that we use for the different types in uimaFIT:

1) CustomResourceSpecifier

2) FileResourceSpecifier (if the resource does not need parameters), otherwise 

3) CustomResourceSpecifier

If you are not bound to using XML descriptors, you might want to have a look at uimaFIT 
for programmatically  creating component and resource descriptions. Here a little example
binding an external resource to two different AEs:

  ExternalResourceDescription extDesc = createExternalResourceDescription(
    SharedModel.class, new File("somemodel.bin"));
  // Binding external resource to each Annotator individually
  AnalysisEngineDescription aed1 = createPrimitiveDescription(Annotator.class,
    Annotator.MODEL_KEY, extDesc);
    AnalysisEngineDescription aed2 = createPrimitiveDescription(Annotator.class,
    Annotator.MODEL_KEY, extDesc);

  // Process something with the two AEs
  AnalysisEngineDescription aaed = createAggregateDescription(aed1, aed2);
  AnalysisEngine ae = createAggregate(aaed);

(Source: http://code.google.com/p/uimafit/wiki/uimaFitResources)


-- Richard

Am 16.03.2012 um 21:00 schrieb Stephan Greene:

> Well, to answer my own question, I see that I can set a CustomResourceSpecifier by editing
my descriptor xml directly (thanks to a post by Adam Lally in 2008; http://www.mail-archive.com/uima-user@incubator.apache.org/msg01437.html
> I have this now:
>      <externalResource>
>        <name>theResource</name>
>        <description>my resource</description>
>        <customResourceSpecifier>
>          <resourceClassName>com.my.resourcemanagers.MyDataResource</resourceClassName>
>          <parameters>
>            <parameter name="param1" value="paramval1"/>
>            <parameter name="param2" value="paramval2"/>
>          </parameters>
>        </customResourceSpecifier>
>      </externalResource>
> I then implemented as
> public class MyDataResource extends Resource_ImplBase implements ParameterizedDataResource,
DataResource, SharedResourceObject
> This actually works and does what I want. But I suspect I'm not really using the framework
correctly. Does anyone knows the canonical way to use these various Resource classes?
> Stephan
> On Mar 16, 2012, at 12:30 PM, Stephan Greene wrote:
>> I am implementing a SharedResourceObject which requires a DataResource more involved
than just a url to access the data the resource represents. I need something like the ParameterizedDataResource
-- but I don't see how to instantiate this. The load() method of SharedResourceObject takes
a DataResource object parameter. How do I configure my SharedResourceObject to use some other
kind of DataResource? I know how to implement the data resource I need, but I can't figure
out how to tell the framework that I want to use my own data resource with my own SharedResourceObject.
>> Does it involve a CustomResourceSpecifier? I can't figure out how to use that, either.
Any help appreciated.
>> Stephan

Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab (UKP-TUD) 
FB 20 Computer Science Department      
Technische Universit├Ąt Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de

View raw message