You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Kameron Cole <ka...@us.ibm.com> on 2017/11/01 17:55:12 UTC

uniqueID() function

Hello

I am trying to use the uniqueId() function, and find some examples.
Basically I want to use the CAS unique ID as the unique id Feature for an
annotation. Fro example, a police report Annotation would have a Feature
reportid, which would leverage the uniqueId() .  The ultimate purpose is to
send the CAS to a database table, and use the reportid as the row's unique
ID.

I can't find any information on it, except here:

http://uima.apache.org/d/uimaj-2.4.2/apidocs/org/apache/uima/cas/FeatureValuePath.html

Contains CAS Type and Feature objects to represent a feature path of the
form feature1/.../featureN. Each part that is enclosed within / is referred
to as "path snippet" below. Also contains the necessary evaluation logic to
yield the value of the feature path. For leaf snippets, the following
"special features" are defined:
      coveredText() can be accessed using evaluateAsString
      typeName() can be accessed using evaluateAsString
      fsId() can be accessed using evaluateAsInt. Its result can be used to
      retrieve an FS from the current LowLevel-CAS.
      uniqueId() can be accessed using evaluateAsInt. Its result can be
      used to uniquely identify an FS for a document (even if the document
      is split over several CAS chunks)

This is deprecated, and replaced with

http://uima.apache.org/d/uimaj-2.4.2/apidocs/org/apache/uima/cas/FeaturePath.html

However, FeaturePath does not have the uniqueID() method

The feature path syntax also allows some built-in functions on the last
feature path element. Built-in functions are added with a ":" followed by
the function name. E.g. "/my/path:fsId()". The allowed built-in functions
are:
      coveredText()
      fsId()
      typeName()
Built-in functions are only evaluated if getValueAsString() is called.

At least, I don't get it. Can I get an example?  Thanks




Re: uniqueID() function

Posted by Marshall Schor <ms...@schor.com>.
Hi,

The uniqueId() function you found is (as you have noticed) not actually a
method.  It's instead, some special syntax that was supported by the
feature-value-path mechanism.

I think this is not what you're looking for.

The best thing for you to do is to design your type system as follows:

1) separate the types into those which you want to store in the database, and
others.  Examples of others might be things like "temporary" types, or types
which are in some sense "derived" and not worth the redundant storage in the DB.

2) for those types you want to store in the DB, add a feature, let's call it:
db_unique_id.  You can have it be whatever kind of value makes the most sense -
an integer, or a string, for example.

3) Then arrange your code to "set" this when the feature structure is created.

---------------

Having said that, there is a more-or-less unique "id", for every feature
structure in the CAS.  Of course, it's not unique across CASs.  Given a feature
structure myFeatureStructure, you can access it using

myFeatureStructure.hashCode()

In UIMA v3, we have myFeatureStructure._id() 

-Marshall

On 11/1/2017 1:55 PM, Kameron Cole wrote:
> Hello
>
> I am trying to use the uniqueId() function, and find some examples.
> Basically I want to use the CAS unique ID as the unique id Feature for an
> annotation. Fro example, a police report Annotation would have a Feature
> reportid, which would leverage the uniqueId() .  The ultimate purpose is to
> send the CAS to a database table, and use the reportid as the row's unique
> ID.
>
> I can't find any information on it, except here:
>
> http://uima.apache.org/d/uimaj-2.4.2/apidocs/org/apache/uima/cas/FeatureValuePath.html
>
> Contains CAS Type and Feature objects to represent a feature path of the
> form feature1/.../featureN. Each part that is enclosed within / is referred
> to as "path snippet" below. Also contains the necessary evaluation logic to
> yield the value of the feature path. For leaf snippets, the following
> "special features" are defined:
>       coveredText() can be accessed using evaluateAsString
>       typeName() can be accessed using evaluateAsString
>       fsId() can be accessed using evaluateAsInt. Its result can be used to
>       retrieve an FS from the current LowLevel-CAS.
>       uniqueId() can be accessed using evaluateAsInt. Its result can be
>       used to uniquely identify an FS for a document (even if the document
>       is split over several CAS chunks)
>
> This is deprecated, and replaced with
>
> http://uima.apache.org/d/uimaj-2.4.2/apidocs/org/apache/uima/cas/FeaturePath.html
>
> However, FeaturePath does not have the uniqueID() method
>
> The feature path syntax also allows some built-in functions on the last
> feature path element. Built-in functions are added with a ":" followed by
> the function name. E.g. "/my/path:fsId()". The allowed built-in functions
> are:
>       coveredText()
>       fsId()
>       typeName()
> Built-in functions are only evaluated if getValueAsString() is called.
>
> At least, I don't get it. Can I get an example?  Thanks
>
>
>
>