Aaron Kaplan | 1 Apr 09:08
Picon
Favicon

Re: Copying feature structures between views

Hi Eddie.

Eddie Epstein wrote:

> For a class that just copies from one view to another, you should be 
> able to easily avoid the use of low-level methods.

Great, but how? I tried using the clone() method of the feature 
structure I wanted to copy, but that creates a feature structure that's 
associated with the original view, and I can't see how to modify it to 
be associated with the new one.  Say I'm copying from view1 to view2. 
If call setBegin() and setEnd() on the cloned FeatureStructure, and then 
call addToIndexes() with no arguments, that adds it to the index of 
view1, which is not what I want.  If I call addToIndexes(view2), I get: 
org.apache.uima.cas.CASRuntimeException: Error - the Annotation "Token 
..." is over view "view1" and cannot be added to indexes associated with 
the different view "view2".

> Note that one of the main features of this method, supporting deep 
> copies with shared FS (FS that are referenced multiple times) may not
> be needed in your case. An FS in the CAS can be referenced from any 
> view.

Agreed.  If CasCopier had worked I would have lived with its behavior, 
but in fact it would be preferable to share non-Annotation 
FeatureStructures between views rather than copying them from one to the 
other.

-Aaron

(Continue reading)

Aaron Kaplan | 1 Apr 09:33
Picon
Favicon

Re: Copying feature structures between views

OK, I figured it out, with help from an archived mailing list message 
from Matthew Cammpbell.  A FeatureStructure's sofa is just a feature 
like any other, and can be set with setFeatureValue().  The reason I 
missed this the first time around is that there's no convenience method 
setSofa(), as there is for other features.

-Aaron

Aaron Kaplan wrote:
> Hi Eddie.
> 
> Eddie Epstein wrote:
> 
>> For a class that just copies from one view to another, you should be 
>> able to easily avoid the use of low-level methods.
> 
> Great, but how? I tried using the clone() method of the feature 
> structure I wanted to copy, but that creates a feature structure that's 
> associated with the original view, and I can't see how to modify it to 
> be associated with the new one.  Say I'm copying from view1 to view2. If 
> call setBegin() and setEnd() on the cloned FeatureStructure, and then 
> call addToIndexes() with no arguments, that adds it to the index of 
> view1, which is not what I want.  If I call addToIndexes(view2), I get: 
> org.apache.uima.cas.CASRuntimeException: Error - the Annotation "Token 
> ..." is over view "view1" and cannot be added to indexes associated with 
> the different view "view2".
> 
>> Note that one of the main features of this method, supporting deep 
>> copies with shared FS (FS that are referenced multiple times) may not
>> be needed in your case. An FS in the CAS can be referenced from any view.
(Continue reading)

Eddie Epstein | 1 Apr 15:09
Picon

Re: Copying feature structures between views

On Tue, Apr 1, 2008 at 3:33 AM, Aaron Kaplan <Aaron.Kaplan@...>
wrote:

> OK, I figured it out, with help from an archived mailing list message
> from Matthew Cammpbell.  A FeatureStructure's sofa is just a feature
> like any other, and can be set with setFeatureValue().  The reason I
> missed this the first time around is that there's no convenience method
> setSofa(), as there is for other features.
>

Right, this feature is automatically set during Annotation creation. We have
done more work with the casCopier that makes things easier, but haven't had
a chance to formalize them. Your scenario could inspire more convenience
methods too.

Eddie
Dennis Geller | 2 Apr 14:34

Re: Another instance of annotator processing failed

IN the problem below, I get to
 public Category_Type(JCas jcas, Type casType) {
    super(jcas, casType);

casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, 
getFSGenerator());

 
    casFeat_keyword = jcas.getRequiredFeatureDE(casType, "keyword", 
"uima.cas.String", featOkTst); //<<<======
    casFeatCode_keyword  = (null == casFeat_keyword) ? 
JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_keyword).getCode();

In the indicated line, casFeat_keyword is set to null. I don't see any 
obvious errors, such as references to the wrong type system.
Hope this provides useful information.
Thanks
Dennis Geller wrote:
> There was a question about a problem like this earlier in the month. I 
> think this one is different because (a) The error message isn't quite 
> the same; (b) I'm not using Ant (the eventual source of the earlier 
> problem.) Also, I don't have multiple versions of UIMA -- just the one 
> download of the example package.
>
> But I also get"Caused by: org.apache.uima.cas.CASRuntimeException: 
> Feature "keyword" is not defined for type 
> "org.apache.uima.DDMS.Category"." although
> keyword
> Is defined in the type system file (as uima.cas.String)
> --> <features>
(Continue reading)

Picon

Mixing C++ and Java annotators

