Annotation token = (Annotation) iterator3.next();
tokens[i] = token.getFeatures().get("string").toString();
Object posObj = token.getFeatures().get("category");
if (posObj == null) {
throw new ExecutionException(
"Token found with no POS tag category!\n"
+ "Did you run a POS tagger before the OpenNLPChunker?");
}
postags[i] = posObj.toString();
i++;
}
// run pos chunker
String[] chunks = chunker.chunk(tokens, postags);
// add tohose chunk tags to token annotations
int j = 0;
for (Iterator iterator4 = annList.iterator(); iterator4
.hasNext();) {
Annotation token = (Annotation) iterator4.next();
FeatureMap fm = token.getFeatures();
fm.put("chunk", chunks[j]);
token.setFeatures(fm);
j++;
}
}
} else {
throw new ExecutionException("No sentences or tokens to process!\n"
+ "Please run a sentence splitter "
+ "and tokeniser first!");
}
}