You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Himanshu Gahlot <hi...@gmail.com> on 2012/12/03 19:48:25 UTC

Is is possible to pass cas view to the process method of an annotator?

Hi,

I want to create 3 views of the base cas and pass them one by one to the process
method of my annotator. From the documentation I know that we can pass only the
base cas to the anlaysis engine unless the annotator is sofa aware. But even if
the annotator is sofa aware I am not able to pass any view to the annotator,
since the cas passed in the sofa aware annotator has no sofa attached to it and
I need to fetch/create the view in the process method itself. Is there a way so
that I do not have to write the view accessing logic within the annotator and
can pass a view of the cas to the process method itself? In short, I would like
the following functionality to work:

JCas casView1 = baseCas.createView("view1");
ae.process(casView1);

and in the process method of the annotator, the cas should be the casView1.

-Himanshu


Re: Is is possible to pass cas view to the process method of an annotator?

Posted by Himanshu Gahlot <hi...@gmail.com>.
ok, I'll evaluate both approaches and see which one is more suitable for my
use case. Thanks Burn and Richard!

Himanshu



On Tue, Dec 4, 2012 at 7:37 AM, Burn Lewis <bu...@gmail.com> wrote:

> You can't select the view in the FC but a very ugly hack would be for the
> FC to modify the CAS and set some feature that would tell a sofa-aware
> annotator what view to switch to.  But again I recommend making the
> annotator sofa-aware and let it do the switching ... that would require
> only a few lines of code and could be quite flexible ... it could use a
> config param to specify the view(s) or fall back to taking the default
> view.  If you do not have access to the annotator source then I think the
> earlier suggestion of replicating it in the aggregate with different sofa
> mappings is the best.
>
> ~Burn
>
>
> On Mon, Dec 3, 2012 at 6:55 PM, Himanshu Gahlot <
> himanshu.gahlot86@gmail.com
> > wrote:
>
> > How can I switch the view for an annotator in the Flow Controller? I have
> > tried the following two things:
> > 1. If the annotator is not sofa aware then even if I use setJCas('view1')
> > method in the Flow Controller, it still passes the base cas to the
> > annotator and not view1. The annotator itself needs to call
> > baseCas.getView('view1') in order to access view1.
> >
> > 2. If the annotator is sofa aware then if I use setJCas('view1') in the
> > Flow Controller it again passes only the base cas which is not associated
> > to any sofa.
> >
> > Even though setJCas is deprecated but I trying to see if the view
> switching
> > functionality in flow controller is possible at all or not.
> >
> > I need to run the same annotator on three different views of the base cas
> > using the Flow Controller. I do not want to write the view switching
> logic
> > in the annotator. As Richard said, I can create three AEs where each AE
> has
> > its default sofa mapped to one of the views and then run it as a
> pipeline.
> > But I want to know if the same is possible using the Flow Controller.
> >
> > Himanshu
> >
> >
> >
> > On Mon, Dec 3, 2012 at 3:31 PM, Burn Lewis <bu...@gmail.com> wrote:
> >
> > > > One more question on a related note: Is it possible to set sofa
> > mappings
> > > in
> > > > the Flow Controller? From all the code usages that I have come across
> > it
> > > > seems that sofa mappings can only be set while building the
> > > AnalysisEngine.
> > >
> > > No, but the FC could modify the CAS, e.g. set some FS to say what view
> an
> > > annotator should switch to.
> > > If you can modify the annotator code it's very easy to make it sofa
> aware
> > > and, say, iterate over all views, or all matching some prefix, or those
> > > specified in a config param.
> > >
> > > ~Burn
> > >
> > >
> > > On Mon, Dec 3, 2012 at 5:57 PM, Richard Eckart de Castilho <
> > > eckart@ukp.informatik.tu-darmstadt.de> wrote:
> > >
> > > > Am 03.12.2012 um 23:32 schrieb Himanshu Gahlot <
> > > > himanshu.gahlot86@gmail.com>:
> > > >
> > > > > One more question on a related note: Is it possible to set sofa
> > > mappings
> > > > in
> > > > > the Flow Controller? From all the code usages that I have come
> across
> > > it
> > > > > seems that sofa mappings can only be set while building the
> > > > AnalysisEngine.
> > > >
> > > >
> > > > Good question. I don't know. I think it's not possible since the
> > JavaDoc
> > > of
> > > > the reconfigure() methods says the method is used only to update a
> > > > component
> > > > with new parameters. Also, the sofa mappings are read directly from
> the
> > > > component descriptor which is afaik not accessible by a flow
> > controller.
> > > >
> > > > I think sofa mappings can only be configured "statically". You
> probably
> > > > could dynamically create a nested pipeline in your flow controller. I
> > > > didn't use flow controllers very much so far.
> > > >
> > > > Maybe someone else has a better idea.
> > > >
> > > > -- Richard
> > > >
> > > > --
> > > > -------------------------------------------------------------------
> > > > 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: Is is possible to pass cas view to the process method of an annotator?

