uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Eckart de Castilho <...@apache.org>
Subject Re: dinamically type system creation
Date Tue, 13 May 2014 19:05:35 GMT
If you use JCasFactory.createJCas() or CasCreationUtils.createCas()
I'd recommend to load a type system description from XML and pass
it to those calls. The method you describe here should imho only be
used if you need to reconfigure the type system of the CAS from
within a CollectionReader - e.g. when loading a serialized CAS
from disk.

Btw. since UIMA 2.5.0, there are more efficient binary formats than
the Java-serialized CAS. Some inspiration of how to store/load
CASes to/from disk in the binary formats could be picked up from the
BinaryCasReader/Writer [1,2] and SerializedCasReader/Writer [3,4]
components of DKPro Core.

Cheers,

-- Richard

[1] https://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.bincas-asl/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/bincas/BinaryCasReader.java
[2] https://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.bincas-asl/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/bincas/BinaryCasWriter.java
[3] https://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.bincas-asl/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/bincas/SerializedCasReader.java
[4] https://code.google.com/p/dkpro-core-asl/source/browse/de.tudarmstadt.ukp.dkpro.core-asl/trunk/de.tudarmstadt.ukp.dkpro.core.io.bincas-asl/src/main/java/de/tudarmstadt/ukp/dkpro/core/io/bincas/SerializedCasWriter.java

On 13.05.2014, at 18:39, Brian Dolan <buddha_314@yahoo.com> wrote:

> We struggled with this as well.  The key is to provide the TypeSystem
> along with the CAS, especially when serializing.
> 
> Here we are writing it out:
> 
> // Serialziation with type system
>            CASMgr casMgr = jCas.getCasImpl();
>            CASCompleteSerializer casCompleteSerializer =
> Serialization.serializeCASComplete(casMgr);
> 
>            outputObjectStream.writeObject(casCompleteSerializer);
> 
> 
> 
> Here we are reading it in:
> 
>            // deSerialization with type system
>            Object inputObj = inputObjectStream.readObject();
>            CASCompleteSerializer casCompleteSerializer = null;
>            if (inputObj instanceof CASCompleteSerializer) {
>                casCompleteSerializer = (CASCompleteSerializer) inputObj;
>            } else {
>                throw new IOException("Deserialized Object is not an
> instance of CASCompleteSerializer");
>            }
> 
>            JCas jCas = JCasFactory.createJCas();
>            CASMgr casMgr = jCas.getCasImpl();
>            Serialization.deserializeCASComplete(casCompleteSerializer,
> casMgr);
> 
> 
> Hope this helps!
> b
> 
> 
> 
> 
> On 5/13/14 8:23 AM, "Alexandre Patry" <alexandre.patry@keatext.com> wrote:
> 
>> Hi Tiziano,
>> 
>> On 13/05/2014 09:55, Tiziano Lorenzetti wrote:
>>> Dear all,
>>> I'm new to UIMA and I'm trying to develope an annotator that creates
>>> dinamically a type system with serveral feature structure.
>>> To accomplish this, the annotator does:
>>> 
>>> ...
>>> TypeSystemDescription tsd =
>>> TypeSystemDescriptionFactory.createTypeSystemDescription(new String[0]);
>>> tsd.addType("it.uniroma2.art.ExcelAnnotation", "",
>>> "uima.tcas.Annotation");
>>> TypeDescription type = tsd.getType("it.uniroma2.art.ExcelAnnotation");
>>> type.addFeature("newUIMAFeature", "", "uima.cas.String");
>>> ...
>>> 
>>> In another annotator, I try to access this type system and its features
>>> in
>>> this way:
>>> 
>>> TypeSystem ts = aCAS.getTypeSystem();
>>> Iterator<Type> types = ts.getTypeIterator();
>>> Iterator<Feature> features = ts.getFeatures();
>>> 
>>> but neither the type system and its features are present. How could I
>>> reach
>>> my goal?
>> How do you create your CAS? I guess the types should be found if you
>> create it using:
>> 
>> CAS aCAS = CasCreationUtils.createCas(typeSystemDescription, null, null);
>> 
>> Hope this help,
>> 
>> Alexandre
>> 
>> -- 
>> Alexandre Patry, Ph.D
>> Chercheur / Researcher
>> http://KeaText.com


Mime
View raw message