You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Roberto Franchini <ro...@gmail.com> on 2008/01/24 11:46:03 UTC

POJOing uima, is it possible?

Hi to all,
I embedded a CPM in a Spring context (www.springframework.org) via a
wrapper class that parses AE xml (collectionreaders, annotators and
consumers) and push them in the CPM.
I did the same thing with aggregate AE to be used by a web app (here I
don't need collection readers nor consumers).

A snippet from the spring context:

	<bean name="listener" class="it.celi.uima.engine.Listener">
		<property name="cpm" ref="cpm" />
	</bean>

	<bean name="cpm" class="org.apache.uima.UIMAFramework"
factory-method="newCollectionProcessingManager">
		<description>The collection processing manager that holds uima
components</description>
	</bean>

	<bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
		<description>An Engine that wraps UIMA components: collection
readers, analsys engines and consumers</description>
		<property name="pearsInstallPath" value="${pears.base.path}installed" />
		<property name="cpm" ref="cpm">
			<description>The uderlying Collection Processing Manager</description>
		</property>
		<property name="listeners">
			<description>A collection of listeners to be attached to CPM</description>
			<list>
				<ref bean="listener" />
			</list>
		</property>
		<property name="readerDescriptors">
			<description>A collection of CollectionReaders: the entire pipeline
is activated for each reader</description>
			<list>
				<value>${conf.base.path}RecursiveFileSystemCollectionReader.xml</value>
			</list>
		</property>
		<property name="analisysDescriptors">
			<description>The pipeline of analysis: analysis engines, aggregates
and pears descriptors allowed</description>
			<list>
				<value>${conf.base.path}SentenceAnnotator.xml</value>
				<value>${conf.base.path}RegExpTokenizer.xml</value>
			</list>
		</property>
		<property name="consumerDescriptors">
			<list>
				<value>${conf.base.path}XmiWriterCasConsumer.xml</value>
				<value>${conf.base.path}XCasWriterCasConsumer.xml</value>
			</list>
		</property>
	</bean>

Now I would go a step forward and avoid UIMA xml descritptor, please
don't blame me :)
What I'm looking for is something like this:

RegExpNormalizer annotator = new RegExpNormalizer();

annotar.setAProperty(value);
annotar.setAnotehrProperty(anotherValue);

CollectionProcessingManager cpm =
UIMAFramework.newCollectionProcessingManager();
cpm.add(annotator)

Where RegExpNormalizer  extends JCasAnnotator_ImplBase.

So in the spring context I can write:

	<bean name="normalizer" class="it.celi.uima.engine.RegExpNormalizer">
		<property name="aProperty" value="value"/>
		<property name="anotherProperty" value="anotherValue"/>
       </bean>

	<bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
[cut]
		<property name="analisysDescriptors">
			<description>The pipeline of analysis: analysis engines, aggregates
and pears descriptors allowed</description>
			<list>
				<ref bean="normalizer"/>
			</list>
		</property>

Is it possible to do that?
Thanks
Roberto
-- 
Roberto Franchini
CELI s.r.l.  (http://www.celi.it) - C.so Moncalieri 21 - 10131 Torino - ITALY
Tel +39-011-6600814 - Fax +39-011-6600687
jabber:ro.franchini@gmail.com skype:ro.franchini

Re: POJOing uima, is it possible?

Posted by Jaroslaw Cwiklik <cw...@us.ibm.com>.




I am not aware of anyone trying such initialization approach for the CPM,
but this should be doable. Two issues here

1) how to configure the CPM using spring xml
2) how to start processing of the CPM deployed in the Spring Container.

1) The cpm can be configured programatically. I think there are examples in
the programmer's guide. So you can create a Spring wrapper
(with setter methods) that you can populate in spring xml. Add spring
init-method on the wrapper bean which gets called by Spring when all the
setter methods
complete and intialize the cpm. The initialization of the cpm is
synchronous. Meaning that the Spring  container instantiates all the beans
sequentially, based
on dependencies you setup in spring xml. Once all the beans are created and
initialized the container returns controll to the client.

2) Once the Spring container deploys all the beans ( and consequently the
CPM), you can query the container for an instance of
your cpm wrapper ( by bean id or class name) and call a method that will
start the CPM.

jc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Jerry Cwiklik
 UIMA Extensions
 IBM T.J.  Watson Research Center
 Hawtorne, NY, 10532
 Tel: 914-784-7665,  T/L: 863-7665
 Email: cwiklik@us.ibm.com



                                                                           
             "Roberto                                                      
             Franchini"                                                    
             <ro.franchini@gma                                          To 
             il.com>                   uima-user@incubator.apache.org      
                                                                        cc 
             01/24/2008 11:09                                              
             AM                                                    Subject 
                                       Re: POJOing uima, is it possible?   
                                                                           
             Please respond to                                             
             uima-user@incubat                                             
               or.apache.org                                               
                                                                           
                                                                           




