You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Kai Schlamp <sc...@gmx.de> on 2009/06/16 12:46:14 UTC

Reuse serialized XMI CAS in a dynamic application.

Hi.

I store the serialized (XMI) CASes during my analysis process in a database to use them afterwards 
for further evaluation.
The problem is that later I don't have a CAS available for deserialization. Another problem is that 
my application is highly dynamic, analysis engines come and go. It is not guaranteed that an 
analysis engine (and the type system of it) is still there, when the XMI-CAS should be later 
deserialized. So it's not that easy to generate a new CAS that is compatible to the serialized CAS.
A solution I can think of is to store the type system together with the serialized CAS. That way a 
new CAS could be generated later from scratch with the help of the also stored type system (by using 
CASFactory.createCAS(typeSystem).getCAS()).

Here are my questions ;-)
What are my options to serialize and deserialize a type system?
Can I convert a TypeSystem to TypeSystemDescription (then serialization would be easy)?
Any suggestions for solving the whole problem in another way?

Best regards,
Kai






Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Thilo Goetz <tw...@gmx.de>.
Kai Schlamp wrote:
> Hi Thilo,
> 
>> Re Tong's comments: it's odd that we have the same
>> functionality twice, with different implementations.
>> I have no idea how that came about.  However, looking
>> at the source code, the alternative should have
>> exactly the same problems.
> 
> Tong is right.
> "TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem()).toXML;"
> produces another XML type system then TypeSystem2Xml.
> The creation of the CAS and the deserialization now works correctly with
> the type system from TypeSystemUtil.
> In my opinion TypeSystem2Xml is dispensable (if you want to avoid the
> duplication in a future version).
> For one TypeSystem2Xml is not even described in the current Javadocs,
> for another TypeSystemUtil is much more the way the UIMA framework works.
> 
> Nevertheless, here is a bug report for TypeSystem2Xml:
> https://issues.apache.org/jira/browse/UIMA-1388
> 
> Regards,
> Kai

As I see from Jira now, I've discovered this myself in
the past and already fixed it (about half a year ago).
This still doesn't explain why we have two classes to
do the same thing.  They both came in with the original
code grant, so we've lost the pre-Apache history...

--Thilo

Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Kai Schlamp <sc...@gmx.de>.
Hi Thilo,

> Re Tong's comments: it's odd that we have the same
> functionality twice, with different implementations.
> I have no idea how that came about.  However, looking
> at the source code, the alternative should have
> exactly the same problems.

Tong is right. "TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem()).toXML;" 
produces another XML type system then TypeSystem2Xml.
The creation of the CAS and the deserialization now works correctly with the type system from 
TypeSystemUtil.
In my opinion TypeSystem2Xml is dispensable (if you want to avoid the duplication in a future version).
For one TypeSystem2Xml is not even described in the current Javadocs, for another TypeSystemUtil is 
much more the way the UIMA framework works.

Nevertheless, here is a bug report for TypeSystem2Xml: https://issues.apache.org/jira/browse/UIMA-1388

Regards,
Kai


Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Thilo Goetz <tw...@gmx.de>.
Kai Schlamp wrote:
> I compared both type systems (the serialized type system of the CAS with
> the original type system).
> It seems the problems comes from those definitions that are only present
> in the serialized one:
> 
> <typeDescription>
>   <name>org.pubcurator.uima.ts.PubIdentifier[]</name>
>   <description/>
>   <supertypeName>uima.cas.FSArray</supertypeName>
> </typeDescription>
> 
> So it seems that the TypeSystem2Xml produces an not 100% compatible type
> system description (at least for deserialization of a CAS).
> Can you think of any workarounds? Any chance to get that fixed soon?
> Should I create a bug report (if it is one at all)?

Yes, this is a bug.  Please open a Jira issue, we'll
fix it asap.

Re Tong's comments: it's odd that we have the same
functionality twice, with different implementations.
I have no idea how that came about.  However, looking
at the source code, the alternative should have
exactly the same problems.

--Thilo

