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