Posted by Burn Lewis <bu...@gmail.com>.
You can't select the view in the FC but a very ugly hack would be for the
FC to modify the CAS and set some feature that would tell a sofa-aware
annotator what view to switch to.  But again I recommend making the
annotator sofa-aware and let it do the switching ... that would require
only a few lines of code and could be quite flexible ... it could use a
config param to specify the view(s) or fall back to taking the default
view.  If you do not have access to the annotator source then I think the
earlier suggestion of replicating it in the aggregate with different sofa
mappings is the best.

~Burn


On Mon, Dec 3, 2012 at 6:55 PM, Himanshu Gahlot <himanshu.gahlot86@gmail.com
> wrote:

> How can I switch the view for an annotator in the Flow Controller? I have
> tried the following two things:
> 1. If the annotator is not sofa aware then even if I use setJCas('view1')
> method in the Flow Controller, it still passes the base cas to the
> annotator and not view1. The annotator itself needs to call
> baseCas.getView('view1') in order to access view1.
>
> 2. If the annotator is sofa aware then if I use setJCas('view1') in the
> Flow Controller it again passes only the base cas which is not associated
> to any sofa.
>
> Even though setJCas is deprecated but I trying to see if the view switching
> functionality in flow controller is possible at all or not.
>
> I need to run the same annotator on three different views of the base cas
> using the Flow Controller. I do not want to write the view switching logic
> in the annotator. As Richard said, I can create three AEs where each AE has
> its default sofa mapped to one of the views and then run it as a pipeline.
> But I want to know if the same is possible using the Flow Controller.
>
> Himanshu
>
>
>
> On Mon, Dec 3, 2012 at 3:31 PM, Burn Lewis <bu...@gmail.com> wrote:
>
> > > One more question on a related note: Is it possible to set sofa
> mappings
> > in
> > > the Flow Controller? From all the code usages that I have come across
> it
> > > seems that sofa mappings can only be set while building the
> > AnalysisEngine.
> >
> > No, but the FC could modify the CAS, e.g. set some FS to say what view an
> > annotator should switch to.
> > If you can modify the annotator code it's very easy to make it sofa aware
> > and, say, iterate over all views, or all matching some prefix, or those
> > specified in a config param.
> >
> > ~Burn
> >
> >
> > On Mon, Dec 3, 2012 at 5:57 PM, Richard Eckart de Castilho <
> > eckart@ukp.informatik.tu-darmstadt.de> wrote:
> >
> > > Am 03.12.2012 um 23:32 schrieb Himanshu Gahlot <
> > > himanshu.gahlot86@gmail.com>:
> > >
> > > > One more question on a related note: Is it possible to set sofa
> > mappings
> > > in
> > > > the Flow Controller? From all the code usages that I have come across
> > it
> > > > seems that sofa mappings can only be set while building the
> > > AnalysisEngine.
> > >
> > >
> > > Good question. I don't know. I think it's not possible since the
> JavaDoc
> > of
> > > the reconfigure() methods says the method is used only to update a
> > > component
> > > with new parameters. Also, the sofa mappings are read directly from the
> > > component descriptor which is afaik not accessible by a flow
> controller.
> > >
> > > I think sofa mappings can only be configured "statically". You probably
> > > could dynamically create a nested pipeline in your flow controller. I
> > > didn't use flow controllers very much so far.
> > >
> > > Maybe someone else has a better idea.
> > >
> > > -- Richard
> > >
> > > --
> > > -------------------------------------------------------------------
> > > 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: Is is possible to pass cas view to the process method of an annotator?