> 
> Regards,
> Kai
> 
> 
> 
> Kai Schlamp wrote:
>> Hi Thilo,
>>
>> thanks for your help.
>> I tried it the way you suggested. I just tested it with one type
>> system. And if I use my type system description directly instead of
>> the serialized/deserialized type system it works fine.
>> But when I use the deserialized type system (serialized by your
>> mentioned TypeSystem2Xml) to deserialize the CAS I get a
>> CASAdminException.
>> Below is the Exception, the original type system description, the
>> serialized type description via TypeSystem2Xml, and a little
>> serialized CAS test case.
>> Do you have an idea why this Exception occurs?
>>
>> The Exception:
>> CASAdminException: Can't derive from type "uima.cas.FSArray" since it
>> is inheritance final.
>>     at
>> org.apache.uima.cas.impl.TypeSystemImpl.addType(TypeSystemImpl.java:581)
>>     at
>> org.apache.uima.util.CasCreationUtils.setupTypeSystem(CasCreationUtils.java:733)
>>
>>     at
>> org.apache.uima.util.CasCreationUtils.doCreateCas(CasCreationUtils.java:590)
>>
>>     at
>> org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:352)
>>
>>     at
>> org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:304)
>>
>>     at
>> org.pubcurator.uima.utils.FullCasDeserializer.deserialize(FullCasDeserializer.java:56)
>>
>>     at
>> org.pubcurator.uima.utils.FullCasDeserializerTest.testDeserialize(FullCasDeserializerTest.java:36)
>>
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>     at
>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>>
>>     at
>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>
>>     at
>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>>
>>     at
>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>>
>>     at
>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>>
>>     at
>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>>
>>     at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
>>
>>     at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
>>
>>     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
>>     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
>>     at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
>>     at
>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>>
>>     at
>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>>
>>     at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
>>     at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>
>>     at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>
>>     at
>> org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
>>
>>     at
>> org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
>>
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>     at
>> org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)
>>
>>     at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
>>
>>     at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
>>
>>     at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
>>
>>     at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
>>
>>     at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
>>
>>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>     at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>
>>     at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>
>>     at java.lang.reflect.Method.invoke(Method.java:597)
>>     at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
>>     at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
>>     at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
>>     at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
>>
>>
>>
>> Orignial Type System Description:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
>>   <name>PubCurator TypeSystem</name>
>>   <description>This is the type system that PubCurator uses for data
>> representation.
>> All analysis engines used in PubCurator must output this type
>> system.</description>
>>   <version>1.0</version>
>>   <vendor>PubCurator</vendor>
>>   <types>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubAnnotation</name>
>>       <description/>
>>       <supertypeName>uima.tcas.Annotation</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>annotator</name>
>>           <description/>
>>          
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>score</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>identifiers</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>>           <elementType>org.pubcurator.uima.ts.PubIdentifier</elementType>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>spans</name>
>>           <description>One item for example can be devided in multiple
>> spans. For example, the phrase "</description>
>>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>>           <elementType>org.pubcurator.uima.ts.PubSpan</elementType>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>topic</name>
>>           <description/>
>>           <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubIdentifier</name>
>>       <description/>
>>       <supertypeName>uima.cas.TOP</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>identifierType</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>identifier</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubItem</name>
>>       <description/>
>>       <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubItemAssociation</name>
>>       <description/>
>>       <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>source</name>
>>           <description/>
>>           <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>destination</name>
>>           <description/>
>>           <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubAnnotator</name>
>>       <description/>
>>       <supertypeName>uima.cas.TOP</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>analyzerId</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>delegateName</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>analyzerVersion</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>note</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubEntity</name>
>>       <description/>
>>       <supertypeName>uima.tcas.Annotation</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>annotations</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>>           <elementType>org.pubcurator.uima.ts.PubAnnotation</elementType>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>score</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>annotator</name>
>>           <description/>
>>          
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>subEntities</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>>           <elementType>org.pubcurator.uima.ts.PubEntity</elementType>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>identifiers</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>>           <elementType>org.pubcurator.uima.ts.PubIdentifier</elementType>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>topic</name>
>>           <description/>
>>           <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubProperty</name>
>>       <description/>
>>       <supertypeName>uima.cas.TOP</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>key</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>value</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubSpan</name>
>>       <description/>
>>       <supertypeName>uima.tcas.Annotation</supertypeName>
>>     </typeDescription>
>>     <typeDescription>
>>       <name>org.pubcurator.uima.ts.PubTopic</name>
>>       <description/>
>>       <supertypeName>uima.cas.TOP</supertypeName>
>>       <features>
>>         <featureDescription>
>>           <name>namespace</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>         <featureDescription>
>>           <name>name</name>
>>           <description/>
>>           <rangeTypeName>uima.cas.String</rangeTypeName>
>>         </featureDescription>
>>       </features>
>>     </typeDescription>
>>   </types>
>> </typeSystemDescription>
>>
>>
>>
>>
>> Serialized Type System Description:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
>>     <types>
>>         <typeDescription>
>>             <name>uima.tcas.Annotation</name>
>>             <description/>
>>             <supertypeName>uima.cas.AnnotationBase</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>uima.tcas.DocumentAnnotation</name>
>>             <description/>
>>             <supertypeName>uima.tcas.Annotation</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>language</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubAnnotation</name>
>>             <description/>
>>             <supertypeName>uima.tcas.Annotation</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>annotator</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>score</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>identifiers</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>spans</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>topic</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubIdentifier</name>
>>             <description/>
>>             <supertypeName>uima.cas.TOP</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>identifierType</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>identifier</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubItem</name>
>>             <description/>
>>            
>> <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>annotator</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>score</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>identifiers</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>spans</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>topic</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubItemAssociation</name>
>>             <description/>
>>            
>> <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>annotator</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>score</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>identifiers</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>spans</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>topic</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>source</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>destination</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubAnnotator</name>
>>             <description/>
>>             <supertypeName>uima.cas.TOP</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>analyzerId</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>delegateName</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>analyzerVersion</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>note</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubEntity</name>
>>             <description/>
>>             <supertypeName>uima.tcas.Annotation</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>annotations</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotation[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>score</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>annotator</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>subEntities</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubEntity[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>identifiers</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>topic</name>
>>                     <description/>
>>                    
>> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubProperty</name>
>>             <description/>
>>             <supertypeName>uima.cas.TOP</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>key</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>value</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubSpan</name>
>>             <description/>
>>             <supertypeName>uima.tcas.Annotation</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>sofa</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>begin</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>end</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubTopic</name>
>>             <description/>
>>             <supertypeName>uima.cas.TOP</supertypeName>
>>             <features>
>>                 <featureDescription>
>>                     <name>namespace</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>                 <featureDescription>
>>                     <name>name</name>
>>                     <description/>
>>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>>                 </featureDescription>
>>             </features>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubIdentifier[]</name>
>>             <description/>
>>             <supertypeName>uima.cas.FSArray</supertypeName>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubSpan[]</name>
>>             <description/>
>>             <supertypeName>uima.cas.FSArray</supertypeName>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubAnnotation[]</name>
>>             <description/>
>>             <supertypeName>uima.cas.FSArray</supertypeName>
>>         </typeDescription>
>>         <typeDescription>
>>             <name>org.pubcurator.uima.ts.PubEntity[]</name>
>>             <description/>
>>             <supertypeName>uima.cas.FSArray</supertypeName>
>>         </typeDescription>
>>     </types>
>> </typeSystemDescription>
>>
>>
>>
>>
>>
>> Serialized CAS:
>>
>> <?xml version="1.0" encoding="UTF-8"?><xmi:XMI
>> xmlns:cas="http:///uima/cas.ecore" xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:ts="http:///org/pubcurator/uima/ts.ecore"
>> xmlns:tcas="http:///uima/tcas.ecore" xmi:version="2.0"><cas:NULL
>> xmi:id="0"/><cas:Sofa xmi:id="10" sofaNum="1"
>> sofaID="_InitialView"/><ts:PubAnnotation xmi:id="1" sofa="10"
>> begin="10" end="20" score="1000"/><cas:View sofa="10"
>> members="1"/></xmi:XMI>
>>
>>

Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Tong Fin <to...@gmail.com>.
Hi Kai,
I never use TypeSystem2Xml class.

But, I know that the following piece of code works for me.
Please give it a try and let us know.

        TypeSystemDescription tsDesc = TypeSystemUtil
.typeSystem2TypeSystemDescription (your_TypeSystem);
        FileOutputStream outTs;
        try {
            outTs = new FileOutputStream (fileName);
            tsDesc.toXML(outTs);
            outTs.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

-- Tong

Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Kai Schlamp <sc...@gmx.de>.
> So it seems that the TypeSystem2Xml produces an not 100% compatible type 
> system description (at least for deserialization of a CAS).

Ah sorry, I meant not deserialization the CAS, but creation of the CAS, as the Exception occurs when 
creating the CAS with:
CasCreationUtils.createCas(descriptor, null, new FsIndexDescription[0]);


Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Kai Schlamp <sc...@gmx.de>.
I compared both type systems (the serialized type system of the CAS with the original type system).
It seems the problems comes from those definitions that are only present in the serialized one:

<typeDescription>
   <name>org.pubcurator.uima.ts.PubIdentifier[]</name>
   <description/>
   <supertypeName>uima.cas.FSArray</supertypeName>
</typeDescription>

So it seems that the TypeSystem2Xml produces an not 100% compatible type system description (at 
least for deserialization of a CAS).
Can you think of any workarounds? Any chance to get that fixed soon? Should I create a bug report 
(if it is one at all)?

Regards,
Kai



Kai Schlamp wrote:
> Hi Thilo,
> 
> thanks for your help.
> I tried it the way you suggested. I just tested it with one type system. 
> And if I use my type system description directly instead of the 
> serialized/deserialized type system it works fine.
> But when I use the deserialized type system (serialized by your 
> mentioned TypeSystem2Xml) to deserialize the CAS I get a CASAdminException.
> Below is the Exception, the original type system description, the 
> serialized type description via TypeSystem2Xml, and a little serialized 
> CAS test case.
> Do you have an idea why this Exception occurs?
> 
> The Exception:
> CASAdminException: Can't derive from type "uima.cas.FSArray" since it is 
> inheritance final.
>     at 
> org.apache.uima.cas.impl.TypeSystemImpl.addType(TypeSystemImpl.java:581)
>     at 
> org.apache.uima.util.CasCreationUtils.setupTypeSystem(CasCreationUtils.java:733) 
> 
>     at 
> org.apache.uima.util.CasCreationUtils.doCreateCas(CasCreationUtils.java:590) 
> 
>     at 
> org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:352)
>     at 
> org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:304)
>     at 
> org.pubcurator.uima.utils.FullCasDeserializer.deserialize(FullCasDeserializer.java:56) 
> 
>     at 
> org.pubcurator.uima.utils.FullCasDeserializerTest.testDeserialize(FullCasDeserializerTest.java:36) 
> 
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> 
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
> 
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) 
> 
>     at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) 
> 
>     at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) 
> 
>     at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) 
> 
>     at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 
> 
>     at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>     at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) 
> 
>     at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) 
> 
>     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
>     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
>     at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
>     at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) 
> 
>     at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>     at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
>     at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) 
> 
>     at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
> 
>     at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
> 
>     at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
> 
>     at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
> 
>     at 
> org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62) 
> 
>     at 
> org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23) 
> 
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> 
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
> 
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at 
> org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574) 
> 
>     at 
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) 
> 
>     at 
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) 
> 
>     at 
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) 
> 
>     at 
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368) 
> 
>     at 
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) 
> 
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> 
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
> 
>     at java.lang.reflect.Method.invoke(Method.java:597)
>     at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
>     at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
>     at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
>     at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
> 
> 
> 
> Orignial Type System Description:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
>   <name>PubCurator TypeSystem</name>
>   <description>This is the type system that PubCurator uses for data 
> representation.
> All analysis engines used in PubCurator must output this type 
> system.</description>
>   <version>1.0</version>
>   <vendor>PubCurator</vendor>
>   <types>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubAnnotation</name>
>       <description/>
>       <supertypeName>uima.tcas.Annotation</supertypeName>
>       <features>
>         <featureDescription>
>           <name>annotator</name>
>           <description/>
>           
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>score</name>
>           <description/>
>           <rangeTypeName>uima.cas.Integer</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>identifiers</name>
>           <description/>
>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>           <elementType>org.pubcurator.uima.ts.PubIdentifier</elementType>
>         </featureDescription>
>         <featureDescription>
>           <name>spans</name>
>           <description>One item for example can be devided in multiple 
> spans. For example, the phrase "</description>
>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>           <elementType>org.pubcurator.uima.ts.PubSpan</elementType>
>         </featureDescription>
>         <featureDescription>
>           <name>topic</name>
>           <description/>
>           <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubIdentifier</name>
>       <description/>
>       <supertypeName>uima.cas.TOP</supertypeName>
>       <features>
>         <featureDescription>
>           <name>identifierType</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>identifier</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubItem</name>
>       <description/>
>       <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubItemAssociation</name>
>       <description/>
>       <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>       <features>
>         <featureDescription>
>           <name>source</name>
>           <description/>
>           <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>destination</name>
>           <description/>
>           <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubAnnotator</name>
>       <description/>
>       <supertypeName>uima.cas.TOP</supertypeName>
>       <features>
>         <featureDescription>
>           <name>analyzerId</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>delegateName</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>analyzerVersion</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>note</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubEntity</name>
>       <description/>
>       <supertypeName>uima.tcas.Annotation</supertypeName>
>       <features>
>         <featureDescription>
>           <name>annotations</name>
>           <description/>
>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>           <elementType>org.pubcurator.uima.ts.PubAnnotation</elementType>
>         </featureDescription>
>         <featureDescription>
>           <name>score</name>
>           <description/>
>           <rangeTypeName>uima.cas.Integer</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>annotator</name>
>           <description/>
>           
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>subEntities</name>
>           <description/>
>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>           <elementType>org.pubcurator.uima.ts.PubEntity</elementType>
>         </featureDescription>
>         <featureDescription>
>           <name>identifiers</name>
>           <description/>
>           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
>           <elementType>org.pubcurator.uima.ts.PubIdentifier</elementType>
>         </featureDescription>
>         <featureDescription>
>           <name>topic</name>
>           <description/>
>           <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubProperty</name>
>       <description/>
>       <supertypeName>uima.cas.TOP</supertypeName>
>       <features>
>         <featureDescription>
>           <name>key</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>value</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubSpan</name>
>       <description/>
>       <supertypeName>uima.tcas.Annotation</supertypeName>
>     </typeDescription>
>     <typeDescription>
>       <name>org.pubcurator.uima.ts.PubTopic</name>
>       <description/>
>       <supertypeName>uima.cas.TOP</supertypeName>
>       <features>
>         <featureDescription>
>           <name>namespace</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>         <featureDescription>
>           <name>name</name>
>           <description/>
>           <rangeTypeName>uima.cas.String</rangeTypeName>
>         </featureDescription>
>       </features>
>     </typeDescription>
>   </types>
> </typeSystemDescription>
> 
> 
> 
> 
> Serialized Type System Description:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
>     <types>
>         <typeDescription>
>             <name>uima.tcas.Annotation</name>
>             <description/>
>             <supertypeName>uima.cas.AnnotationBase</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>uima.tcas.DocumentAnnotation</name>
>             <description/>
>             <supertypeName>uima.tcas.Annotation</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>language</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubAnnotation</name>
>             <description/>
>             <supertypeName>uima.tcas.Annotation</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>annotator</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>score</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>identifiers</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>spans</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>topic</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubIdentifier</name>
>             <description/>
>             <supertypeName>uima.cas.TOP</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>identifierType</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>identifier</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubItem</name>
>             <description/>
>             
> <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>annotator</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>score</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>identifiers</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>spans</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>topic</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubItemAssociation</name>
>             <description/>
>             
> <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>annotator</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>score</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>identifiers</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>spans</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>topic</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>source</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>destination</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubAnnotator</name>
>             <description/>
>             <supertypeName>uima.cas.TOP</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>analyzerId</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>delegateName</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>analyzerVersion</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>note</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubEntity</name>
>             <description/>
>             <supertypeName>uima.tcas.Annotation</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>annotations</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotation[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>score</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>annotator</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>subEntities</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubEntity[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>identifiers</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>topic</name>
>                     <description/>
>                     
> <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubProperty</name>
>             <description/>
>             <supertypeName>uima.cas.TOP</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>key</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>value</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubSpan</name>
>             <description/>
>             <supertypeName>uima.tcas.Annotation</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>sofa</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>begin</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>end</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubTopic</name>
>             <description/>
>             <supertypeName>uima.cas.TOP</supertypeName>
>             <features>
>                 <featureDescription>
>                     <name>namespace</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>                 <featureDescription>
>                     <name>name</name>
>                     <description/>
>                     <rangeTypeName>uima.cas.String</rangeTypeName>
>                 </featureDescription>
>             </features>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubIdentifier[]</name>
>             <description/>
>             <supertypeName>uima.cas.FSArray</supertypeName>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubSpan[]</name>
>             <description/>
>             <supertypeName>uima.cas.FSArray</supertypeName>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubAnnotation[]</name>
>             <description/>
>             <supertypeName>uima.cas.FSArray</supertypeName>
>         </typeDescription>
>         <typeDescription>
>             <name>org.pubcurator.uima.ts.PubEntity[]</name>
>             <description/>
>             <supertypeName>uima.cas.FSArray</supertypeName>
>         </typeDescription>
>     </types>
> </typeSystemDescription>
> 
> 
> 
> 
> 
> Serialized CAS:
> 
> <?xml version="1.0" encoding="UTF-8"?><xmi:XMI 
> xmlns:cas="http:///uima/cas.ecore" xmlns:xmi="http://www.omg.org/XMI" 
> xmlns:ts="http:///org/pubcurator/uima/ts.ecore" 
> xmlns:tcas="http:///uima/tcas.ecore" xmi:version="2.0"><cas:NULL 
> xmi:id="0"/><cas:Sofa xmi:id="10" sofaNum="1" 
> sofaID="_InitialView"/><ts:PubAnnotation xmi:id="1" sofa="10" begin="10" 
> end="20" score="1000"/><cas:View sofa="10" members="1"/></xmi:XMI>
> 
> 


Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Kai Schlamp <sc...@gmx.de>.
Hi Thilo,

thanks for your help.
I tried it the way you suggested. I just tested it with one type system. And if I use my type system 
description directly instead of the serialized/deserialized type system it works fine.
But when I use the deserialized type system (serialized by your mentioned TypeSystem2Xml) to 
deserialize the CAS I get a CASAdminException.
Below is the Exception, the original type system description, the serialized type description via 
TypeSystem2Xml, and a little serialized CAS test case.
Do you have an idea why this Exception occurs?

The Exception:
CASAdminException: Can't derive from type "uima.cas.FSArray" since it is inheritance final.
	at org.apache.uima.cas.impl.TypeSystemImpl.addType(TypeSystemImpl.java:581)
	at org.apache.uima.util.CasCreationUtils.setupTypeSystem(CasCreationUtils.java:733)
	at org.apache.uima.util.CasCreationUtils.doCreateCas(CasCreationUtils.java:590)
	at org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:352)
	at org.apache.uima.util.CasCreationUtils.createCas(CasCreationUtils.java:304)
	at org.pubcurator.uima.utils.FullCasDeserializer.deserialize(FullCasDeserializer.java:56)
	at org.pubcurator.uima.utils.FullCasDeserializerTest.testDeserialize(FullCasDeserializerTest.java:36)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
	at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at 
org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:574)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at 
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)



