Java Reference
In-Depth Information
Its
get
method returns a list of
CoreLabel
objects that are used within a for-each state-
ment:
for (CoreLabel token :
sentence.get(TokensAnnotation.class)) {
In previous chapters, we have used the
SentencesAnnotation
class to access the
sentences in an annotation, as shown here:
List<CoreMap> sentences =
annotation.get(SentencesAnnotation.class);
The
CoreLabel
class has been used to access individual words in a sentence as demon-
strated here:
for (CoreMap sentence : sentences) {
for (CoreLabel token:
sentence.get(TokensAnnotation.class)) {
String word = token.get(TextAnnotation.class);
String pos =
token.get(PartOfSpeechAnnotation.class);
}
}
Annotator options can be found at
http://nlp.stanford.edu/software/corenlp.shtml
. The fol-
lowing code example illustrates how to use an annotator to specify the POS model. The
pos.model
property is set to the model desired using the
Property
class'
put
meth-
od:
props.put("pos.model",
"C:/.../Models/
english-caseless-left3words-distsim.tagger");
A summary of the annotators is found in the following table. The first column is the string
used in the properties' list. The second column lists only the basic annotation class, and
the third column specifies how it is typically used: