uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Dolan <buddha_...@yahoo.com>
Subject Re: dinamically type system creation
Date Tue, 13 May 2014 16:39:24 GMT
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