@Override
  public void process(JCas aJCas) throws AnalysisEngineProcessException {
    String documentText = aJCas.getDocumentText();

    Annotation document = new Annotation(documentText);
    pipeline.annotate(document);

    String preNe = "";
    int neBegin = 0;
    int neEnd = 0;

    // Iterate through the Stanford sentences
    for (CoreMap sent : document.get(SentencesAnnotation.class)) {
      // Iterate all Tokens
      for (CoreLabel token : sent.get(TokensAnnotation.class)) {
        int beginIndex = token.get(CharacterOffsetBeginAnnotation.class);
        int endIndex = token.get(CharacterOffsetEndAnnotation.class);

        // Add NER annotation
        String ne = token.get(NamedEntityTagAnnotation.class);
        if (ne != null) {
          if (ne.equals(preNe) && !preNe.equals("")) {
          } else if (preNe.equals("")) {
            neBegin = beginIndex;
            preNe = ne;
          } else {
            if (!preNe.equals("O")) {
              EntityMention sne = new EntityMention(aJCas);
              sne.setBegin(neBegin);
              sne.setEnd(neEnd);
              sne.setEntityType(preNe);
              sne.addToIndexes(aJCas);
            }
            // set the next named entity
            neBegin = beginIndex;
            preNe = ne;
          }
          neEnd = endIndex;
        }
      }
    }

  }