April 2019
Beginner to intermediate
386 pages
11h 20m
English
Since there is more than one possible set of tags for most sentences, it is often useful to examine other possible tag variations. The tagNBest method of the HmmDecoder class returns an iterator of the ScoredTagging instance, each of which represents alternate tagging possibilities.
In the following statement, we create such an iterator using the previously created list of words and a second argument of three meaning that only the top three variations will be returned:
Iterator<ScoredTagging<String>> scoredTaggingIterator = hmmDecoder.tagNBest(tokenList, 3);
The following while loop will iterate over the list of possibilities:
while (scoredTaggingIterator.hasNext()) { ScoredTagging<String> scoredTagging = scoredTaggingIterator.next(); ...Read now
Unlock full access