uima-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thilo Götz <twgo...@gmx.de>
Subject Re: Opening a Cas.xmi file and using it to create a CAS object
Date Wed, 10 Nov 2010 09:42:28 GMT
Please check out the source code in the annotation
viewer or CVD.  For CVD, the relevant code is in
TypeSystemFileOpenEventHandler and MainFrame.loadXmiFile()
(in the uimaj-tools project).
You should have no trouble adapting this to your
case.

--Thilo

On 11/10/2010 03:49, Frank wrote:
> Hi,
> 
> I am currently trying to load CAS xmi files and create CAS objects, but I
> can't see how to do it.
> 
> I have looked at the CASCreationUtils methods, but these all require CAS
> objects to be created first, and there is my problem. I am not able to
> create an empty CAS object.
> 
> I have looked into doing
>  "CAS cas = (CAS) mUimaContext.getEmptyCas(CAS.class);"
> but I am not sure if I am setting up the UIMAContext properly, since I get
> null pointer exceptions
> 
> I assume the end point would be to use the XMIDeserializer, once I have a
> CAS object created. Like..
> FileInputStream inputCasStream = new FileInputStream(inputCasFile);
> XmiCasDeserializer.deserialize(inputCasStream, cas);
> 
> Can you point me in the right direction.....?
> 
> Thank you,
> Frank,
> 
> P.S...
> The UIMA annotation viewer ( org.apache.uima.tools.AnnotationViewerMain )
> from the uimaj-examples project  is able to open these CAS files, along with
> the TypeSystem description file, and we are able to view the annotations
> there with no problem. So, I assume the cas files are ok.
> 
> 
> Here is something else that I tried, that did not work for me....
>          XMLInputSource xmlInput = new XMLInputSource(inputTypeSystemFile);
>          //get the type system descriptor from the file
>          TypeSystemDescription typeSystemDescriptor =
> UIMAFramework.getXMLParser()
>                .parseTypeSystemDescription(xmlInput);
>          //create a cas manager
>         CASMgr casMgr = CASFactory.createCAS();
>          casMgr.initCASIndexes();
>          //connect the casManager with the type system descriptor file
>        CasCreationUtils.setupTypeSystem(casMgr, typeSystemDescriptor);
>          //get the cas from the manager
>         CAS aCas = casMgr.getCAS();
> 
> this also gives me null pointer exceptions....
> 

Mime
View raw message