Each CoreMap returned in the list from annotation.get(TimeAnnotations.TimexAnnotations.class)
is an Annotation
and you can get other attributes of it, such as the list of tokens, each of which stores character offset information. So you can finish off your example like this:
List<CoreMap> timexAnnsAll = annotation.get(TimeAnnotations.TimexAnnotations.class);
for (CoreMap cm : timexAnnsAll) {
List<CoreLabel> tokens = cm.get(CoreAnnotations.TokensAnnotation.class);
System.out.println(cm +
" [from char offset " +
tokens.get(0).get(CoreAnnotations.CharacterOffsetBeginAnnotation.class) +
" to " + tokens.get(tokens.size() -1)
.get(CoreAnnotations.CharacterOffsetEndAnnotation.class) + ']');
/* -- This shows printing out each token and its character offsets
for (CoreLabel token : tokens) {
System.out.println(token +
", start: " + token.get(CoreAnnotations.CharacterOffsetBeginAnnotation.class) +
", end: " + token.get(CoreAnnotations.CharacterOffsetEndAnnotation.class));
}
*/
}
Then the output is:
4 days from today [from char offset 24 to 41]
20th july of this year [from char offset 52 to 74]
18th Feb 1997 [from char offset 92 to 105]