List<AbstractCoreLabel> ne = Generics.newArrayList();
String previousNEType = "";
int previousNEIndex = -1;
for (int i = 0; i < words.size(); i++) {
AbstractCoreLabel word = words.get(i);
if(!word.ner().equals("O")) {
if (!word.ner().equals(previousNEType) || previousNEIndex != i-1) {
ne = Generics.newArrayList();
namedEntities.add(ne);
}
ne.add(word);