}
public static Annotation sentencesToDocument(String documentID, List<CoreMap> sentences)
{
String docText = null;
Annotation document = new Annotation(docText);
document.set(CoreAnnotations.DocIDAnnotation.class, documentID);
document.set(CoreAnnotations.SentencesAnnotation.class, sentences);
// Accumulate docTokens and label sentence with overall token begin/end, and sentence index annotations
List<CoreLabel> docTokens = new ArrayList<CoreLabel>();
int sentenceIndex = 0;
int tokenBegin = 0;
for (CoreMap sentenceAnnotation:sentences) {
List<CoreLabel> sentenceTokens = sentenceAnnotation.get(CoreAnnotations.TokensAnnotation.class);
docTokens.addAll(sentenceTokens);
int tokenEnd = tokenBegin + sentenceTokens.size();
sentenceAnnotation.set(CoreAnnotations.TokenBeginAnnotation.class, tokenBegin);
sentenceAnnotation.set(CoreAnnotations.TokenEndAnnotation.class, tokenEnd);
sentenceAnnotation.set(CoreAnnotations.SentenceIndexAnnotation.class, sentenceIndex);
sentenceIndex++;
tokenBegin = tokenEnd;
}
document.set(CoreAnnotations.TokensAnnotation.class, docTokens);
// Put in character offsets
int i = 0;
for (CoreLabel token:docTokens) {
String tokenText = token.get(CoreAnnotations.TextAnnotation.class);