Is there any simple way to ask for the token 3 to the left of my
current token? I can't find anything that is built into the default
annotation index, and so I have defined an index for this in the
descriptor file. In order to do this I define a feature in my token
type that keeps track of the index of each token and create an FSIndex
on that feature. I can then use the FSIndex as follows:
FSIndex fsIndex =
jCas.getFSIndexRepository().getIndex("my.token.place.index");
MyToken targetAnnotation = new MyToken(jCas);
targetAnnotation.setIndex(targetIndex); //target index is the index of
the token I want to find
return fsIndex.find(targetAnnotation);
Does this make sense? It works - but I just want to make sure that I am
not creating extra work for myself. I actually have several types that
I want to be able to access this way and so I've created a super-type
that has the 'index' feature. This allows me to create a set of utility
methods that I can use for retrieving e.g. tokens, sentences,
constituents, etc. at a specific index or relative to other annotations
of the same type. The only challenge is making sure I retrieve (and
manage) the appropriate index when one of these methods is called.
Any advice here is appreciated.
Thanks,
Philip