Java Reference
In-Depth Information
System.out.println(taggedSentence);
}
The output is as follows:
[The/DT, voyage/NN, of/IN, the/DT, Abraham/NNP, Lincoln/
NNP, was/VBD, for/IN, a/DT, long/JJ, --- time/NN, marked/
VBN, by/IN, no/DT, special/JJ, incident/NN, ./.]
[But/CC, one/CD, circumstance/NN, happened/VBD, which/WDT,
showed/VBD, the/DT, wonderful/JJ, dexterity/NN, of/IN, Ned/
NNP, Land/NNP, ,/,, and/CC, proved/VBD, what/WP, confidence/
NN, we/PRP, might/MD, place/VB, in/IN, him/PRP, ./.]
[The/DT, 30th/JJ, of/IN, June/NNP, ,/,, the/DT, frigate/NN,
spoke/VBD, some/DT, American/JJ, whalers/NNS, ,/,, from/IN,
whom/WP, we/PRP, learned/VBD, that/IN, they/PRP, knew/VBD,
nothing/NN, about/IN, the/DT, narwhal/NN, ./.]
[But/CC, one/CD, of/IN, them/PRP, ,/,, the/DT, captain/NN,
of/IN, the/DT, Monroe/NNP, ,/,, knowing/VBG, that/IN, Ned/
NNP, Land/NNP, had/VBD, shipped/VBN, on/IN, board/NN, the/
DT, Abraham/NNP, Lincoln/NNP, ,/,, begged/VBN, for/IN, his/
PRP$, help/NN, in/IN, chasing/VBG, a/DT, whale/NN, they/
PRP, had/VBD, in/IN, sight/NN, ./.]
Alternately, we can use the Sentence class' listToString method to convert the
tagged sentence to a simple String object.
A value of false for its second parameter is used by the toString method of the
HasWord to create the resulting string, as shown here:
List<TaggedWord> taggedSentence =
tagger.tagSentence(sentence);
for (List<HasWord> sentence : sentences) {
List<TaggedWord> taggedSentence=
tagger.tagSentence(sentence);
System.out.println(Sentence.listToString(taggedSentence,
false));
}
Search WWH ::




Custom Search