You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Shahim Essaid <sh...@essaid.com> on 2013/02/19 23:31:16 UTC

Obtaining the AnalysisEngine object from a primitive analysis component

Hi all,

I have a use case where I would like be able to get the AnalysisEngine
object from an AnalysisComponent object at runtime in order to get to
the:

  private ResourceCreationSpecifier mDescription; (or the aggregate's
corresponding field.)

in the PrimitiveAnalysisEngine_impl class.

This will help my use case in two different ways. First, it will give
me a single unique object for the current engine regardless how many
component instances are created from my class and the object will be
specific to the current engine in case my component class is
instantiated in multiple engines. Second, I can get full access to the
specifier that was used to create the engine.

Is this possible?  I tried to look through the various object
references while debugging but couldn't figure out how to get to the
analysis engine object. I was able to get hold of the
ConfigurationManager object for the engine (which appears to be a
single object per engine) but not the engine object itself. I know I
can coordinate this from the application side but I would like to be
able to do this by simply including the component in an engine without
any other changes.

Thanks,
Shahim

Re: Obtaining the AnalysisEngine object from a primitive analysis component

Posted by Shahim Essaid <sh...@essaid.com>.
Richard, thank you for your detailed response. I probably can use a
combination of your suggestions at some point.

A related question. If I need to synchronize in an analysis component
on a single object that maintains its identity throughout a pipeline
run, what object would that be?  Let's say I have an analysis
component Java class that will be used in different running pipelines
at the same time and this class needs to do something once per
pipeline instance (a multiprocessing pipeline should count as one
pipeline),  is the configuration manager for the pipeline the correct
object to use for this purpose? Is there a better option? I am looking
for an object in the UIMA framework and not some resource that has to
be created and registered by the application. Also, i am only
concerned about doing this in a single JVM and it doesn't matter if
there are other pipeline related processes in other machines.

Thanks,
Shahim

On Wed, Feb 20, 2013 at 2:11 PM, Richard Eckart de Castilho
<ec...@ukp.informatik.tu-darmstadt.de> wrote:
> Hi Shahim,
>
> UIMA doesn't support the kind of scenario you describe. In the UIMA
> world, components must exist independent of each other. Part of that
> independence is that there is no way for a component to find out
> what other components are in the pipeline. E.g. UIMA supports pipelines
> where each component runs on a different server and they communicate via
> network. A central control server may know about the full pipeline, but not
> the components running on the processing servers - they only know about
> themselves. What even the central server may not know is that a processing
> server may actually run an aggregated analysis engine, not a primitive
> engine, so what the central server thinks would be one component are
> actually several.
>
> So far, I have seen two approaches to a scenario such as you describe:
>
> 1) Store meta data in the CAS: every component that processes the CAS
> adds some special meta-data annotation(s) to the CAS. The last component
> can read all these and record the information in a DB/RDF/whatever.
>
> 2) Execution wrapper : instead of passing your analysis description (AAE,
> CPE or whatever) directly to UIMA for execution, you create a thin
> wrapper around UIMA to which you pass the description. The wrapper
> can access the description and record what you need before or after
> passing on the description to UIMA for execution.
>
> Solution 2) should be preferable, because it doesn't require the AEs
> to support any special meta-data annotations.
>
> I recommend against continuing on the path you are currently on. It
> is extremely unlikely that the UIMA framework core will not be
> changed to support access to the kind of information that you need.
> You can hack yourself to the information you require using reflection,
> but that will create extremely fragile code. When internal details of
> the UIMA framework change in any future release, there is a good
> chance your code will break. Nobody will try to make sure non-public
> API or fields remain stable across releases. Your idea will also not
> work in a distributed environment as outlined in the beginning of this
> mail.
>
> Cheers,
>
> -- Richard
>
> Am 20.02.2013 um 22:48 schrieb Shahim Essaid <sh...@essaid.com>:
>
>> Hi Richard,
>>
>> Thank you for your answer. I was trying to avoid discussing the
>> details of the use case to avoid a lengthy email like this one :-) I
>> am still filling in some of the details of my use case but here is the
>> general idea.
>>
>> I would like to add a primitive analysis engine to the end of any
>> pipeline and have this engine record all the information about the
>> pipeline and the CAS without additional configuration or application
>> modification. So, this engine needs to get all the information from
>> the specifier for the pipeline. This information will be recorded in
>> RDF as information about what I am calling the "implementation of an
>> analysis agent". An agent could be a person, an algorithm, a UIMA
>> pipeline, etc. and the engine I am adding to the end of a UIMA
>> pipeline will capture this information in a UIMA specific way and then
>> write it as RDF that is based on a general ontology I am developing.
>>
>> Basically, I need to reach into the pipeline to collect as much
>> metadata as possible. I was able to find the URL of the primitive
>> specifiers in the configuration manager but I couldn't find the URL
>> for the top level engine. Also, the URL might not be available if the
>> pipeline is put together dynamically. I think what i need is the
>> metadata object for the top resource but I can't see a way to get hold
>> of that object. It is private but I can get it through reflection as
>> long as I can get hold of the top resource for a pipeline instance.
>>
>> The log term goal that I am working on is the development of a generic
>> OWL/RDF model of content, annotations, interpretations, etc. that can
>> aggregate output from different tools with the main one being UIMA. I
>> am an informatics and formal semantics researcher and many researchers
>> and user in our domain need tools and solutions for generating and
>> aggregating such data in a common way and I am attempting to do this
>> in RDF. There are other pieces to my work but they are not directly
>> related to my UIMA questions.
>>
>> Hope this helps clarify my earlier questions.
>>
>> Best,
>> Shahim
>
>
> --
> -------------------------------------------------------------------
> 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
> eckart@ukp.informatik.tu-darmstadt.de
> www.ukp.tu-darmstadt.de
> Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
> -------------------------------------------------------------------
>

