String[] off = tagger.model.find(tokens, Collections.EMPTY_MAP);
for (int i = 0; i < off.length; i++) {
if (!off[i].equals("other")) {
// /here is the logic to add annotation to gate
FeatureMap fm = Factory.newFeatureMap();
// type
fm.put("source", "openNLP");
// ok then add to string buff all the string to make
// shure we got all the span
// fm.put("string", text.substring(spans[i].getStart(),
// spans[i]
// .getEnd()));
// fm.put("string",
// tokenslist.get(spans[i].getStart()+1).getStartNode().getOffset(),
// tokenslist.get(spans[i].getEnd()).getEndNode().getOffset());
// source
fm.put("type", tagger.name);
// iterate until got the final span
int start = i;
int tmp = i + 1;
if (off.length - 1 > tmp) {
// System.out.println("I am in if the value is: " +
// (off.length > tmp) + " the arr is: " + off.length
// + " " +
// "the index is: " + tmp);
try {
while (off[i + 1].equals("cont")) {
// while(off[++i].equals("cont"))
tmp = i + 1;
if (!(off.length - 1 > tmp))
break;
i++;
}
} catch (ArrayIndexOutOfBoundsException e) {
logger.error("Problem in doc "
+ document.getName());
logger.error("The sentence is "
+ sentence.toString());
logger.error("The named entity is at position "
+ tmp);
continue;
}
}
try {
// annotations.add(Long.valueOf(tokens[start].get()),
// Long
// .valueOf(spans[i].getEnd()), "Name", fm);
// get the label
String label = document.getContent().getContent(
tokenslist.get(start).getStartNode()
.getOffset(),
tokenslist.get(i).getEndNode().getOffset())
.toString();
// add the label
fm.put("string", label);
// get the class uri
//String classUri = type2uri.get(tr.get(tagger.name));
// put the class