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


Reply via email to