Re: Obtaining the AnalysisEngine object from a primitive analysis component

Posted by Richard Eckart de Castilho <ec...@ukp.informatik.tu-darmstadt.de>.
Hi Shahim,

UIMA doesn't support the kind of scenario you describe. In the UIMA
world, components must exist independent of each other. Part of that
independence is that there is no way for a component to find out
what other components are in the pipeline. E.g. UIMA supports pipelines
where each component runs on a different server and they communicate via
network. A central control server may know about the full pipeline, but not
the components running on the processing servers - they only know about
themselves. What even the central server may not know is that a processing
server may actually run an aggregated analysis engine, not a primitive
engine, so what the central server thinks would be one component are 
actually several.

So far, I have seen two approaches to a scenario such as you describe:

1) Store meta data in the CAS: every component that processes the CAS
adds some special meta-data annotation(s) to the CAS. The last component
can read all these and record the information in a DB/RDF/whatever.

2) Execution wrapper : instead of passing your analysis description (AAE,
CPE or whatever) directly to UIMA for execution, you create a thin
wrapper around UIMA to which you pass the description. The wrapper
can access the description and record what you need before or after
passing on the description to UIMA for execution.

Solution 2) should be preferable, because it doesn't require the AEs 
to support any special meta-data annotations.

I recommend against continuing on the path you are currently on. It 
is extremely unlikely that the UIMA framework core will not be
changed to support access to the kind of information that you need.
You can hack yourself to the information you require using reflection,
but that will create extremely fragile code. When internal details of
the UIMA framework change in any future release, there is a good
chance your code will break. Nobody will try to make sure non-public
API or fields remain stable across releases. Your idea will also not
work in a distributed environment as outlined in the beginning of this
mail.

Cheers,

-- Richard

Am 20.02.2013 um 22:48 schrieb Shahim Essaid <sh...@essaid.com>:

> Hi Richard,
> 
> Thank you for your answer. I was trying to avoid discussing the
> details of the use case to avoid a lengthy email like this one :-) I
> am still filling in some of the details of my use case but here is the
> general idea.
> 
> I would like to add a primitive analysis engine to the end of any
> pipeline and have this engine record all the information about the
> pipeline and the CAS without additional configuration or application
> modification. So, this engine needs to get all the information from
> the specifier for the pipeline. This information will be recorded in
> RDF as information about what I am calling the "implementation of an
> analysis agent". An agent could be a person, an algorithm, a UIMA
> pipeline, etc. and the engine I am adding to the end of a UIMA
> pipeline will capture this information in a UIMA specific way and then
> write it as RDF that is based on a general ontology I am developing.
> 
> Basically, I need to reach into the pipeline to collect as much
> metadata as possible. I was able to find the URL of the primitive
> specifiers in the configuration manager but I couldn't find the URL
> for the top level engine. Also, the URL might not be available if the
> pipeline is put together dynamically. I think what i need is the
> metadata object for the top resource but I can't see a way to get hold
> of that object. It is private but I can get it through reflection as
> long as I can get hold of the top resource for a pipeline instance.
> 
> The log term goal that I am working on is the development of a generic
> OWL/RDF model of content, annotations, interpretations, etc. that can
> aggregate output from different tools with the main one being UIMA. I
> am an informatics and formal semantics researcher and many researchers
> and user in our domain need tools and solutions for generating and
> aggregating such data in a common way and I am attempting to do this
> in RDF. There are other pieces to my work but they are not directly
> related to my UIMA questions.
> 
> Hope this helps clarify my earlier questions.
> 
> Best,
> Shahim