On Jan 24, 2008 4:02 PM, Jaroslaw Cwiklik <cw...@us.ibm.com> wrote:
>
>
> Not sure if I fully grasp what you are trying to do.
>
>
>  <bean name="normalizer" class="it.celi.uima.engine.RegExpNormalizer">
>  <property name="aProperty" value="value"/>
>  <property name="anotherProperty" value="anotherValue"/>
>        </bean>
>
>  <bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
>  [cut]
>  <property name="analisysDescriptors">
>  <description>The pipeline of analysis: analysis engines, aggregates
>  and pears descriptors allowed</description>
>  <list>
>  <ref bean="normalizer"/>
>  </list>
>  </property>
>  In the above you are specifying spring beans which are wrappers (I
presume)
> around uima components. The uima spring bean
>  under the covers crates an instance of the cpm ( I presume). What I dont
> see is how you are initializing the cpm engine. I only
>  see the AE being plugged in (the normalizer).

This snippet is what I would, not what i have :(

The previous xml snippet is what I have now: CPM or aggregate analysis
wrapper that parses UIMA XML descriptors and the add
Processors/consumers to a CPM or AAE.

Now i want to simplyfy the configuration and configuring ALL
components in the spring xml format.
The better way would be instatntiating annotars as beans and add theme
to a cpm/cpe.
MAybe I should implements a cpm that allows this way of deployment.
I watched at uima source, but i didn't find a way to do this (and i
don'y know if it is possible!)


>
>  Incidentally, we are working on a replacement for the cpm that uses
Spring
> extensively. The new approach is based on asynchronous
>  architecture using JMS ( ActiveMQ specifically) for transport.
>
This is very interesting. I read about it on the wiki and maybe on the ml.
Roberto

--
Roberto Franchini
CELI s.r.l.  (http://www.celi.it) - C.so Moncalieri 21 - 10131 Torino -
ITALY
Tel +39-011-6600814 - Fax +39-011-6600687
jabber:ro.franchini@gmail.com skype:ro.franchini

Re: POJOing uima, is it possible?

Posted by Roberto Franchini <ro...@gmail.com>.
On Jan 24, 2008 4:02 PM, Jaroslaw Cwiklik <cw...@us.ibm.com> wrote:
>
>
> Not sure if I fully grasp what you are trying to do.
>
>
>  <bean name="normalizer" class="it.celi.uima.engine.RegExpNormalizer">
>  <property name="aProperty" value="value"/>
>  <property name="anotherProperty" value="anotherValue"/>
>        </bean>
>
>  <bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
>  [cut]
>  <property name="analisysDescriptors">
>  <description>The pipeline of analysis: analysis engines, aggregates
>  and pears descriptors allowed</description>
>  <list>
>  <ref bean="normalizer"/>
>  </list>
>  </property>
>  In the above you are specifying spring beans which are wrappers (I presume)
> around uima components. The uima spring bean
>  under the covers crates an instance of the cpm ( I presume). What I dont
> see is how you are initializing the cpm engine. I only
>  see the AE being plugged in (the normalizer).

This snippet is what I would, not what i have :(

The previous xml snippet is what I have now: CPM or aggregate analysis
wrapper that parses UIMA XML descriptors and the add
Processors/consumers to a CPM or AAE.

Now i want to simplyfy the configuration and configuring ALL
components in the spring xml format.
The better way would be instatntiating annotars as beans and add theme
to a cpm/cpe.
MAybe I should implements a cpm that allows this way of deployment.
I watched at uima source, but i didn't find a way to do this (and i
don'y know if it is possible!)


>
>  Incidentally, we are working on a replacement for the cpm that uses Spring
> extensively. The new approach is based on asynchronous
>  architecture using JMS ( ActiveMQ specifically) for transport.
>
This is very interesting. I read about it on the wiki and maybe on the ml.
Roberto

-- 
Roberto Franchini
CELI s.r.l.  (http://www.celi.it) - C.so Moncalieri 21 - 10131 Torino - ITALY
Tel +39-011-6600814 - Fax +39-011-6600687
jabber:ro.franchini@gmail.com skype:ro.franchini

Re: POJOing uima, is it possible?

Posted by Jaroslaw Cwiklik <cw...@us.ibm.com>.




Not sure if I fully grasp what you are trying to do.

             <bean name="normalizer"
class="it.celi.uima.engine.RegExpNormalizer">
                         <property name="aProperty" value="value"/>
                         <property name="anotherProperty"
value="anotherValue"/>
       </bean>

             <bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
[cut]
                         <property name="analisysDescriptors">
                                     <description>The pipeline of analysis:
analysis engines, aggregates
and pears descriptors allowed</description>
                                     <list>
                                                 <ref bean="normalizer"/>
                                     </list>
                         </property>
In the above you are specifying spring beans which are wrappers (I presume)
around uima components. The uima spring bean
under the covers crates an instance of the cpm ( I presume). What I dont
see is how you are initializing the cpm engine. I only
see the AE being plugged in (the normalizer).

Incidentally, we are working on a replacement for the cpm that uses Spring
extensively. The new approach is based on asynchronous
architecture using JMS ( ActiveMQ specifically) for transport.

jerry cwiklik


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Jerry Cwiklik
 UIMA Extensions
 IBM T.J.  Watson Research Center
 Hawtorne, NY, 10532
 Tel: 914-784-7665,  T/L: 863-7665
 Email: cwiklik@us.ibm.com



                                                                           
             "Roberto                                                      
             Franchini"                                                    
             <ro.franchini@gma                                          To 
             il.com>                   uima-user@incubator.apache.org      
                                                                        cc 
             01/24/2008 05:46                                              
             AM                                                    Subject 
                                       POJOing uima, is it possible?       
                                                                           
             Please respond to                                             
             uima-user@incubat                                             
               or.apache.org                                               
                                                                           
                                                                           




Hi to all,
I embedded a CPM in a Spring context (www.springframework.org) via a
wrapper class that parses AE xml (collectionreaders, annotators and
consumers) and push them in the CPM.
I did the same thing with aggregate AE to be used by a web app (here I
don't need collection readers nor consumers).

A snippet from the spring context:

             <bean name="listener" class="it.celi.uima.engine.Listener">
                         <property name="cpm" ref="cpm" />
             </bean>

             <bean name="cpm" class="org.apache.uima.UIMAFramework"
factory-method="newCollectionProcessingManager">
                         <description>The collection processing manager
that holds uima
components</description>
             </bean>

             <bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
                         <description>An Engine that wraps UIMA components:
collection
readers, analsys engines and consumers</description>
                         <property name="pearsInstallPath"
value="${pears.base.path}installed" />
                         <property name="cpm" ref="cpm">
                                     <description>The uderlying Collection
Processing Manager</description>
                         </property>
                         <property name="listeners">
                                     <description>A collection of listeners
to be attached to CPM</description>
                                     <list>
                                                 <ref bean="listener" />
                                     </list>
                         </property>
                         <property name="readerDescriptors">
                                     <description>A collection of
CollectionReaders: the entire pipeline
is activated for each reader</description>
                                     <list>

<value>${conf.base.path}RecursiveFileSystemCollectionReader.xml</value>
                                     </list>
                         </property>
                         <property name="analisysDescriptors">
                                     <description>The pipeline of analysis:
analysis engines, aggregates
and pears descriptors allowed</description>
                                     <list>

<value>${conf.base.path}SentenceAnnotator.xml</value>

<value>${conf.base.path}RegExpTokenizer.xml</value>
                                     </list>
                         </property>
                         <property name="consumerDescriptors">
                                     <list>

<value>${conf.base.path}XmiWriterCasConsumer.xml</value>

<value>${conf.base.path}XCasWriterCasConsumer.xml</value>
                                     </list>
                         </property>
             </bean>

Now I would go a step forward and avoid UIMA xml descritptor, please
don't blame me :)
What I'm looking for is something like this:

RegExpNormalizer annotator = new RegExpNormalizer();

annotar.setAProperty(value);
annotar.setAnotehrProperty(anotherValue);

CollectionProcessingManager cpm =
UIMAFramework.newCollectionProcessingManager();
cpm.add(annotator)

Where RegExpNormalizer  extends JCasAnnotator_ImplBase.

So in the spring context I can write:

             <bean name="normalizer"
class="it.celi.uima.engine.RegExpNormalizer">
                         <property name="aProperty" value="value"/>
                         <property name="anotherProperty"
value="anotherValue"/>
       </bean>

             <bean name="uima" class="it.celi.uima.engine.CpmUIMAEngine">
[cut]
                         <property name="analisysDescriptors">
                                     <description>The pipeline of analysis:
analysis engines, aggregates
and pears descriptors allowed</description>
                                     <list>
                                                 <ref bean="normalizer"/>
                                     </list>
                         </property>

Is it possible to do that?
Thanks
Roberto
--
Roberto Franchini
CELI s.r.l.  (http://www.celi.it) - C.so Moncalieri 21 - 10131 Torino -
ITALY
Tel +39-011-6600814 - Fax +39-011-6600687
jabber:ro.franchini@gmail.com skype:ro.franchini