Posted by Himanshu Gahlot <hi...@gmail.com>.
How can I switch the view for an annotator in the Flow Controller? I have
tried the following two things:
1. If the annotator is not sofa aware then even if I use setJCas('view1')
method in the Flow Controller, it still passes the base cas to the
annotator and not view1. The annotator itself needs to call
baseCas.getView('view1') in order to access view1.

2. If the annotator is sofa aware then if I use setJCas('view1') in the
Flow Controller it again passes only the base cas which is not associated
to any sofa.

Even though setJCas is deprecated but I trying to see if the view switching
functionality in flow controller is possible at all or not.

I need to run the same annotator on three different views of the base cas
using the Flow Controller. I do not want to write the view switching logic
in the annotator. As Richard said, I can create three AEs where each AE has
its default sofa mapped to one of the views and then run it as a pipeline.
But I want to know if the same is possible using the Flow Controller.

Himanshu



On Mon, Dec 3, 2012 at 3:31 PM, Burn Lewis <bu...@gmail.com> wrote:

> > One more question on a related note: Is it possible to set sofa mappings
> in
> > the Flow Controller? From all the code usages that I have come across it
> > seems that sofa mappings can only be set while building the
> AnalysisEngine.
>
> No, but the FC could modify the CAS, e.g. set some FS to say what view an
> annotator should switch to.
> If you can modify the annotator code it's very easy to make it sofa aware
> and, say, iterate over all views, or all matching some prefix, or those
> specified in a config param.
>
> ~Burn
>
>
> On Mon, Dec 3, 2012 at 5:57 PM, Richard Eckart de Castilho <
> eckart@ukp.informatik.tu-darmstadt.de> wrote:
>
> > Am 03.12.2012 um 23:32 schrieb Himanshu Gahlot <
> > himanshu.gahlot86@gmail.com>:
> >
> > > One more question on a related note: Is it possible to set sofa
> mappings
> > in
> > > the Flow Controller? From all the code usages that I have come across
> it
> > > seems that sofa mappings can only be set while building the
> > AnalysisEngine.
> >
> >
> > Good question. I don't know. I think it's not possible since the JavaDoc
> of
> > the reconfigure() methods says the method is used only to update a
> > component
> > with new parameters. Also, the sofa mappings are read directly from the
> > component descriptor which is afaik not accessible by a flow controller.
> >
> > I think sofa mappings can only be configured "statically". You probably
> > could dynamically create a nested pipeline in your flow controller. I
> > didn't use flow controllers very much so far.
> >
> > Maybe someone else has a better idea.
> >
> > -- Richard
> >
> > --
> > -------------------------------------------------------------------
> > 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: Is is possible to pass cas view to the process method of an annotator?

Posted by Burn Lewis <bu...@gmail.com>.
> One more question on a related note: Is it possible to set sofa mappings
in
> the Flow Controller? From all the code usages that I have come across it
> seems that sofa mappings can only be set while building the
AnalysisEngine.

No, but the FC could modify the CAS, e.g. set some FS to say what view an
annotator should switch to.
If you can modify the annotator code it's very easy to make it sofa aware
and, say, iterate over all views, or all matching some prefix, or those
specified in a config param.

~Burn


On Mon, Dec 3, 2012 at 5:57 PM, Richard Eckart de Castilho <
eckart@ukp.informatik.tu-darmstadt.de> wrote:

