You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Joel Dubbels <du...@us.ibm.com> on 2011/06/15 22:07:49 UTC

XmiCasSerialization, XmiCasDeserialization and XmiSerializationSharedData

New user question about serialization.  I would like to serialize my CAS 
to disk and then later on, with a new program/invocation/whatever, I'd 
like to deserialize the CAS and work with it.  When I do just normal 
serialization/deserialization I appear to be losing a lot of types from 
the typesystem (provided I am doing lenient deserialization), which 
results in a very empty CAS.  I want exactly the same CAS as what I 
serialized out..  It looked like I was able to successfully 
serialize/deserialize when I used an XmiSerializationSharedData object 
between serialize/deserialize.  However, if I want to do the 
deserialization in an different program/invocation/whatever from where I 
did the serialization, how do I preserve the XmiSerializationSharedData 
object that allows me to pick up all the types that I originally 
serialized out.   Ie. do I have to somehow preserve/serialize the 
shareddata object (which seems silly and also not doable because it is not 
a serializable object).  I'm sure there must be a straightforward way to 
do this.  Anyone have an answer, or better yet, a good example?  Thanks.

Joel Dubbels
Watson Solution Development
Healthcare and Life Sciences Solution Development
Phone: 507-253-1165
Internet:dubbels@us.ibm.com

Re: XmiCasSerialization, XmiCasDeserialization and XmiSerializationSharedData

Posted by Richard Eckart de Castilho <ec...@tk.informatik.tu-darmstadt.de>.
> Thanks, Richard.   So by configuring the same type system, what do you mean? 


Using a both UIMA (CasCreationUtils) and uimaFIT (TypeSystemDescriptionFactory), you could do something like this:

  CAS cas = CasCreationUtils.createCas(TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("TypeSystem.xml"), null, null);
  XmiCasDeserializer.deserialize(new FileInputStream("file.xmi"), cas);

If you want to worry a bit less about configuring type systems, you might want to have a look at uimaFIT's type discovery capability.
This capability basically allows you to "just have your types on the classpath" and then use code like this:

  CAS cas = CasCreationUtils.createCas(TypeSystemDescriptionFactory.createTypeSystemDescription(), null, null);
  XmiCasDeserializer.deserialize(new FileInputStream("file.xmi"), cas);

Here the createTypeSystemDescription() automatically scans the classpath and adds all types it finds to the type system. The 
following page details how to set up this feature:

  http://code.google.com/p/uimafit/wiki/TypeDescriptorDetection

Cheers,

Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
FB 20 Computer Science Department      
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
------------------------------------------------------------------- 





Re: XmiCasSerialization, XmiCasDeserialization and XmiSerializationSharedData (pure UIMA)

Posted by Richard Eckart de Castilho <ec...@tk.informatik.tu-darmstadt.de>.
I'd like to point out the pure-UIMA (no uimaFIT) solution:

  TypeSystemDescription tsd = UIMAFramework.getXMLParser().parseTypeSystemDescription(new XMLInputSource("TypeSystem.xml"));
  CAS cas = CasCreationUtils.createCas(tsd, null, null);
  XmiCasDeserializer.deserialize(new FileInputStream("file.xmi"), cas);

I'm so used to using uimaFIT's type discovery that I barely consider using pure-UIMA ;)

Cheers,

Richard

Am 16.06.2011 um 15:37 schrieb Joel Dubbels:

> Thanks, Richard.   So by configuring the same type system, what do you 
> mean?  On the serialization side I can see you can instantiate it with a 
> type system, but  in the deserializer case, how do you specify a type 
> system for it to work from?  In your example, I see you are writing the 
> type system out to a file, but I'm not sure how that's used when 
> deserializing.  Thanks.

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
FB 20 Computer Science Department      
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
------------------------------------------------------------------- 





Re: XmiCasSerialization, XmiCasDeserialization and XmiSerializationSharedData

Posted by Joel Dubbels <du...@us.ibm.com>.
Thanks, Richard.   So by configuring the same type system, what do you 
mean?  On the serialization side I can see you can instantiate it with a 
type system, but  in the deserializer case, how do you specify a type 
system for it to work from?  In your example, I see you are writing the 
type system out to a file, but I'm not sure how that's used when 
deserializing.  Thanks.

