code: public static Annotation getAnnotatedChunk(CoreMap annotation, int tokenStartIndex, int tokenEndIndex)
    {
      Integer annoTokenBegin = annotation.get(CoreAnnotations.TokenBeginAnnotation.class);
      if (annoTokenBegin == null) { annoTokenBegin = 0; }
      List<CoreLabel> tokens = annotation.get(CoreAnnotations.TokensAnnotation.class);
      Annotation chunk = getAnnotatedChunk(tokens, tokenStartIndex, tokenEndIndex, annoTokenBegin);
      String text = annotation.get(CoreAnnotations.TextAnnotation.class);
      if (text != null) {
        annotateChunkText(chunk, annotation);
      } else {
        annotateChunkText(chunk, CoreAnnotations.TextAnnotation.class);
      }
      return chunk;
    }
docs: Create a new chunk Annotation with basic chunk information
  CharacterOffsetBeginAnnotation - set to CharacterOffsetBeginAnnotation of first token in chunk
  CharacterOffsetEndAnnotation - set to CharacterOffsetEndAnnotation of last token in chunk
  TokensAnnotation - List of tokens in this chunk
  TokenBeginAnnotation - Index of first token in chunk (index in original list of tokens)
  tokenStartIndex + annotation's TokenBeginAnnotation
  TokenEndAnnotation - Index of last token in chunk (index in original list of tokens)
  tokenEndIndex + annotation's TokenBeginAnnotation
  TextAnnotation - String extracted from the origAnnotation using character offset information for this chunk
  @param annotation - Annotation from which to extract the text for this chunk
  @param tokenStartIndex - Index (relative to current list of tokens) at which this chunk starts
  @param tokenEndIndex - Index (relative to current list of tokens) at which this chunk ends (not inclusive)
  @return Annotation representing new chunk