> Am 03.12.2012 um 23:32 schrieb Himanshu Gahlot <
> himanshu.gahlot86@gmail.com>:
>
> > One more question on a related note: Is it possible to set sofa mappings
> in
> > the Flow Controller? From all the code usages that I have come across it
> > seems that sofa mappings can only be set while building the
> AnalysisEngine.
>
>
> Good question. I don't know. I think it's not possible since the JavaDoc of
> the reconfigure() methods says the method is used only to update a
> component
> with new parameters. Also, the sofa mappings are read directly from the
> component descriptor which is afaik not accessible by a flow controller.
>
> I think sofa mappings can only be configured "statically". You probably
> could dynamically create a nested pipeline in your flow controller. I
> didn't use flow controllers very much so far.
>
> Maybe someone else has a better idea.
>
> -- Richard
>
> --
> -------------------------------------------------------------------
> 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: Is is possible to pass cas view to the process method of an annotator?

Posted by Richard Eckart de Castilho <ec...@ukp.informatik.tu-darmstadt.de>.
Am 03.12.2012 um 23:32 schrieb Himanshu Gahlot <hi...@gmail.com>:

> One more question on a related note: Is it possible to set sofa mappings in
> the Flow Controller? From all the code usages that I have come across it
> seems that sofa mappings can only be set while building the AnalysisEngine.


Good question. I don't know. I think it's not possible since the JavaDoc of
the reconfigure() methods says the method is used only to update a component
with new parameters. Also, the sofa mappings are read directly from the
component descriptor which is afaik not accessible by a flow controller.

I think sofa mappings can only be configured "statically". You probably 
could dynamically create a nested pipeline in your flow controller. I
didn't use flow controllers very much so far.

Maybe someone else has a better idea.

-- Richard

-- 
------------------------------------------------------------------- 
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: Is is possible to pass cas view to the process method of an annotator?

Posted by Himanshu Gahlot <hi...@gmail.com>.
One more question on a related note: Is it possible to set sofa mappings in
the Flow Controller? From all the code usages that I have come across it
seems that sofa mappings can only be set while building the AnalysisEngine.

Himanshu



On Mon, Dec 3, 2012 at 2:17 PM, Himanshu Gahlot <himanshu.gahlot86@gmail.com
> wrote:

> Thanks Richard! I was looking for the 'Maybe' solution and it should work
> for my use case.
>
> Himanshu
>
>
>
> On Mon, Dec 3, 2012 at 11:20 AM, Richard Eckart de Castilho <
> eckart@ukp.informatik.tu-darmstadt.de> wrote:
>
>> Hello Himanshu,
>>
>> yes, no and maybe.
>>
>> Yes: you can use "Sofa mapping". You should find corresponding
>> configuration possibilities
>> on aggregate analysis engines and in the CPEs.
>>
>> In uimaFIT you'd want to look at the AggregateBuilder:
>>
>>
>> http://uimafit.googlecode.com/svn/trunk/apidocs/org/uimafit/factory/AggregateBuilder.html
>>
>> No: a Sofa mapping only maps a particular named view to the default view
>> of an AE, it cannot
>> pass one view after the other to an AE.
>>
>> Maybe: if you don't mind, you should be able to have your process three
>> times in an aggregate and
>> every time you map another view to its default view.
>>
>> Cheers,
>>
>> -- Richard
>>
>> Am 03.12.2012 um 19:48 schrieb Himanshu Gahlot <
>> himanshu.gahlot86@gmail.com>
>> :
>>
>> > Hi,
>> >
>> > I want to create 3 views of the base cas and pass them one by one to
>> the process
>> > method of my annotator. From the documentation I know that we can pass
>> only the
>> > base cas to the anlaysis engine unless the annotator is sofa aware. But
>> even if
>> > the annotator is sofa aware I am not able to pass any view to the
>> annotator,
>> > since the cas passed in the sofa aware annotator has no sofa attached
>> to it and
>> > I need to fetch/create the view in the process method itself. Is there
>> a way so
>> > that I do not have to write the view accessing logic within the
>> annotator and
>> > can pass a view of the cas to the process method itself? In short, I
>> would like
>> > the following functionality to work:
>> >
>> > JCas casView1 = baseCas.createView("view1");
>> > ae.process(casView1);
>> >
>> > and in the process method of the annotator, the cas should be the
>> casView1.
>>
>>
>> --
>> -------------------------------------------------------------------
>> 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: Is is possible to pass cas view to the process method of an annotator?

