@SuppressWarnings("unchecked")
  //we are feeding in the proper type so casting should not be an issue
  private void annotateWithNGrams(Annotation textAnnotation, JCas aJCas) {
    
    int annotationBegin = textAnnotation.getBegin();
    int annotationEnd = textAnnotation.getEnd();
    Iterator<Token> tokenIter = (Iterator<Token>) getAnnotationsFromIndex(aJCas, Token.type);
    List<Token> tokensSoFar = new ArrayList<Token>(); // keep a running list of tokens
    while (tokenIter.hasNext()) {
      Token token = (Token)tokenIter.next();
      // check that the token is for this sentence
      if (token.getBegin() >= annotationBegin && token.getEnd() <= annotationEnd) {
        // build a list of tokens, taking advantage of the fact that the tokens are arranged
        // in sorted order
        tokensSoFar.add(token);
        int end = tokensSoFar.size() - 1;
        // for each new token we add, one NGram is generated for each previous span
        for (int start = 0; start <= end; start++) {
          ngramAnnotationFactory.Annotate(aJCas, tokensSoFar.subList(start, end + 1));
        }
      }
    }
  }