You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Adei Mandaluniz <am...@zaizi.com> on 2011/11/18 11:15:05 UTC

UIMA packaging for integration

Hi,

I'm quite a newbie using UIMA and my question may be (I'm sure it is) a
basic question.

Here it go...

I've created my own Annotator, what I want to do is integrate it with
java-spring based application so I can post some text to the annotator and
get the annotations back.
So the question is, how can I integrate it with another application? Do I
need to package it as something else than PEAR, or do I need to deploy it
on a server and call it as an external tool, if so, how?

Thanks in advance!
Adei


This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.

Re: UIMA packaging for integration

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

> Nov 20, 2011 4:34:39 PM
>> Caused by: org.apache.uima.cas.CASRuntimeException: JCas type
>> "org.uimafit.type.RoomNumber" used in Java code,  but was not declared in
>> the XML type descriptor.

You seem not to initialize the type system properly. This line should load the type system from the classpath (e.g. from src/main/resources).

	TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription("org.uimafit.type.RoomNumber");

With uimaFIT you don't need the RoomNumbersAE.xml. Most people using uimaFIT would generate that using the AnalysisEngineFactory. The second parameter you can pass to the createPrimitive() method is where you plug your type system in.

	AnalysisEngine analysisEngine = AnalysisEngineDescription.createPrimitive(RoomNumberAnnotator.class, tsd);

If you use uimaFIT, looking at your XML files does not give me a base to advice you. Instead, the Java code that you use to run your
pipeline would be more helpful.

You may find some runnable examples adapted from the official UIMA examples for uimaFIT in the "uimafit-examples" subproject, e.g. here

http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-examples/src/main/java/org/uimafit/examples/tutorial/ex1/RoomNumberAnnotatorPipeline.java
http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-examples/src/main/java/org/uimafit/examples/tutorial/ex2/RoomNumberAnnotatorPipeline.java

Best,

-- Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
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
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
------------------------------------------------------------------- 





Re: UIMA packaging for integration

Posted by Adei Mandaluniz <am...@zaizi.com>.
Hello,

I'm playing around with UIMAFit, trying the RoomNumberAnnotator but I'm
getting an error:

Nov 20, 2011 4:34:39 PM
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl
> callAnalysisComponentProcess(405)
> SEVERE: Exception occurred
> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator
> processing failed.
> at
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(
> PrimitiveAnalysisEngine_impl.java:391)
> at
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(
> PrimitiveAnalysisEngine_impl.java:295)
> at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(
> AnalysisEngineImplBase.java:267)
> at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(
> AnalysisEngineImplBase.java:280)
> at org.uimafit.RoomNumbersAEPipeline.main(RoomNumbersAEPipeline.java:28)
> Caused by: org.apache.uima.cas.CASRuntimeException: JCas type
> "org.uimafit.type.RoomNumber" used in Java code,  but was not declared in
> the XML type descriptor.
> at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:412)
> at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:92)
> at org.apache.uima.jcas.cas.AnnotationBase.<init>(AnnotationBase.java:53)
> at org.apache.uima.jcas.tcas.Annotation.<init>(Annotation.java:54)
> at org.uimafit.type.RoomNumber.<init>(RoomNumber.java:61)
> at org.uimafit.ae.RoomNumbersAE.process(RoomNumbersAE.java:36)
> at org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(
> JCasAnnotator_ImplBase.java:48)
> at
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(
> PrimitiveAnalysisEngine_impl.java:377)
> ... 4 more
> Exception in thread "main"
> org.apache.uima.analysis_engine.AnalysisEngineProcessException: Annotator
> processing failed.
> at
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(
> PrimitiveAnalysisEngine_impl.java:391)
> at
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(
> PrimitiveAnalysisEngine_impl.java:295)
> at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(
> AnalysisEngineImplBase.java:267)
> at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(
> AnalysisEngineImplBase.java:280)
> at org.uimafit.RoomNumbersAEPipeline.main(RoomNumbersAEPipeline.java:28)
> Caused by: org.apache.uima.cas.CASRuntimeException: JCas type
> "org.uimafit.type.RoomNumber" used in Java code,  but was not declared in
> the XML type descriptor.
> at org.apache.uima.jcas.impl.JCasImpl.getType(JCasImpl.java:412)
> at org.apache.uima.jcas.cas.TOP.<init>(TOP.java:92)
> at org.apache.uima.jcas.cas.AnnotationBase.<init>(AnnotationBase.java:53)
> at org.apache.uima.jcas.tcas.Annotation.<init>(Annotation.java:54)
> at org.uimafit.type.RoomNumber.<init>(RoomNumber.java:61)
> at org.uimafit.ae.RoomNumbersAE.process(RoomNumbersAE.java:36)
> at org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(
> JCasAnnotator_ImplBase.java:48)
> at
> org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(
> PrimitiveAnalysisEngine_impl.java:377)
> ... 4 more