Joel Dubbels
Watson Solution Development
Healthcare and Life Sciences Solution Development
Phone: 507-253-1165
Internet:dubbels@us.ibm.com



From:
Richard Eckart de Castilho <ec...@tk.informatik.tu-darmstadt.de>
To:
"user@uima.apache.org" <us...@uima.apache.org>
Date:
06/15/2011 03:17 PM
Subject:
Re: XmiCasSerialization, XmiCasDeserialization and 
XmiSerializationSharedData



Hi Joel,

Am 15.06.2011 um 22:07 schrieb Joel Dubbels:
>  I want exactly the same CAS as what I serialized out.. 


do you make sure that you have the same type system configured when you 
de-serialize the CAS as when you serialize the CAS?

For an example on how to do this you may find these classes helpful:

http://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.xmi/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/xmi/XmiReader.java


http://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.xmi/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/xmi/XmiWriter.java


Cheers,

Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
FB 20 Computer Science Department 
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
------------------------------------------------------------------- 







Re: XmiCasSerialization, XmiCasDeserialization and XmiSerializationSharedData

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

Am 15.06.2011 um 22:07 schrieb Joel Dubbels:
>  I want exactly the same CAS as what I serialized out.. 


do you make sure that you have the same type system configured when you de-serialize the CAS as when you serialize the CAS?

For an example on how to do this you may find these classes helpful:

http://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.xmi/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/xmi/XmiReader.java

http://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.xmi/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/xmi/XmiWriter.java

Cheers,

Richard

-- 
------------------------------------------------------------------- 
Richard Eckart de Castilho
Technical Lead
Ubiquitous Knowledge Processing Lab 
FB 20 Computer Science Department      
Technische Universität Darmstadt 
Hochschulstr. 10, D-64289 Darmstadt, Germany 
phone [+49] (0)6151 16-7477, fax -5455, room S2/02/B117
eckartde@tk.informatik.tu-darmstadt.de 
www.ukp.tu-darmstadt.de 
Web Research at TU Darmstadt (WeRC) www.werc.tu-darmstadt.de
------------------------------------------------------------------- 





Re: XmiCasSerialization, XmiCasDeserialization and XmiSerializationSharedData

Posted by Marshall Schor <ms...@schor.com>.
Serialization / deserialization is supposed to return the same CAS :-)  (but see
exception below).

The deserialization step *requires* that the CAS you deserialize into, is
previously set up with the proper type system for the types in the serialized form.

The *lenient* flag, if set, disables the error message you would normally get,
if the serialized form has a type in it trying to be deserialized, but the CAS
doesn't have that type defined.  This allows you to deserialize just some subset
of the types in the serialized form - namely those which are defined in the
CAS's type system.

----------

Please check and confirm that you've set up the CAS you're deserializing into,
with the type system containing all the types that may be in the serialized form.

-Marshall

On 6/15/2011 4:07 PM, Joel Dubbels wrote:
> New user question about serialization.  I would like to serialize my CAS 
> to disk and then later on, with a new program/invocation/whatever, I'd 
> like to deserialize the CAS and work with it.  When I do just normal 
> serialization/deserialization I appear to be losing a lot of types from 
> the typesystem (provided I am doing lenient deserialization), which 
> results in a very empty CAS.  I want exactly the same CAS as what I 
> serialized out..  It looked like I was able to successfully 
> serialize/deserialize when I used an XmiSerializationSharedData object 
> between serialize/deserialize.  However, if I want to do the 
> deserialization in an different program/invocation/whatever from where I 
> did the serialization, how do I preserve the XmiSerializationSharedData 
> object that allows me to pick up all the types that I originally 
> serialized out.   Ie. do I have to somehow preserve/serialize the 
> shareddata object (which seems silly and also not doable because it is not 
> a serializable object).  I'm sure there must be a straightforward way to 
> do this.  Anyone have an answer, or better yet, a good example?  Thanks.
>
> Joel Dubbels
> Watson Solution Development
> Healthcare and Life Sciences Solution Development
> Phone: 507-253-1165
> Internet:dubbels@us.ibm.com