}
// display each sentence in this annotation
if (sentences != null) {
for(int i = 0, sz = sentences.size(); i < sz; i ++) {
CoreMap sentence = sentences.get(i);
List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
os.printf("Sentence #%d (%d tokens):%n", (i + 1), tokens.size());
String text = sentence.get(CoreAnnotations.TextAnnotation.class);
os.println(text);
// display the token-level annotations
String[] tokenAnnotations = {
"Text", "PartOfSpeech", "Lemma", "Answer", "NamedEntityTag", "CharacterOffsetBegin", "CharacterOffsetEnd", "NormalizedNamedEntityTag", "Timex", "TrueCase", "TrueCaseText" };
for (CoreLabel token: tokens) {
os.print(token.toShorterString(tokenAnnotations));
os.print(' ');
}
os.println();
// display the parse tree for this sentence
Tree tree = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
if (tree != null) {
options.constituentTreePrinter.printTree(tree, os);
}
// It is possible turn off the semantic graphs, in which
// case we don't want to recreate them using the dependency
// printer. This might be relevant if using corenlp for a
// language which doesn't have dependencies, for example.
if (sentence.get(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation.class) != null) {
os.print(sentence.get(SemanticGraphCoreAnnotations.CollapsedDependenciesAnnotation.class).toList());
os.printf("%n");
}
// display MachineReading entities and relations
List<EntityMention> entities = sentence.get(MachineReadingAnnotations.EntityMentionsAnnotation.class);
if (entities != null) {
os.println("Extracted the following MachineReading entity mentions:");
for (EntityMention e : entities) {
os.println("\t" + e);
}
}
List<RelationMention> relations = sentence.get(MachineReadingAnnotations.RelationMentionsAnnotation.class);
if(relations != null){
os.println("Extracted the following MachineReading relation mentions:");
for(RelationMention r: relations){
if(r.printableObject(beam)){
os.println(r);