The *RoomNumber.xml* (places in src/main/resources/org/uimafit/type) looks
like this:

<?xml version="1.0" encoding="UTF-8"?>
> <typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
>     <types>
>         <typeDescription>
>           <name>org.apache.uima.tutorial.RoomNumber</name>
>           <description/>
>           <supertypeName>uima.tcas.Annotation</supertypeName>
>           <features>
>             <featureDescription>
>               <name>building</name>
>               <description/>
>               <rangeTypeName>uima.cas.String</rangeTypeName>
>             </featureDescription>
>           </features>
>         </typeDescription>
>       </types>
> </typeSystemDescription>


Also the *RoomNumbersAE.xml* (placed in src/main/resources/org/uimafit)
looks like this:

<?xml version="1.0" encoding="UTF-8"?>
> <analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier
> ">
>     <frameworkImplementation>org.apache.uima.java</frameworkImplementation
> >
>     <primitive>true</primitive>
>     <annotatorImplementationName>org.uimafit.ae.RoomNumbersAE</
> annotatorImplementationName>
>     <analysisEngineMetaData>
>         <name>org.uimafit.ae.RoomNumbersAE</name>
>         <description>Descriptor automatically generated by uimaFIT</
> description>
>         <version>unknown</version>
>         <vendor>org.uimafit.ae</vendor>
>         <configurationParameters/>
>         <configurationParameterSettings/>
>         <typeSystemDescription>
>             <imports>
>                 <import name="org.uimafit.type.RoomNumber"/>
>             </imports>
>         </typeSystemDescription>
>         <fsIndexCollection/>
>         <capabilities/>
>         <operationalProperties>
>             <modifiesCas>true</modifiesCas>
>             <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
>             <outputsNewCASes>false</outputsNewCASes>
>         </operationalProperties>
>     </analysisEngineMetaData>
> </analysisEngineDescription>


Is there anything wrong with them?

Thanks!

On Fri, Nov 18, 2011 at 2:54 PM, Adei Mandaluniz <am...@zaizi.com>wrote:

