You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Radwen ANIBA <ar...@gmail.com> on 2010/01/14 15:16:00 UTC
Calling CPE from a java application
Hi all,
I'm writing a java application to call my uima developped CPE but i'm facing
a problem in this code line
CpeDescription cpeDesc =
UIMAFramework.getXMLParser().parseCpeDescription(new
XMLInputSource("filename"));
Is there any error in it ? I'm just following the developer guide and notice
here that filename contain full path to the CPE descriptor !!
What's wrong ?
Radwen
Re: Calling CPE from a java application
Posted by Radwen ANIBA <ar...@gmail.com>.
Cool, I have figured out this issue and succeeded to do what I wanted.
Thank you all for your help
Have a nice day
Rad
2010/1/15 Jaroslaw Cwiklik <ui...@gmail.com>
> Rad, the callback listener is registered with the CPE to receive
> notifications. The example code uses class StatusCallbackListenerImpl() but
> you can create your own listener and plug it into the CPE. Just
> implement StatusCallbackListener interface. Look at the java docs for
> details.
> The listener's methods are called to make the application aware of certain
> CPE events like:
>
> - CPE initialization complete
> - when a CAS is processed
> - when there is an exception while processing a CAS
> - when the collection is completed
>
> Again look at the java docs and also check:
>
> org.apache.uima.examples.cpe.SimpleRunCPE.java in the
> %UIMA_HOME%\examples\src directory for the complete code
>
> Regards, Jerry C
>
> On Thu, Jan 14, 2010 at 10:20 AM, Radwen ANIBA <ar...@gmail.com> wrote:
>
> > yes, thank you I think a combination of the two last answers were right.
> >
> > but now i'm facing another problem
> >
> > package org.apache.uima.al;
> >
> > import org.apache.uima.UIMAFramework;
> > import org.apache.uima.collection.CollectionProcessingEngine;
> > import org.apache.uima.collection.metadata.CpeDescription;
> > import org.apache.uima.util.*;
> > import org.apache.uima.collection.StatusCallbackListener;
> >
> > public class RunAlexsys {
> >
> >
> > void RunAlexSys(){
> >
> > XMLInputSource in = new XMLInputSource("MyDescriptor.xml");
> > CpeDescription cpeDesc =
> > UIMAFramework.getXMLParser().parseCpeDescription(in);
> >
> > //instantiate CPE
> > CollectionProcessingEngine mCPE =
> > UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
> >
> > //Create and register a Status Callback Listener
> > mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
> >
> > //Start Processing
> > mCPE.process();
> >
> >
> >
> > }
> > }
> >
> >
> >
> > in mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
> >
> > What is the role of this line exactely ?
> >
> >
> > Rad
> >
> > 2010/1/14 LeHouillier, Frank D <Fr...@gdit.com>
> >
> > > Maybe you need to be using a org.apache.uima.util.XMLInputSource
> instead
> > of
> > > a
> > > com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource
> > > ________________________________________
> > > From: Radwen ANIBA [aradwen@gmail.com]
> > > Sent: Thursday, January 14, 2010 9:34 AM
> > > To: uima-user@incubator.apache.org
> > > Subject: Re: Calling CPE from a java application
> > >
> > > No I verified that, here is the code
> > >
> > > package org.apache.uima.al;
> > >
> > > import org.apache.uima.UIMAFramework;
> > > import org.apache.uima.collection.CollectionProcessingEngine;
> > > import org.apache.uima.collection.metadata.CpeDescription;
> > > import org.apache.uima.util.*;
> > > import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
> > >
> > > public class RunAlexsys {
> > >
> > >
> > >
> > >
> > > CpeDescription cpeDesc =
> > > UIMAFramework.getXMLParser().parseCpeDescription(new
> > > XMLInputSource("filename"));
> > >
> > > //instantiate CPE
> > > mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
> > >
> > > //Create and register a Status Callback Listener
> > > mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
> > >
> > > //Start Processing
> > > mCPE.process();
> > >
> > >
> > >
> > > }
> > >
> > >
> > >
> > >
> > > 2010/1/14 Jörn Kottmann <ko...@gmail.com>
> > >
> > > > Radwen ANIBA wrote:
> > > >
> > > >> I dont really get error since I dont run the application yet but in
> > > >> eclipse
> > > >> it is marked with red cross telling me that's wrong and proposing me
> > to
> > > >> change the parseCpeDescription !!
> > > >>
> > > >>
> > > >>
> > > > There is usually an error message attached to the error marker
> > > > in eclipse. In your case it will contain the reason why it cannot
> > > > compile the class.
> > > >
> > > > Maybe you are missing an import for CpeDescription, UIMAFramework,
> > > > XMLInputSource ?
> > > >
> > > > Jörn
> > > >
> > >
> >
>
Re: Calling CPE from a java application
Posted by Jaroslaw Cwiklik <ui...@gmail.com>.
Rad, the callback listener is registered with the CPE to receive
notifications. The example code uses class StatusCallbackListenerImpl() but
you can create your own listener and plug it into the CPE. Just
implement StatusCallbackListener interface. Look at the java docs for
details.
The listener's methods are called to make the application aware of certain
CPE events like:
- CPE initialization complete
- when a CAS is processed
- when there is an exception while processing a CAS
- when the collection is completed
Again look at the java docs and also check:
org.apache.uima.examples.cpe.SimpleRunCPE.java in the
%UIMA_HOME%\examples\src directory for the complete code
Regards, Jerry C
On Thu, Jan 14, 2010 at 10:20 AM, Radwen ANIBA <ar...@gmail.com> wrote:
> yes, thank you I think a combination of the two last answers were right.
>
> but now i'm facing another problem
>
> package org.apache.uima.al;
>
> import org.apache.uima.UIMAFramework;
> import org.apache.uima.collection.CollectionProcessingEngine;
> import org.apache.uima.collection.metadata.CpeDescription;
> import org.apache.uima.util.*;
> import org.apache.uima.collection.StatusCallbackListener;
>
> public class RunAlexsys {
>
>
> void RunAlexSys(){
>
> XMLInputSource in = new XMLInputSource("MyDescriptor.xml");
> CpeDescription cpeDesc =
> UIMAFramework.getXMLParser().parseCpeDescription(in);
>
> //instantiate CPE
> CollectionProcessingEngine mCPE =
> UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
>
> //Create and register a Status Callback Listener
> mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
>
> //Start Processing
> mCPE.process();
>
>
>
> }
> }
>
>
>
> in mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
>
> What is the role of this line exactely ?
>
>
> Rad
>
> 2010/1/14 LeHouillier, Frank D <Fr...@gdit.com>
>
> > Maybe you need to be using a org.apache.uima.util.XMLInputSource instead
> of
> > a
> > com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource
> > ________________________________________
> > From: Radwen ANIBA [aradwen@gmail.com]
> > Sent: Thursday, January 14, 2010 9:34 AM
> > To: uima-user@incubator.apache.org
> > Subject: Re: Calling CPE from a java application
> >
> > No I verified that, here is the code
> >
> > package org.apache.uima.al;
> >
> > import org.apache.uima.UIMAFramework;
> > import org.apache.uima.collection.CollectionProcessingEngine;
> > import org.apache.uima.collection.metadata.CpeDescription;
> > import org.apache.uima.util.*;
> > import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
> >
> > public class RunAlexsys {
> >
> >
> >
> >
> > CpeDescription cpeDesc =
> > UIMAFramework.getXMLParser().parseCpeDescription(new
> > XMLInputSource("filename"));
> >
> > //instantiate CPE
> > mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
> >
> > //Create and register a Status Callback Listener
> > mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
> >
> > //Start Processing
> > mCPE.process();
> >
> >
> >
> > }
> >
> >
> >
> >
> > 2010/1/14 Jörn Kottmann <ko...@gmail.com>
> >
> > > Radwen ANIBA wrote:
> > >
> > >> I dont really get error since I dont run the application yet but in
> > >> eclipse
> > >> it is marked with red cross telling me that's wrong and proposing me
> to
> > >> change the parseCpeDescription !!
> > >>
> > >>
> > >>
> > > There is usually an error message attached to the error marker
> > > in eclipse. In your case it will contain the reason why it cannot
> > > compile the class.
> > >
> > > Maybe you are missing an import for CpeDescription, UIMAFramework,
> > > XMLInputSource ?
> > >
> > > Jörn
> > >
> >
>
Re: Calling CPE from a java application
Posted by Radwen ANIBA <ar...@gmail.com>.
yes, thank you I think a combination of the two last answers were right.
but now i'm facing another problem
package org.apache.uima.al;
import org.apache.uima.UIMAFramework;
import org.apache.uima.collection.CollectionProcessingEngine;
import org.apache.uima.collection.metadata.CpeDescription;
import org.apache.uima.util.*;
import org.apache.uima.collection.StatusCallbackListener;
public class RunAlexsys {
void RunAlexSys(){
XMLInputSource in = new XMLInputSource("MyDescriptor.xml");
CpeDescription cpeDesc =
UIMAFramework.getXMLParser().parseCpeDescription(in);
//instantiate CPE
CollectionProcessingEngine mCPE =
UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
//Create and register a Status Callback Listener
mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
//Start Processing
mCPE.process();
}
}
in mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
What is the role of this line exactely ?
Rad
2010/1/14 LeHouillier, Frank D <Fr...@gdit.com>
> Maybe you need to be using a org.apache.uima.util.XMLInputSource instead of
> a
> com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource
> ________________________________________
> From: Radwen ANIBA [aradwen@gmail.com]
> Sent: Thursday, January 14, 2010 9:34 AM
> To: uima-user@incubator.apache.org
> Subject: Re: Calling CPE from a java application
>
> No I verified that, here is the code
>
> package org.apache.uima.al;
>
> import org.apache.uima.UIMAFramework;
> import org.apache.uima.collection.CollectionProcessingEngine;
> import org.apache.uima.collection.metadata.CpeDescription;
> import org.apache.uima.util.*;
> import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
>
> public class RunAlexsys {
>
>
>
>
> CpeDescription cpeDesc =
> UIMAFramework.getXMLParser().parseCpeDescription(new
> XMLInputSource("filename"));
>
> //instantiate CPE
> mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
>
> //Create and register a Status Callback Listener
> mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
>
> //Start Processing
> mCPE.process();
>
>
>
> }
>
>
>
>
> 2010/1/14 Jörn Kottmann <ko...@gmail.com>
>
> > Radwen ANIBA wrote:
> >
> >> I dont really get error since I dont run the application yet but in
> >> eclipse
> >> it is marked with red cross telling me that's wrong and proposing me to
> >> change the parseCpeDescription !!
> >>
> >>
> >>
> > There is usually an error message attached to the error marker
> > in eclipse. In your case it will contain the reason why it cannot
> > compile the class.
> >
> > Maybe you are missing an import for CpeDescription, UIMAFramework,
> > XMLInputSource ?
> >
> > Jörn
> >
>
RE: Calling CPE from a java application
Posted by "LeHouillier, Frank D" <Fr...@GDIT.com>.
Maybe you need to be using a org.apache.uima.util.XMLInputSource instead of a
com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource
________________________________________
From: Radwen ANIBA [aradwen@gmail.com]
Sent: Thursday, January 14, 2010 9:34 AM
To: uima-user@incubator.apache.org
Subject: Re: Calling CPE from a java application
No I verified that, here is the code
package org.apache.uima.al;
import org.apache.uima.UIMAFramework;
import org.apache.uima.collection.CollectionProcessingEngine;
import org.apache.uima.collection.metadata.CpeDescription;
import org.apache.uima.util.*;
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
public class RunAlexsys {
CpeDescription cpeDesc =
UIMAFramework.getXMLParser().parseCpeDescription(new
XMLInputSource("filename"));
//instantiate CPE
mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
//Create and register a Status Callback Listener
mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
//Start Processing
mCPE.process();
}
2010/1/14 Jörn Kottmann <ko...@gmail.com>
> Radwen ANIBA wrote:
>
>> I dont really get error since I dont run the application yet but in
>> eclipse
>> it is marked with red cross telling me that's wrong and proposing me to
>> change the parseCpeDescription !!
>>
>>
>>
> There is usually an error message attached to the error marker
> in eclipse. In your case it will contain the reason why it cannot
> compile the class.
>
> Maybe you are missing an import for CpeDescription, UIMAFramework,
> XMLInputSource ?
>
> Jörn
>
Re: Calling CPE from a java application
Posted by Jörn Kottmann <ko...@gmail.com>.
Radwen ANIBA wrote:
> No I verified that, here is the code
>
I think you intended to place the code snippet into
a method, but you didn't. There must be multiple compiler
errors because of that.
Jörn
Re: Calling CPE from a java application
Posted by Radwen ANIBA <ar...@gmail.com>.
No I verified that, here is the code
package org.apache.uima.al;
import org.apache.uima.UIMAFramework;
import org.apache.uima.collection.CollectionProcessingEngine;
import org.apache.uima.collection.metadata.CpeDescription;
import org.apache.uima.util.*;
import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
public class RunAlexsys {
CpeDescription cpeDesc =
UIMAFramework.getXMLParser().parseCpeDescription(new
XMLInputSource("filename"));
//instantiate CPE
mCPE = UIMAFramework.produceCollectionProcessingEngine(cpeDesc);
//Create and register a Status Callback Listener
mCPE.addStatusCallbackListener(new StatusCallbackListenerImpl());
//Start Processing
mCPE.process();
}
2010/1/14 Jörn Kottmann <ko...@gmail.com>
> Radwen ANIBA wrote:
>
>> I dont really get error since I dont run the application yet but in
>> eclipse
>> it is marked with red cross telling me that's wrong and proposing me to
>> change the parseCpeDescription !!
>>
>>
>>
> There is usually an error message attached to the error marker
> in eclipse. In your case it will contain the reason why it cannot
> compile the class.
>
> Maybe you are missing an import for CpeDescription, UIMAFramework,
> XMLInputSource ?
>
> Jörn
>
Re: Calling CPE from a java application
Posted by Jörn Kottmann <ko...@gmail.com>.
Radwen ANIBA wrote:
> I dont really get error since I dont run the application yet but in eclipse
> it is marked with red cross telling me that's wrong and proposing me to
> change the parseCpeDescription !!
>
>
There is usually an error message attached to the error marker
in eclipse. In your case it will contain the reason why it cannot
compile the class.
Maybe you are missing an import for CpeDescription, UIMAFramework,
XMLInputSource ?
Jörn
Re: Calling CPE from a java application
Posted by Radwen ANIBA <ar...@gmail.com>.
I dont really get error since I dont run the application yet but in eclipse
it is marked with red cross telling me that's wrong and proposing me to
change the parseCpeDescription !!
2010/1/14 Jörn Kottmann <ko...@gmail.com>
> Radwen ANIBA wrote:
>
>> Hi all,
>>
>> I'm writing a java application to call my uima developped CPE but i'm
>> facing
>> a problem in this code line
>>
>> CpeDescription cpeDesc =
>> UIMAFramework.getXMLParser().parseCpeDescription(new
>> XMLInputSource("filename"));
>>
>> Is there any error in it ? I'm just following the developer guide and
>> notice
>> here that filename contain full path to the CPE descriptor !!
>>
>> What's wrong ?
>>
>>
> Please post also the error you get,
> Jörn
>
Re: Calling CPE from a java application
Posted by Jörn Kottmann <ko...@gmail.com>.
Radwen ANIBA wrote:
> Hi all,
>
> I'm writing a java application to call my uima developped CPE but i'm facing
> a problem in this code line
>
> CpeDescription cpeDesc =
> UIMAFramework.getXMLParser().parseCpeDescription(new
> XMLInputSource("filename"));
>
> Is there any error in it ? I'm just following the developer guide and notice
> here that filename contain full path to the CPE descriptor !!
>
> What's wrong ?
>
Please post also the error you get,
Jörn