Posted by Himanshu Gahlot <hi...@gmail.com>.
Thanks Richard! I was looking for the 'Maybe' solution and it should work
for my use case.

Himanshu



On Mon, Dec 3, 2012 at 11:20 AM, Richard Eckart de Castilho <
eckart@ukp.informatik.tu-darmstadt.de> wrote:

> Hello Himanshu,
>
> yes, no and maybe.
>
> Yes: you can use "Sofa mapping". You should find corresponding
> configuration possibilities
> on aggregate analysis engines and in the CPEs.
>
> In uimaFIT you'd want to look at the AggregateBuilder:
>
>
> http://uimafit.googlecode.com/svn/trunk/apidocs/org/uimafit/factory/AggregateBuilder.html
>
> No: a Sofa mapping only maps a particular named view to the default view
> of an AE, it cannot
> pass one view after the other to an AE.
>
> Maybe: if you don't mind, you should be able to have your process three
> times in an aggregate and
> every time you map another view to its default view.
>
> Cheers,
>
> -- Richard
>
> Am 03.12.2012 um 19:48 schrieb Himanshu Gahlot <
> himanshu.gahlot86@gmail.com>
> :
>
> > Hi,
> >
> > I want to create 3 views of the base cas and pass them one by one to the
> process
> > method of my annotator. From the documentation I know that we can pass
> only the
> > base cas to the anlaysis engine unless the annotator is sofa aware. But
> even if
> > the annotator is sofa aware I am not able to pass any view to the
> annotator,
> > since the cas passed in the sofa aware annotator has no sofa attached to
> it and
> > I need to fetch/create the view in the process method itself. Is there a
> way so
> > that I do not have to write the view accessing logic within the
> annotator and
> > can pass a view of the cas to the process method itself? In short, I
> would like
> > the following functionality to work:
> >
> > JCas casView1 = baseCas.createView("view1");
> > ae.process(casView1);
> >
> > and in the process method of the annotator, the cas should be the
> casView1.
>
>
> --
> -------------------------------------------------------------------
> 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: Is is possible to pass cas view to the process method of an annotator?

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

yes, no and maybe.

Yes: you can use "Sofa mapping". You should find corresponding configuration possibilities
on aggregate analysis engines and in the CPEs.

In uimaFIT you'd want to look at the AggregateBuilder:

http://uimafit.googlecode.com/svn/trunk/apidocs/org/uimafit/factory/AggregateBuilder.html

No: a Sofa mapping only maps a particular named view to the default view of an AE, it cannot
pass one view after the other to an AE.

Maybe: if you don't mind, you should be able to have your process three times in an aggregate and
every time you map another view to its default view.

Cheers,

-- Richard

Am 03.12.2012 um 19:48 schrieb Himanshu Gahlot <hi...@gmail.com>
:

> Hi,
> 
> I want to create 3 views of the base cas and pass them one by one to the process
> method of my annotator. From the documentation I know that we can pass only the
> base cas to the anlaysis engine unless the annotator is sofa aware. But even if
> the annotator is sofa aware I am not able to pass any view to the annotator,
> since the cas passed in the sofa aware annotator has no sofa attached to it and
> I need to fetch/create the view in the process method itself. Is there a way so
> that I do not have to write the view accessing logic within the annotator and
> can pass a view of the cas to the process method itself? In short, I would like
> the following functionality to work:
> 
> JCas casView1 = baseCas.createView("view1");
> ae.process(casView1);
> 
> and in the process method of the annotator, the cas should be the casView1.


-- 
------------------------------------------------------------------- 
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
-------------------------------------------------------------------