Java Reference
In-Depth Information
Each element of the documentPreprocessor object is then processed and consists of
a list of the HasWord objects, as shown in the following block of code. The HasWord
elements are objects that represent a word. An instance of StringBuilder is used to
construct the sentence with each element of the hasWordList element being added to
the list. When the sentence has been built, it is added to the sentenceList list:
for (List<HasWord> element : documentPreprocessor) {
StringBuilder sentence = new StringBuilder();
List<HasWord> hasWordList = element;
for (HasWord token : hasWordList) {
sentence.append(token).append(" ");
}
sentenceList.add(sentence.toString());
}
A for-each statement is then used to display the sentences:
for (String sentence : sentenceList) {
System.out.println(sentence);
}
The output will appear as shown here:
The first sentence .
The second sentence .
The SBD process is covered in depth in Chapter 3 , Finding Sentences .
Search WWH ::




Custom Search