You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by James Jichun Zhu <ji...@gmail.com> on 2011/07/22 22:04:26 UTC

XmiCasDeserializer destroys the view/sofa

I ran into a problem using XmiCasDeserializer with multi-view.

What I am doing here is something fairly simple. In my simple analysis 
engine,
1. I try to create a new view.
2. I pass the view's underlying CAS to XmiCasDeserializer so it can 
populate the CAS with objects deserialized from a given XMI file.

It works if I use the default "_InitialView". But fails to work if I use 
a new view. Also, if I don't call XmiCasDeserializer the new view would 
stay ok, and the empty sofa can still be passed out of the analysis 
engine component to downstream components. However, once I call 
XmiCasDeserializer on the new view, the sofa gets affected and blows up 
at the downstream components.

I'd really appreciate if someone can help me figure out if it is an 
issue with XmiCasDeserializer or I am doing it wrong.

Here are some more details:
Here is how I created the views.

         JCas defaultView = null;
         JCas goldView = null;
         JCas engineView = null;

         try {
             defaultView = aJCas.getView("_InitialView");
             goldView = aJCas.createView("goldTokens"); *// I have a 
output sofa "goldTokens" defined in the descriptor.*
             engineView = aJCas.createView("engineTokens"); *// I have a 
output sofa "engineTokens" defined in the descriptor.*

         } catch (CASException e) {
             e.printStackTrace();
         }

Here is how I used XmiCasDeserializer to extract objects from XMI file 
and populate the CASes.

         try {
             goldInputStream = new FileInputStream(goldXmiFile);
             engineInputStream = new FileInputStream(engineXmiFile);
             XmiCasDeserializer.deserialize(goldInputStream,
                     goldView.getCas(), false); *// Nothing is inserted 
into the CAS and the view/sofa also seems to be ruined.*
             XmiCasDeserializer.deserialize(engineInputStream,
                     engineView.getCas(), false); *// Nothing is 
inserted into the CAS and the view/sofa also seems to be ruined.*
         } catch (FileNotFoundException fnfe) {
             fnfe.printStackTrace();
             return;
         } catch (SAXException saxe) {
             saxe.printStackTrace();
         } catch (IOException ioe) {
             ioe.printStackTrace();
         } finally {
             try {
                 goldInputStream.close();
                 engineInputStream.close();
             } catch (IOException ioe) {
                 ioe.printStackTrace();
             }
         }

-- 
James


Re: XmiCasDeserializer destroys the view/sofa

Posted by Marshall Schor <ms...@schor.com>.
this was cross posted to the dev list and was answered there, I think. -Marshall

On 7/22/2011 4:04 PM, James Jichun Zhu wrote:
> I ran into a problem using XmiCasDeserializer with multi-view.
>
> What I am doing here is something fairly simple. In my simple analysis engine,
> 1. I try to create a new view.
> 2. I pass the view's underlying CAS to XmiCasDeserializer so it can populate
> the CAS with objects deserialized from a given XMI file.
>
> It works if I use the default "_InitialView". But fails to work if I use a new
> view. Also, if I don't call XmiCasDeserializer the new view would stay ok, and
> the empty sofa can still be passed out of the analysis engine component to
> downstream components. However, once I call XmiCasDeserializer on the new
> view, the sofa gets affected and blows up at the downstream components.
>
> I'd really appreciate if someone can help me figure out if it is an issue with
> XmiCasDeserializer or I am doing it wrong.
>
> Here are some more details:
> Here is how I created the views.
>
>         JCas defaultView = null;
>         JCas goldView = null;
>         JCas engineView = null;
>
>         try {
>             defaultView = aJCas.getView("_InitialView");
>             goldView = aJCas.createView("goldTokens"); *// I have a output
> sofa "goldTokens" defined in the descriptor.*
>             engineView = aJCas.createView("engineTokens"); *// I have a output
> sofa "engineTokens" defined in the descriptor.*
>
>         } catch (CASException e) {
>             e.printStackTrace();
>         }
>
> Here is how I used XmiCasDeserializer to extract objects from XMI file and
> populate the CASes.
>
>         try {
>             goldInputStream = new FileInputStream(goldXmiFile);
>             engineInputStream = new FileInputStream(engineXmiFile);
>             XmiCasDeserializer.deserialize(goldInputStream,
>                     goldView.getCas(), false); *// Nothing is inserted into
> the CAS and the view/sofa also seems to be ruined.*
>             XmiCasDeserializer.deserialize(engineInputStream,
>                     engineView.getCas(), false); *// Nothing is inserted into
> the CAS and the view/sofa also seems to be ruined.*
>         } catch (FileNotFoundException fnfe) {
>             fnfe.printStackTrace();
>             return;
>         } catch (SAXException saxe) {
>             saxe.printStackTrace();
>         } catch (IOException ioe) {
>             ioe.printStackTrace();
>         } finally {
>             try {
>                 goldInputStream.close();
>                 engineInputStream.close();
>             } catch (IOException ioe) {
>                 ioe.printStackTrace();
>             }
>         }
>