Orignial Type System Description:

<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
   <name>PubCurator TypeSystem</name>
   <description>This is the type system that PubCurator uses for data representation.
All analysis engines used in PubCurator must output this type system.</description>
   <version>1.0</version>
   <vendor>PubCurator</vendor>
   <types>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubAnnotation</name>
       <description/>
       <supertypeName>uima.tcas.Annotation</supertypeName>
       <features>
         <featureDescription>
           <name>annotator</name>
           <description/>
           <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>score</name>
           <description/>
           <rangeTypeName>uima.cas.Integer</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>identifiers</name>
           <description/>
           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
           <elementType>org.pubcurator.uima.ts.PubIdentifier</elementType>
         </featureDescription>
         <featureDescription>
           <name>spans</name>
           <description>One item for example can be devided in multiple spans. For example, the 
phrase "</description>
           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
           <elementType>org.pubcurator.uima.ts.PubSpan</elementType>
         </featureDescription>
         <featureDescription>
           <name>topic</name>
           <description/>
           <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubIdentifier</name>
       <description/>
       <supertypeName>uima.cas.TOP</supertypeName>
       <features>
         <featureDescription>
           <name>identifierType</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>identifier</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubItem</name>
       <description/>
       <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubItemAssociation</name>
       <description/>
       <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
       <features>
         <featureDescription>
           <name>source</name>
           <description/>
           <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>destination</name>
           <description/>
           <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubAnnotator</name>
       <description/>
       <supertypeName>uima.cas.TOP</supertypeName>
       <features>
         <featureDescription>
           <name>analyzerId</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>delegateName</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>analyzerVersion</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>note</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubEntity</name>
       <description/>
       <supertypeName>uima.tcas.Annotation</supertypeName>
       <features>
         <featureDescription>
           <name>annotations</name>
           <description/>
           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
           <elementType>org.pubcurator.uima.ts.PubAnnotation</elementType>
         </featureDescription>
         <featureDescription>
           <name>score</name>
           <description/>
           <rangeTypeName>uima.cas.Integer</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>annotator</name>
           <description/>
           <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>subEntities</name>
           <description/>
           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
           <elementType>org.pubcurator.uima.ts.PubEntity</elementType>
         </featureDescription>
         <featureDescription>
           <name>identifiers</name>
           <description/>
           <rangeTypeName>uima.cas.FSArray</rangeTypeName>
           <elementType>org.pubcurator.uima.ts.PubIdentifier</elementType>
         </featureDescription>
         <featureDescription>
           <name>topic</name>
           <description/>
           <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubProperty</name>
       <description/>
       <supertypeName>uima.cas.TOP</supertypeName>
       <features>
         <featureDescription>
           <name>key</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>value</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubSpan</name>
       <description/>
       <supertypeName>uima.tcas.Annotation</supertypeName>
     </typeDescription>
     <typeDescription>
       <name>org.pubcurator.uima.ts.PubTopic</name>
       <description/>
       <supertypeName>uima.cas.TOP</supertypeName>
       <features>
         <featureDescription>
           <name>namespace</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
         <featureDescription>
           <name>name</name>
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
       </features>
     </typeDescription>
   </types>
