You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Edward Johnson <ej...@coderyte.com> on 2011/03/02 18:08:57 UTC

Accessing type system features within perl

I am having difficulty getting/setting a types features from within a perl annotator.  I have tried a few things without success:

print $annotation->getStringValue('annotatorName'),"\n";
TypeError in method 'FeatureStructure_getStringValue', argument 2 of type 'Feature const &'

print $annotation->getFSValue('annotatorName')\n";
TypeError in method 'FeatureStructure_getFSValue', argument 2 of type 'Feature const &'

print $annotation->{'annotatorName'}\n";
Can't locate auto/perltator/AnnotationFS/swig_annota.al in @INC (@INC contains: ...) at perltator.pm line 33

The first two messages suggest that I should be passing a Feature object instead of a string, however, there doesn't appear to be a way to set the Feature object's name.

In the above examples, the type was created with an xml descriptor and has a string feature named 'annotatorName'.

Could someone tell me the correct way to do this? 

Thank you.
  Edward.

Re: Accessing type system features within perl

Posted by Eddie Epstein <ea...@gmail.com>.
Should be, yes. Look in $UIMACPP_HOME/scriptators/uima.i and search
for #ifdef SWIGPERL.

Eddie

On Fri, Mar 4, 2011 at 4:15 PM, Edward Johnson <ej...@coderyte.com> wrote:
> Thanks,  that helps a lot.
>
> I ran across a message from 2006: http://www.ibm.com/developerworks/forums/thread.jspa?messageID=13856521
> that in the comments suggests "there are Perl ties to make FSIterators look like arrays and FeatureStructures look like hashes."  Is this feature still available?
>
>
> Edward.
>
>
> ----- Original Message -----
>> The argument for $annotation->getStringValue() is a Feature object.
>> Presumably your type system has created a feature named
>> "annotatorName" for some Type derived from uima.tcas.Annotation. To
>> access that feature in Perl, first get a handle to that Feature object
>> in the typeSystemInit method, something like:
>> $main::annotnamefeat =
>> $main::mytype->getFeatureByBaseName("annotatorName");
>> where $main::mytype is the Type object for your custom type.
>>
>> You can test this by modifying sample.pl, first in typeSystemInit:
>> $main::keybeginfeat =
>> $main::keywordtype->getFeatureByBaseName("begin");
>>
>> then in in the loop at the bottom listing annotations created, add:
>> print "(begin)= (", $anno->getIntValue($main::keybeginfeat),")\n";
>>
>> Eddie
>>
>> On Wed, Mar 2, 2011 at 12:08 PM, Edward Johnson
>> <ej...@coderyte.com> wrote:
>> > I am having difficulty getting/setting a types features from within
>> > a perl annotator. I have tried a few things without success:
>> >
>> > print $annotation->getStringValue('annotatorName'),"\n";
>> > TypeError in method 'FeatureStructure_getStringValue', argument 2 of
>> > type 'Feature const &'
>> >
>> > print $annotation->getFSValue('annotatorName')\n";
>> > TypeError in method 'FeatureStructure_getFSValue', argument 2 of
>> > type 'Feature const &'
>> >
>> > print $annotation->{'annotatorName'}\n";
>> > Can't locate auto/perltator/AnnotationFS/swig_annota.al in @INC
>> > (@INC contains: ...) at perltator.pm line 33
>> >
>> > The first two messages suggest that I should be passing a Feature
>> > object instead of a string, however, there doesn't appear to be a
>> > way to set the Feature object's name.
>> >
>> > In the above examples, the type was created with an xml descriptor
>> > and has a string feature named 'annotatorName'.
>> >
>> > Could someone tell me the correct way to do this?
>> >
>> > Thank you.
>> >  Edward.
>> >
>

Re: Accessing type system features within perl

Posted by Edward Johnson <ej...@coderyte.com>.
Thanks,  that helps a lot.

