Java Reference
In-Depth Information
The words and their types are then displayed:
for (List<CoreLabel> internalList: entityList) {
for (CoreLabel coreLabel : internalList) {
String word = coreLabel.word();
String category = coreLabel.get(
CoreAnnotations.AnswerAnnotation.class);
System.out.println(word + ":" + category);
}
}
Part of the output follows. It has been truncated because every word is displayed. The O
represents the "Other" category:
Joe:PERSON
was:O
the:O
last:O
person:O
to:O
see:O
Fred:PERSON
.:O
He:O
...
look:O
for:O
Fred:PERSON
To filter out the words that are not relevant, replace the println statement with the fol-
lowing statements. This will eliminate the other categories:
if (!"O".equals(category)) {
System.out.println(word + ":" + category);
}
The output is simpler now:
Joe:PERSON
Fred:PERSON
Search WWH ::




Custom Search