</typeSystemDescription>




Serialized Type System Description:

<?xml version="1.0" encoding="UTF-8"?>
<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
     <types>
         <typeDescription>
             <name>uima.tcas.Annotation</name>
             <description/>
             <supertypeName>uima.cas.AnnotationBase</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>uima.tcas.DocumentAnnotation</name>
             <description/>
             <supertypeName>uima.tcas.Annotation</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>language</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubAnnotation</name>
             <description/>
             <supertypeName>uima.tcas.Annotation</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>annotator</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>score</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>identifiers</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>spans</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>topic</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubIdentifier</name>
             <description/>
             <supertypeName>uima.cas.TOP</supertypeName>
             <features>
                 <featureDescription>
                     <name>identifierType</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>identifier</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubItem</name>
             <description/>
             <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>annotator</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>score</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>identifiers</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>spans</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>topic</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubItemAssociation</name>
             <description/>
             <supertypeName>org.pubcurator.uima.ts.PubAnnotation</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>annotator</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>score</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>identifiers</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>spans</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubSpan[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>topic</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>source</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>destination</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubItem</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubAnnotator</name>
             <description/>
             <supertypeName>uima.cas.TOP</supertypeName>
             <features>
                 <featureDescription>
                     <name>analyzerId</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>delegateName</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>analyzerVersion</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>note</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubEntity</name>
             <description/>
             <supertypeName>uima.tcas.Annotation</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>annotations</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubAnnotation[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>score</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>annotator</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubAnnotator</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>subEntities</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubEntity[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>identifiers</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubIdentifier[]</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>topic</name>
                     <description/>
                     <rangeTypeName>org.pubcurator.uima.ts.PubTopic</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubProperty</name>
             <description/>
             <supertypeName>uima.cas.TOP</supertypeName>
             <features>
                 <featureDescription>
                     <name>key</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>value</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubSpan</name>
             <description/>
             <supertypeName>uima.tcas.Annotation</supertypeName>
             <features>
                 <featureDescription>
                     <name>sofa</name>
                     <description/>
                     <rangeTypeName>uima.cas.Sofa</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>begin</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>end</name>
                     <description/>
                     <rangeTypeName>uima.cas.Integer</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubTopic</name>
             <description/>
             <supertypeName>uima.cas.TOP</supertypeName>
             <features>
                 <featureDescription>
                     <name>namespace</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
                 <featureDescription>
                     <name>name</name>
                     <description/>
                     <rangeTypeName>uima.cas.String</rangeTypeName>
                 </featureDescription>
             </features>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubIdentifier[]</name>
             <description/>
             <supertypeName>uima.cas.FSArray</supertypeName>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubSpan[]</name>
             <description/>
             <supertypeName>uima.cas.FSArray</supertypeName>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubAnnotation[]</name>
             <description/>
             <supertypeName>uima.cas.FSArray</supertypeName>
         </typeDescription>
         <typeDescription>
             <name>org.pubcurator.uima.ts.PubEntity[]</name>
             <description/>
             <supertypeName>uima.cas.FSArray</supertypeName>
         </typeDescription>
     </types>
</typeSystemDescription>





Serialized CAS:

<?xml version="1.0" encoding="UTF-8"?><xmi:XMI xmlns:cas="http:///uima/cas.ecore" 
xmlns:xmi="http://www.omg.org/XMI" xmlns:ts="http:///org/pubcurator/uima/ts.ecore" 
xmlns:tcas="http:///uima/tcas.ecore" xmi:version="2.0"><cas:NULL xmi:id="0"/><cas:Sofa xmi:id="10" 
sofaNum="1" sofaID="_InitialView"/><ts:PubAnnotation xmi:id="1" sofa="10" begin="10" end="20" 
score="1000"/><cas:View sofa="10" members="1"/></xmi:XMI>


Re: Reuse serialized XMI CAS in a dynamic application.

Posted by Thilo Goetz <tw...@gmx.de>.
Hello Kai,

Kai Schlamp wrote:
> Hi.
> 
> I store the serialized (XMI) CASes during my analysis process in a
> database to use them afterwards for further evaluation.
> The problem is that later I don't have a CAS available for
> deserialization. Another problem is that my application is highly
> dynamic, analysis engines come and go. It is not guaranteed that an
> analysis engine (and the type system of it) is still there, when the
> XMI-CAS should be later deserialized. So it's not that easy to generate
> a new CAS that is compatible to the serialized CAS.
> A solution I can think of is to store the type system together with the
> serialized CAS. That way a new CAS could be generated later from scratch
> with the help of the also stored type system (by using
> CASFactory.createCAS(typeSystem).getCAS()).
> 
> Here are my questions ;-)
> What are my options to serialize and deserialize a type system?

You can look at the CVD code for an example how to
serialize and deserialize type systems.  Serialization
is as easy as this (from XCASSaveTSHandler):

        OutputStream outStream = new BufferedOutputStream(new FileOutputStream(tsFile));
        TypeSystem2Xml.typeSystem2Xml(this.main.getCas().getTypeSystem(), outStream);
        outStream.close();

Creating a CAS from an existing type system is
not much more complicated (TypeSystemFileOpenEventHandler):

          // Simplified...
          Object descriptor = UIMAFramework.getXMLParser().parse(new XMLInputSource(tsFile));
          TypeSystemDescription tsDesc = (TypeSystemDescription) descriptor;
          tsDesc.resolveImports();
          CAS cas = CasCreationUtils.createCas(tsDesc, null, new FsIndexDescription[0]);

Please do not use CASFactory directly, that's a
framework internal helper class.

> Can I convert a TypeSystem to TypeSystemDescription (then serialization
> would be easy)?
> Any suggestions for solving the whole problem in another way?

No, from your description, this sounds like a
perfectly reasonable approach.

--Thilo

> 
> Best regards,
> Kai
> 
> 
> 
>