-- 
------------------------------------------------------------------- 
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
eckart@ukp.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
-------------------------------------------------------------------


Re: Obtaining the AnalysisEngine object from a primitive analysis component

Posted by Shahim Essaid <sh...@essaid.com>.
Hi Richard,

Thank you for your answer. I was trying to avoid discussing the
details of the use case to avoid a lengthy email like this one :-) I
am still filling in some of the details of my use case but here is the
general idea.

I would like to add a primitive analysis engine to the end of any
pipeline and have this engine record all the information about the
pipeline and the CAS without additional configuration or application
modification. So, this engine needs to get all the information from
the specifier for the pipeline. This information will be recorded in
RDF as information about what I am calling the "implementation of an
analysis agent". An agent could be a person, an algorithm, a UIMA
pipeline, etc. and the engine I am adding to the end of a UIMA
pipeline will capture this information in a UIMA specific way and then
write it as RDF that is based on a general ontology I am developing.

Basically, I need to reach into the pipeline to collect as much
metadata as possible. I was able to find the URL of the primitive
specifiers in the configuration manager but I couldn't find the URL
for the top level engine. Also, the URL might not be available if the
pipeline is put together dynamically. I think what i need is the
metadata object for the top resource but I can't see a way to get hold
of that object. It is private but I can get it through reflection as
long as I can get hold of the top resource for a pipeline instance.

The log term goal that I am working on is the development of a generic
OWL/RDF model of content, annotations, interpretations, etc. that can
aggregate output from different tools with the main one being UIMA. I
am an informatics and formal semantics researcher and many researchers
and user in our domain need tools and solutions for generating and
aggregating such data in a common way and I am attempting to do this
in RDF. There are other pieces to my work but they are not directly
related to my UIMA questions.

Hope this helps clarify my earlier questions.

Best,
Shahim


On Wed, Feb 20, 2013 at 12:42 PM, Richard Eckart de Castilho
<ec...@ukp.informatik.tu-darmstadt.de> wrote:
> Hi,
>
> there shouldn't be any reason that an AE need to access its specified. Relevant information should be accessible via the UimaContext (parameters and resources). I'd guess there is a good chance that you are trying to solve a problem in an unsupported way that could be solved better otherwise. It seems you do not tell us about your original problem, but rather about a problem you ran into while trying to fix your original problem. What is the original problem?
>
> Cheers,
>
> -- Richard
>
> Am 20.02.2013 um 21:35 schrieb Shahim Essaid <sh...@essaid.com>:
>
>> I looked a little closer at the code and it appears that this is not
>> possible in the current implementation.
>>
>> So a related question would be the following. Is there any harm in
>> passing _and holding_ a reference from parent resources to child
>> resources, and then eventually to an analysis component? This could be
>> done in the initialization map and then nullified in the destroy call.
>> I can easily add this to the code but I am not sure about any
>> consequences of doing this. Would this cause any memory leaks or any
>> other issues? Is the destroy method call guaranteed if any exceptions
>> are thrown? I'm looking through the code to find these answers but a
>> confirmation from the UIMA developers would be very appreciated.
>>
>> Best,
>> Shahim
>>
>> On Tue, Feb 19, 2013 at 2:31 PM, Shahim Essaid <sh...@essaid.com> wrote:
>>> Hi all,
>>>
>>> I have a use case where I would like be able to get the AnalysisEngine
>>> object from an AnalysisComponent object at runtime in order to get to
>>> the:
>>>
>>>  private ResourceCreationSpecifier mDescription; (or the aggregate's
>>> corresponding field.)
>>>
>>> in the PrimitiveAnalysisEngine_impl class.
>>>
>>> This will help my use case in two different ways. First, it will give
>>> me a single unique object for the current engine regardless how many
>>> component instances are created from my class and the object will be
>>> specific to the current engine in case my component class is
>>> instantiated in multiple engines. Second, I can get full access to the
>>> specifier that was used to create the engine.
>>>
>>> Is this possible?  I tried to look through the various object
>>> references while debugging but couldn't figure out how to get to the
>>> analysis engine object. I was able to get hold of the
>>> ConfigurationManager object for the engine (which appears to be a
>>> single object per engine) but not the engine object itself. I know I
>>> can coordinate this from the application side but I would like to be
>>> able to do this by simply including the component in an engine without
>>> any other changes.
>>>
>>> Thanks,
>>> Shahim
>
>
> --
> -------------------------------------------------------------------
> 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
> eckart@ukp.informatik.tu-darmstadt.de
> www.ukp.tu-darmstadt.de
> Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
> -------------------------------------------------------------------
>