Can anyone say if it is currently possibly to add a C++ annotator into a
UIMA Java pipeline.

I have a dummy annotator written in C++ which works within a UIMA C++
framework.

Also when inserted into a UIMA Java framework by specifying C++ in the
AE descriptor together with the path to the AE DLL,
the pipeline runs and calls to the C++ initialize and process methods
can be seen.  So far so good.

However when trying to call any methods on the parameters passed to
initialize or process rather ugly access violation
exceptions result.

For example, this blows up just after the breakpoint 

TyErrorId CppPrimitiveAE::process( CAS& cas, ResultSpecification const&
crResultSpecification)
{
    cout << "CppPrimitiveAE::process" << endl;

    __asm int 3 // this inserts a breakpoint so that the VC++ debugger
can be envoked in JNI world

    CAS* pAudioView = cas.getView( "AudioView");

    if ( pAudioView)
    {
        cout << "got audio view" << endl;
(Continue reading)

Eddie Epstein | 4 Apr 04:26
Picon

Re: Mixing C++ and Java annotators

On Thu, Apr 3, 2008 at 8:33 PM, Johansson, Justin (Contractor) <
Justin.Johansson@...> wrote:

> Can anyone say if it is currently possibly to add a C++ annotator into a
> UIMA Java pipeline.

> I have a dummy annotator written in C++ which works within a UIMA C++
> framework.
>
> Also when inserted into a UIMA Java framework by specifying C++ in the
> AE descriptor together with the path to the AE DLL,
> the pipeline runs and calls to the C++ initialize and process methods
> can be seen.  So far so good.
>
> However when trying to call any methods on the parameters passed to
> initialize or process rather ugly access violation
> exceptions result.
>

Yes this all works. Did you try following the steps on "Verifying Your
Installation" in $UIMACPP_HOME/README just to see if the sample code works?

Is it valid to add a C++ annotator into essentially a Java-based UIMA
> pipeline?  I imagine that the UIMA would aspire to allow this but
> perhaps given the current state of Apache UIMA is it not possible?
>
> Can the list enlighten me on the general state of Apache UIMA C++ in any
> case or is this still early days?
>

(Continue reading)

Picon

RE: Mixing C++ and Java annotators

Thanks Eddie for that.

I've just done two things and the problem has gone away so which of the
two things fixed the problem I do not yet know.

1. Checked out latest UIMACPP from Apache SVN and build the binaries.
The last version I had was about 2 months old.
2. Pointed the paths to the Release version as opposed to the Debug
version of the bin.
All's well after doing both of those things.

I was about to go through "Verifying Your Installation" prior to this
but now no need to.

Is there an issue with using Debug binaries as opposed to Release?  If
so how does one configure for Debug binaries?

BTW.  I'm using Visual Studio 2005.

Thanks
Justin

-----Original Message-----
From: Eddie Epstein [mailto:eaepstein@...] 
Sent: Friday, 4 April 2008 12:56
To: uima-user@...
Subject: Re: Mixing C++ and Java annotators

On Thu, Apr 3, 2008 at 8:33 PM, Johansson, Justin (Contractor) <
Justin.Johansson@...> wrote:
(Continue reading)

Picon

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;
        }

(Continue reading)

Eddie Epstein | 4 Apr 13:19
Picon

Re: Mixing C++ and Java annotators

The story with Windows release vs debug builds is a bit complicated by the
fact that they use different new/free code. Objects created in debug code
cannot be freed in release code and visa versa.

buildSDK adds both release (uima.dll) and debug (uimaD.dll) versions of the
DLL. The sample VC projects link the appropriate version. When loading the
annotator, the debug version of uimacpp will append 'D' to the
annotatorImplementationName from the uima component descriptor.

By default the JVM will use uima.dll when calling a uimacpp annotator. To
use a debug annotator from Java, specify -DDEBUG_UIMACPP when starting the
JVM.

There are also two versions of the native driver, runAECpp.exe and
runAECppD.exe to match the annotator build, as well as two versions of the
native service wrapper, deployCppService.exe and deployCppServiceD.exe.

Glad to hear things are working for you,
Eddie

On Thu, Apr 3, 2008 at 11:09 PM, Johansson, Justin (Contractor) <
Justin.Johansson@...> wrote:

> Thanks Eddie for that.
>
> I've just done two things and the problem has gone away so which of the
> two things fixed the problem I do not yet know.
>
> 1. Checked out latest UIMACPP from Apache SVN and build the binaries.
> The last version I had was about 2 months old.
(Continue reading)

Eddie Epstein | 4 Apr 13:57
Picon

Re: Accessing upstream annotations in downstream C++ AE

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.

(Continue reading)


Gmane