You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by "Johansson, Justin (Contractor)" <Ju...@dsto.defence.gov.au> on 2008/04/04 07:42:54 UTC

Accessing upstream annotations in downstream C++ AE

I have an upstream Java AE putting annotations in the CAS of type, say,
com.my.Foo.

In a downstream C++ annotator, one can get such annotations as instances
of AnnotationFS in C++ but not the as the specific type Foo.

My C++ process() code is along these lines ...

    CAS* pMyView = cas.getView( "MyView");

    if ( pMyView)
	{
        ANIndex fooIndex = pAudioView->getAnnotationIndex( m_fooType);

        if ( !fooIndex.isValid())
        {
            m_pAnnotatorContext->getLogger().logError( "Error getting
Foo index");
            return (TyErrorId) UIMA_ERR_RESMGR_INVALID_RESOURCE;
        }

        AnnotationFS foo = fooIndex.iterator().get();

        if ( !foo.isValid())
        {
            m_pAnnotatorContext->getLogger().logError( "Error getting
Foo FS");
            return (TyErrorId) UIMA_ERR_RESMGR_INVALID_RESOURCE;
        }

	// Problem: How to get Foo specific fields out of foo when it's
just an AnnotationFS?
	}

Observing that there is nothing like a JCasGen for producing C++ header
files for types, then there must be some other way of accessing the
annotations in C++.  Looking through the examples though gives me no
joy.

Could the list please enlighten me on this aspect of UIMA C++.

Thanks
Justin

IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914.  If you have received this email in error, you are requested to contact the sender and delete the email.



Re: File scheme in UIMA C++

Posted by Eddie Epstein <ea...@gmail.com>.
C++ has no built in URI scheme handlers, so uimacpp has a mechanism for
registering a shared library as a scheme handler. See details in
$UIMACPP_HOME/examples/readme.html.

Eddie

On Mon, Apr 7, 2008 at 3:04 AM, Johansson, Justin (Contractor) <
Justin.Johansson@dsto.defence.gov.au> wrote:

> Does anybody know if UIMA C++ is supposed to support file: scheme in
> URI's?
> getSofaDataStream() fails for me when trying to read data from a local
> file.
>
> Error number  : 5066
> Recoverable   : No
> Error         : Scheme handler for the 'file' scheme not registered.
> Cannot access 'file:///C:/Workspace/UimaAerial/data/in/HU-230.raw'.
>   While      : Error accessing Sofa Data Stream.
>   While      : No detailed message available
>   While      : No detailed message available
>   While      : No detailed message available
>
> Thanks to all & esp. Eddie who answered previous questions
> Justin
>
> IMPORTANT: This email remains the property of the Australian Defence
> Organisation and is subject to the jurisdiction of section 70 of the CRIMES
> ACT 1914.  If you have received this email in error, you are requested to
> contact the sender and delete the email.
>
>
>

File scheme in UIMA C++

Posted by "Johansson, Justin (Contractor)" <Ju...@dsto.defence.gov.au>.
Does anybody know if UIMA C++ is supposed to support file: scheme in
URI's?
getSofaDataStream() fails for me when trying to read data from a local
file.

Error number  : 5066
Recoverable   : No
Error         : Scheme handler for the 'file' scheme not registered.
Cannot access 'file:///C:/Workspace/UimaAerial/data/in/HU-230.raw'.
   While      : Error accessing Sofa Data Stream.
   While      : No detailed message available
   While      : No detailed message available
   While      : No detailed message available

Thanks to all & esp. Eddie who answered previous questions
Justin

IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914.  If you have received this email in error, you are requested to contact the sender and delete the email.



Re: Accessing upstream annotations in downstream C++ AE

Posted by Eddie Epstein <ea...@gmail.com>.
In Java there are two interfaces to the CAS: the JCas interface and the
"generic" CAS interface. Some Java example code using the generic interface
are in $UIMA_HOME/examples/src/org/apache/uima/examples/cas/.

UIMACPP implements the generic interface, which requires manual resolution
of Type and Feature definitions before accessing them. This resolution is
normally done in the annotator's typeSystemInit() method.

>From typeSystemInit of the C++ version of the meeting annotator,
$UIMACPP_HOME/examples/tutorial/src/MeetingAnnotator.cpp:

    //input types
    roomNumberT =
crTypeSystem.getType("org.apache.uima.tutorial.RoomNumber");
    dateT =  crTypeSystem.getType("org.apache.uima.tutorial.DateAnnot");
    timeT =  crTypeSystem.getType("org.apache.uima.tutorial.TimeAnnot");

The Type object would then be used for things like
    ANIndex roomNumberIndex = tcas.getAnnotationIndex(roomNumberT);

Custom features are handled in a similar way. For more information about the
generic API, see
http://incubator.apache.org/uima/downloads/releaseDocs/2.2.1-incubating/docs/html/references/references.html#ugr.ref.cas.cas_apis_create_modify_feature_structures

Hope this helps,
Eddie

PS Like Java, the method cas.getView( "MyView") will throw an exception if
the specified view does not exist in cas.



On Fri, Apr 4, 2008 at 1:42 AM, Johansson, Justin (Contractor) <
Justin.Johansson@dsto.defence.gov.au> wrote:

> I have an upstream Java AE putting annotations in the CAS of type, say,
> com.my.Foo.
>
> In a downstream C++ annotator, one can get such annotations as instances
> of AnnotationFS in C++ but not the as the specific type Foo.
>
> My C++ process() code is along these lines ...
>
>    CAS* pMyView = cas.getView( "MyView");
>
>    if ( pMyView)
>        {
>        ANIndex fooIndex = pAudioView->getAnnotationIndex( m_fooType);
>
>        if ( !fooIndex.isValid())
>        {
>            m_pAnnotatorContext->getLogger().logError( "Error getting
> Foo index");
>            return (TyErrorId) UIMA_ERR_RESMGR_INVALID_RESOURCE;
>        }
>
>        AnnotationFS foo = fooIndex.iterator().get();
>
>        if ( !foo.isValid())
>        {
>            m_pAnnotatorContext->getLogger().logError( "Error getting
> Foo FS");
>            return (TyErrorId) UIMA_ERR_RESMGR_INVALID_RESOURCE;
>        }
>
>        // Problem: How to get Foo specific fields out of foo when it's
> just an AnnotationFS?
>        }
>
> Observing that there is nothing like a JCasGen for producing C++ header
> files for types, then there must be some other way of accessing the
> annotations in C++.  Looking through the examples though gives me no
> joy.
>
> Could the list please enlighten me on this aspect of UIMA C++.
>
> Thanks
> Justin
>
> IMPORTANT: This email remains the property of the Australian Defence
> Organisation and is subject to the jurisdiction of section 70 of the CRIMES
> ACT 1914.  If you have received this email in error, you are requested to
> contact the sender and delete the email.
>
>
>