You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Nicolas Hernandez <ni...@gmail.com> on 2008/05/07 19:02:21 UTC

How to update a feature value from an annotation created by a previous annotator ?

Hello,

I am a bit lost. Does someone have an example of some code which update
feature values of some already existing annotations ? I wonder whether I
have to add to the index again...

I had a look to these links, even to the code of the regexp annotator
sandbox, but it remains unclear...
  *
http://incubator.apache.org/uima/downloads/releaseDocs/2.1.0-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.cm.using_cm_to_merge_cases
  *
http://incubator.apache.org/uima/downloads/releaseDocs/2.1.0-incubating/docs/html/references/references.html#ugr.ref.jcas.adding_removing_instances_to_indexes

Thanks in advance for your help

/Nicolas

-- 
Nicolas.Hernandez@univ-nantes.fr
--
# Laboratoire LINA-TALN CNRS UMR 6241
tel. +33 (0)2 51 12 58 55
# Institut Universitaire de Technologie de Nantes - Département Informatique

tel. +33 (0)2 40 30 60 67

Re: How to update a feature value from an annotation created by a previous annotator ?

Posted by Burn Lewis <bu...@gmail.com>.
If you're not changing anything that determines how the annotation is
indexed you can just set it. e.g. if you have retrieved an object foo with a
feature count, then: foo.setCount(foo.getCount()+1);

>From just before your second reference:
Note

It's OK to change feature values which are not used in determining sort
ordering (or set membership), without removing and re-adding back to the
index.
If your change affects one of the index variables you'll have to remove and
add again to the indexes.

Burn.

On Wed, May 7, 2008 at 1:02 PM, Nicolas Hernandez <
nicolas.hernandez@gmail.com> wrote:

> Hello,
>
> I am a bit lost. Does someone have an example of some code which update
> feature values of some already existing annotations ? I wonder whether I
> have to add to the index again...
>
> I had a look to these links, even to the code of the regexp annotator
> sandbox, but it remains unclear...
>  *
>
> http://incubator.apache.org/uima/downloads/releaseDocs/2.1.0-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.cm.using_cm_to_merge_cases
>  *
>
> http://incubator.apache.org/uima/downloads/releaseDocs/2.1.0-incubating/docs/html/references/references.html#ugr.ref.jcas.adding_removing_instances_to_indexes
>
> Thanks in advance for your help
>
> /Nicolas
>
> --
> Nicolas.Hernandez@univ-nantes.fr
> --
> # Laboratoire LINA-TALN CNRS UMR 6241
> tel. +33 (0)2 51 12 58 55
> # Institut Universitaire de Technologie de Nantes - Département
> Informatique
>
> tel. +33 (0)2 40 30 60 67
>

Re: How to update a feature value from an annotation created by a previous annotator ?

Posted by Thilo Goetz <tw...@gmx.de>.
Nicolas Hernandez wrote:
> Hello,
> 
> I am a bit lost. Does someone have an example of some code which update
> feature values of some already existing annotations ? I wonder whether I

You can just use the usual set methods.  Setting a feature value
for the second time (updating) is no different from setting it
for the first time.

> have to add to the index again...

That's a bit tricky.  My assumption is that you are talking about
annotations, and that you haven't defined an index of your own (i.e.,
you're using the built-in annotation index).  In that case, you
would only have to reindex the annotation if you changed the begin
or end position.  Note that if you want to do this, you need to
delete the annotation from the index *before* you change any of
the offsets, and then add it again later.

That's all you need to know.  The following is just if you
want to understand why ;-)

Most indexes (including the default annotation index) are just
sorted collections.  The sort order is defined via the values
of certain features.  In the case of the annotation index, that's
the begin and end position.  In other cases, it might be other
features as well.  The sort order is used both to insert and
to retrieve feature structures.  That means that before you
insert a FS into an index, all features relevant to the sort
order of that index must have their final value.  If you change
such feature values later, the FS may be at the wrong position
in the index.  There is no automatic resorting, and you can't
manually trigger it, either.  So if you do want to change features
relevant to the sort order you have to remove the FS from the
index first.  This you have to do *before* you change the features,
because otherwise the FS may not be found in the index.  I say
"may" because, looking at the code while writing this, I'm no
longer sure this all works correctly.  Hm.  Oh well.  Anyway,
this was just some light reading for your entertainment.

Tomorrow I'll check if we have test cases covering this.  I
don't think many people ever reindex FSs.  I hope you don't
have to.

--Thilo

> 
> I had a look to these links, even to the code of the regexp annotator
> sandbox, but it remains unclear...
>   *
> http://incubator.apache.org/uima/downloads/releaseDocs/2.1.0-incubating/docs/html/tutorials_and_users_guides/tutorials_and_users_guides.html#ugr.tug.cm.using_cm_to_merge_cases
>   *
> http://incubator.apache.org/uima/downloads/releaseDocs/2.1.0-incubating/docs/html/references/references.html#ugr.ref.jcas.adding_removing_instances_to_indexes
> 
> Thanks in advance for your help
> 
> /Nicolas
>