I ran across a message from 2006: http://www.ibm.com/developerworks/forums/thread.jspa?messageID=13856521
that in the comments suggests "there are Perl ties to make FSIterators look like arrays and FeatureStructures look like hashes."  Is this feature still available?


Edward.


----- Original Message -----
> The argument for $annotation->getStringValue() is a Feature object.
> Presumably your type system has created a feature named
> "annotatorName" for some Type derived from uima.tcas.Annotation. To
> access that feature in Perl, first get a handle to that Feature object
> in the typeSystemInit method, something like:
> $main::annotnamefeat =
> $main::mytype->getFeatureByBaseName("annotatorName");
> where $main::mytype is the Type object for your custom type.
> 
> You can test this by modifying sample.pl, first in typeSystemInit:
> $main::keybeginfeat =
> $main::keywordtype->getFeatureByBaseName("begin");
> 
> then in in the loop at the bottom listing annotations created, add:
> print "(begin)= (", $anno->getIntValue($main::keybeginfeat),")\n";
> 
> Eddie
> 
> On Wed, Mar 2, 2011 at 12:08 PM, Edward Johnson
> <ej...@coderyte.com> wrote:
> > I am having difficulty getting/setting a types features from within
> > a perl annotator. I have tried a few things without success:
> >
> > print $annotation->getStringValue('annotatorName'),"\n";
> > TypeError in method 'FeatureStructure_getStringValue', argument 2 of
> > type 'Feature const &'
> >
> > print $annotation->getFSValue('annotatorName')\n";
> > TypeError in method 'FeatureStructure_getFSValue', argument 2 of
> > type 'Feature const &'
> >
> > print $annotation->{'annotatorName'}\n";
> > Can't locate auto/perltator/AnnotationFS/swig_annota.al in @INC
> > (@INC contains: ...) at perltator.pm line 33
> >
> > The first two messages suggest that I should be passing a Feature
> > object instead of a string, however, there doesn't appear to be a
> > way to set the Feature object's name.
> >
> > In the above examples, the type was created with an xml descriptor
> > and has a string feature named 'annotatorName'.
> >
> > Could someone tell me the correct way to do this?
> >
> > Thank you.
> >  Edward.
> >

Re: Accessing type system features within perl

Posted by Eddie Epstein <ea...@gmail.com>.
The argument for $annotation->getStringValue() is a Feature object.
Presumably your type system has created a feature named
"annotatorName" for some Type derived from uima.tcas.Annotation. To
access that feature in Perl, first get a handle to that Feature object
in the typeSystemInit method, something like:
    $main::annotnamefeat = $main::mytype->getFeatureByBaseName("annotatorName");
where $main::mytype is the Type object for your custom type.

You can test this by modifying sample.pl, first in typeSystemInit:
  $main::keybeginfeat = $main::keywordtype->getFeatureByBaseName("begin");

then in in the loop at the bottom listing annotations created, add:
  print "(begin)= (", $anno->getIntValue($main::keybeginfeat),")\n";

Eddie

On Wed, Mar 2, 2011 at 12:08 PM, Edward Johnson <ej...@coderyte.com> wrote:
> I am having difficulty getting/setting a types features from within a perl annotator.  I have tried a few things without success:
>
> print $annotation->getStringValue('annotatorName'),"\n";
> TypeError in method 'FeatureStructure_getStringValue', argument 2 of type 'Feature const &'
>
> print $annotation->getFSValue('annotatorName')\n";
> TypeError in method 'FeatureStructure_getFSValue', argument 2 of type 'Feature const &'
>
> print $annotation->{'annotatorName'}\n";
> Can't locate auto/perltator/AnnotationFS/swig_annota.al in @INC (@INC contains: ...) at perltator.pm line 33
>
> The first two messages suggest that I should be passing a Feature object instead of a string, however, there doesn't appear to be a way to set the Feature object's name.
>
> In the above examples, the type was created with an xml descriptor and has a string feature named 'annotatorName'.
>
> Could someone tell me the correct way to do this?
>
> Thank you.
>  Edward.
>