Java Reference
In-Depth Information
If we are only interested in the positions of the words and sentences, we can use the en-
dPosition method, as illustrated here:
for (List<CoreLabel> sent : sents) {
for (CoreLabel element : sent) {
System.out.print(element.endPosition() + " ");
}
System.out.println();
}
When this is executed, we get the following output. The last number on each line is the in-
dex of the sentence boundary:
4 16 20 24 27 37 40 45 48 57 65 73 74
84 88 92 97 109 115 116
119 128 138 144 145
152 162 165 169 174 182 187 195 196 210 215 218 224 227 231
237 238 242 251 260 267 274 276 285 287 288 291 294 298 302
305 307 316 317
The first elements of each sentence are displayed in the following sequence along with its
index:
for (List<CoreLabel> sent : sents) {
System.out.println(sent.get(0) + " "
+ sent.get(0).beginPosition());
}
The output is as follows:
When 0
Sentences 75
Or 117
Within 146
If we are interested in the last elements of a sentence, we can use the following sequence.
The number of elements of a list is used to display the terminating character and its end-
ing position:
Search WWH ::




Custom Search