Re: Obtaining the AnalysisEngine object from a primitive analysis component

Posted by Richard Eckart de Castilho <ec...@ukp.informatik.tu-darmstadt.de>.
Hi,

there shouldn't be any reason that an AE need to access its specified. Relevant information should be accessible via the UimaContext (parameters and resources). I'd guess there is a good chance that you are trying to solve a problem in an unsupported way that could be solved better otherwise. It seems you do not tell us about your original problem, but rather about a problem you ran into while trying to fix your original problem. What is the original problem?

Cheers,

-- Richard

Am 20.02.2013 um 21:35 schrieb Shahim Essaid <sh...@essaid.com>:

> I looked a little closer at the code and it appears that this is not
> possible in the current implementation.
> 
> So a related question would be the following. Is there any harm in
> passing _and holding_ a reference from parent resources to child
> resources, and then eventually to an analysis component? This could be
> done in the initialization map and then nullified in the destroy call.
> I can easily add this to the code but I am not sure about any
> consequences of doing this. Would this cause any memory leaks or any
> other issues? Is the destroy method call guaranteed if any exceptions
> are thrown? I'm looking through the code to find these answers but a
> confirmation from the UIMA developers would be very appreciated.
> 
> Best,
> Shahim
> 
> On Tue, Feb 19, 2013 at 2:31 PM, Shahim Essaid <sh...@essaid.com> wrote:
>> Hi all,
>> 
>> I have a use case where I would like be able to get the AnalysisEngine
>> object from an AnalysisComponent object at runtime in order to get to
>> the:
>> 
>>  private ResourceCreationSpecifier mDescription; (or the aggregate's
>> corresponding field.)
>> 
>> in the PrimitiveAnalysisEngine_impl class.
>> 
>> This will help my use case in two different ways. First, it will give
>> me a single unique object for the current engine regardless how many
>> component instances are created from my class and the object will be
>> specific to the current engine in case my component class is
>> instantiated in multiple engines. Second, I can get full access to the
>> specifier that was used to create the engine.
>> 
>> Is this possible?  I tried to look through the various object
>> references while debugging but couldn't figure out how to get to the
>> analysis engine object. I was able to get hold of the
>> ConfigurationManager object for the engine (which appears to be a
>> single object per engine) but not the engine object itself. I know I
>> can coordinate this from the application side but I would like to be
>> able to do this by simply including the component in an engine without
>> any other changes.
>> 
>> Thanks,
>> Shahim


-- 
------------------------------------------------------------------- 
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
eckart@ukp.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
-------------------------------------------------------------------


Re: Obtaining the AnalysisEngine object from a primitive analysis component

Posted by Shahim Essaid <sh...@essaid.com>.
I looked a little closer at the code and it appears that this is not
possible in the current implementation.

So a related question would be the following. Is there any harm in
passing _and holding_ a reference from parent resources to child
resources, and then eventually to an analysis component? This could be
done in the initialization map and then nullified in the destroy call.
 I can easily add this to the code but I am not sure about any
consequences of doing this. Would this cause any memory leaks or any
other issues? Is the destroy method call guaranteed if any exceptions
are thrown? I'm looking through the code to find these answers but a
confirmation from the UIMA developers would be very appreciated.

Best,
Shahim

On Tue, Feb 19, 2013 at 2:31 PM, Shahim Essaid <sh...@essaid.com> wrote:
> Hi all,
>
> I have a use case where I would like be able to get the AnalysisEngine
> object from an AnalysisComponent object at runtime in order to get to
> the:
>
>   private ResourceCreationSpecifier mDescription; (or the aggregate's
> corresponding field.)
>
> in the PrimitiveAnalysisEngine_impl class.
>
> This will help my use case in two different ways. First, it will give
> me a single unique object for the current engine regardless how many
> component instances are created from my class and the object will be
> specific to the current engine in case my component class is
> instantiated in multiple engines. Second, I can get full access to the
> specifier that was used to create the engine.
>
> Is this possible?  I tried to look through the various object
> references while debugging but couldn't figure out how to get to the
> analysis engine object. I was able to get hold of the
> ConfigurationManager object for the engine (which appears to be a
> single object per engine) but not the engine object itself. I know I
> can coordinate this from the application side but I would like to be
> able to do this by simply including the component in an engine without
> any other changes.
>
> Thanks,
> Shahim