> Thanks Richard,
>
> I'll give it a try! Obviously this would be for prototype and demo
> purposes...
>
> Regards,
> Adei
>
>
> On Fri, Nov 18, 2011 at 1:33 PM, Richard Eckart de Castilho <
> eckartde@tk.informatik.tu-darmstadt.de> wrote:
>
>> Hello Adei,
>>
>> unless you need classpath separation (which is a feature of PEARs), I
>> would suggest you just create instances of your UIMA components in some
>> Spring bean and run them. I would suggest to try using uimaFIT for this,
>> e.g.:
>>
>>                TypeSystemDescription tsd =
>> TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
>>
>>  "src/test/resources/org/uimafit/type/AnalyzedText.xml");
>>
>>                 // Instantiate component
>>                AnalysisEngine ae =
>> AnalysisEngineFactory.createPrimitive(MyAnalysisEngine.class, tsd);
>>
>>                JCas jcas = ae.newJCas();
>>                jcas.setDocumenText("my text");
>>
>>                // Test that injection works
>>                ae.process(jcas);
>>
>>                for (MyAnnotation a : JCasUtil.select(jcas,
>> MyAnnotation.class)) {
>>                        ... do something with your analysis;
>>                }
>>
>> If you are interested in using UIMA within Spring, you might be
>> interested in the (experimental) uimafit-spring bridge. It provides
>>
>> 1) a way to inject Spring beans as UIMA external resources into UIMA
>> components
>> 2) a way to run the bean postprocessors of your Spring context on your
>> UIMA components so that the actual Spring annotations work, e.g. @Resource
>> or possible @Transactional etc.
>>
>>
>> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/SpringContextResourceManagerTest.java
>>
>> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/UimaFactoryInjectionTest.java
>>
>> Note that if you bind this tightly to your Spring context, you will not
>> be able to use UIMA's scale-out features. But for small systems or
>> prototypes, its can be very useful.
>>
>> Best,
>>
>> -- Richard
>>
>> Am 18.11.2011 um 11:15 schrieb Adei Mandaluniz:
>>
>> > Hi,
>> >
>> > I'm quite a newbie using UIMA and my question may be (I'm sure it is) a
>> > basic question.
>> >
>> > Here it go...
>> >
>> > I've created my own Annotator, what I want to do is integrate it with
>> > java-spring based application so I can post some text to the annotator
>> and
>> > get the annotations back.
>> > So the question is, how can I integrate it with another application? Do
>> I
>> > need to package it as something else than PEAR, or do I need to deploy
>> it
>> > on a server and call it as an external tool, if so, how?
>> >
>> > Thanks in advance!
>> > Adei
>> >
>> >
>> > This message should be regarded as confidential. If you have received
>> this email in error please notify the sender and destroy it immediately.
>> Statements of intent shall only become binding when confirmed in hard copy
>> by an authorised signatory.
>> >
>> > Zaizi Ltd is registered in England and Wales with the registration
>> number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam
>> Road, London W10 5JJ, UK.
>>
>>
>> --
>> -------------------------------------------------------------------
>> Richard Eckart de Castilho
>> Technical Lead
>> Ubiquitous Knowledge Processing Lab
>> 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
>> eckartde@tk.informatik.tu-darmstadt.de
>> www.ukp.tu-darmstadt.de
>> Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
>> -------------------------------------------------------------------
>>
>>
>>
>>
>>


This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


Re: UIMA packaging for integration

Posted by Adei Mandaluniz <am...@zaizi.com>.
Thanks Richard,

I'll give it a try! Obviously this would be for prototype and demo
purposes...

Regards,
Adei

On Fri, Nov 18, 2011 at 1:33 PM, Richard Eckart de Castilho <
eckartde@tk.informatik.tu-darmstadt.de> wrote:

> Hello Adei,
>
> unless you need classpath separation (which is a feature of PEARs), I
> would suggest you just create instances of your UIMA components in some
> Spring bean and run them. I would suggest to try using uimaFIT for this,
> e.g.:
>
>                TypeSystemDescription tsd =
> TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
>
>  "src/test/resources/org/uimafit/type/AnalyzedText.xml");
>
>                 // Instantiate component
>                AnalysisEngine ae =
> AnalysisEngineFactory.createPrimitive(MyAnalysisEngine.class, tsd);
>
>                JCas jcas = ae.newJCas();
>                jcas.setDocumenText("my text");
>
>                // Test that injection works
>                ae.process(jcas);
>
>                for (MyAnnotation a : JCasUtil.select(jcas,
> MyAnnotation.class)) {
>                        ... do something with your analysis;
>                }
>
> If you are interested in using UIMA within Spring, you might be interested
> in the (experimental) uimafit-spring bridge. It provides
>
> 1) a way to inject Spring beans as UIMA external resources into UIMA
> components
> 2) a way to run the bean postprocessors of your Spring context on your
> UIMA components so that the actual Spring annotations work, e.g. @Resource
> or possible @Transactional etc.
>
>
> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/SpringContextResourceManagerTest.java
>
> http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/UimaFactoryInjectionTest.java
>
> Note that if you bind this tightly to your Spring context, you will not be
> able to use UIMA's scale-out features. But for small systems or prototypes,
> its can be very useful.
>
> Best,
>
> -- Richard
>
> Am 18.11.2011 um 11:15 schrieb Adei Mandaluniz:
>
> > Hi,
> >
> > I'm quite a newbie using UIMA and my question may be (I'm sure it is) a
> > basic question.
> >
> > Here it go...
> >
> > I've created my own Annotator, what I want to do is integrate it with
> > java-spring based application so I can post some text to the annotator
> and
> > get the annotations back.
> > So the question is, how can I integrate it with another application? Do I
> > need to package it as something else than PEAR, or do I need to deploy it
> > on a server and call it as an external tool, if so, how?
> >
> > Thanks in advance!
> > Adei
> >
> >
> > This message should be regarded as confidential. If you have received
> this email in error please notify the sender and destroy it immediately.
> Statements of intent shall only become binding when confirmed in hard copy
> by an authorised signatory.
> >
> > Zaizi Ltd is registered in England and Wales with the registration
> number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam
> Road, London W10 5JJ, UK.
>
>
> --
> -------------------------------------------------------------------
> Richard Eckart de Castilho
> Technical Lead
> Ubiquitous Knowledge Processing Lab
> 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
> eckartde@tk.informatik.tu-darmstadt.de
> www.ukp.tu-darmstadt.de
> Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
> -------------------------------------------------------------------
>
>
>
>
>


