You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Klaus Rothenhäusler <ro...@gmail.com> on 2010/05/03 15:15:27 UTC

determining whether a feature has been set

Hi,
is there any way to determine whether a feature of a primitive
numerical type has been set in a particular feature structure? The
methods like getIntValue(feat), getFloatValue(feat), etc. all return a
zero value if the feature hasn't been set. But zero is of course a
perfectly plausible value in many domains.

Thanks
--Klaus Rothenhäusler


Re: determining whether a feature has been set

Posted by Marshall Schor <ms...@schor.com>.
You could pick a value which won't occur otherwise.

For instance, Float has a special value Float.NaN, which is not a
number.  (If you use this, remember that the equals test doesn't work on
this.)
Integers don't have any such value, but some codes use
Integer.MIN_VALUE, if it won't occur otherwise.

Finally, you could define another feature in your FeatureStructure, of
type boolean, and set that to false initially, and true when you set the
feature of interest.

-Marshall

On 5/3/2010 10:02 AM, Thilo Goetz wrote:
> On 5/3/2010 15:15, Klaus Rothenhäusler wrote:
>   
>> Hi,
>> is there any way to determine whether a feature of a primitive
>> numerical type has been set in a particular feature structure? The
>> methods like getIntValue(feat), getFloatValue(feat), etc. all return a
>> zero value if the feature hasn't been set. But zero is of course a
>> perfectly plausible value in many domains.
>>
>> Thanks
>> --Klaus Rothenhäusler
>>     
> There is no way to check this.  We do not wrap primitive
> values internally, and so do not attach any metadata like,
> has it been set or not.  It's like a Java primitive variable
> in that sense.
>
> --Thilo
>
>
>   

Re: determining whether a feature has been set

Posted by Thilo Goetz <tw...@gmx.de>.
On 5/3/2010 15:15, Klaus Rothenhäusler wrote:
> Hi,
> is there any way to determine whether a feature of a primitive
> numerical type has been set in a particular feature structure? The
> methods like getIntValue(feat), getFloatValue(feat), etc. all return a
> zero value if the feature hasn't been set. But zero is of course a
> perfectly plausible value in many domains.
> 
> Thanks
> --Klaus Rothenhäusler

There is no way to check this.  We do not wrap primitive
values internally, and so do not attach any metadata like,
has it been set or not.  It's like a Java primitive variable
in that sense.

--Thilo