-- 
*Adei Mandaluniz
Lead Consultant

Zaizi Limited
<http://www.zaizi.com>222 Westbourne Studios
242 Acklam Road
<http://maps.google.com/maps?q=203+Westbourne+Studios%2C242+Acklam+Road%2CLondon+W10+5JJ%2CUK&hl=en>London
W10 5JJ UK
Work: +44 (0)20 7617 7943
Mobile: + 44 (0)79 0909 2805
Email: amandaluniz@zaizi.com
Skype: amandaluniz


*


This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.

Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


Re: UIMA packaging for integration

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

unless you need classpath separation (which is a feature of PEARs), I would suggest you just create instances of your UIMA components in some Spring bean and run them. I would suggest to try using uimaFIT for this, e.g.:

		TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
                                "src/test/resources/org/uimafit/type/AnalyzedText.xml");

		 // Instantiate component
                AnalysisEngine ae = AnalysisEngineFactory.createPrimitive(MyAnalysisEngine.class, tsd);

		JCas jcas = ae.newJCas();
		jcas.setDocumenText("my text");

                // Test that injection works
                ae.process(jcas);

		for (MyAnnotation a : JCasUtil.select(jcas, MyAnnotation.class)) {
			... do something with your analysis;
		}

If you are interested in using UIMA within Spring, you might be interested in the (experimental) uimafit-spring bridge. It provides

1) a way to inject Spring beans as UIMA external resources into UIMA components
2) a way to run the bean postprocessors of your Spring context on your UIMA components so that the actual Spring annotations work, e.g. @Resource or possible @Transactional etc.

http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/SpringContextResourceManagerTest.java
http://code.google.com/p/uimafit/source/browse/trunk/uimaFIT-spring/src/test/java/org/uimafit/spring/UimaFactoryInjectionTest.java

Note that if you bind this tightly to your Spring context, you will not be able to use UIMA's scale-out features. But for small systems or prototypes, its can be very useful.

Best,

-- Richard

Am 18.11.2011 um 11:15 schrieb Adei Mandaluniz:

> Hi,
> 
> I'm quite a newbie using UIMA and my question may be (I'm sure it is) a
> basic question.
> 
> Here it go...
> 
> I've created my own Annotator, what I want to do is integrate it with
> java-spring based application so I can post some text to the annotator and
> get the annotations back.
> So the question is, how can I integrate it with another application? Do I
> need to package it as something else than PEAR, or do I need to deploy it
> on a server and call it as an external tool, if so, how?
> 
> Thanks in advance!
> Adei
> 
> 
> This message should be regarded as confidential. If you have received this email in error please notify the sender and destroy it immediately. Statements of intent shall only become binding when confirmed in hard copy by an authorised signatory.
> 
> Zaizi Ltd is registered in England and Wales with the registration number 6440931. The Registered Office is 203 Westbourne Studios, 242 Acklam Road, London W10 5JJ, UK.


-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
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
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
-------------------------------------------------------------------