Java Reference
In-Depth Information
The output is as follows:
The/at voyage/nn of/in the/at Abraham/np Lincoln/np was/
bedz for/in a/at long/jj time/nn marked/vbn by/in no/at
special/jj incident/nn ./.
Using the HmmDecoder class with NBest tags
The tagging process considers multiple combinations of tags. The HmmDecoder class'
tagNBest method returns an iterator of the ScoredTagging objects that reflect the
confidence of different orders. This method takes a token list and a number specifying the
maximum number of results desired.
The previous sentence is not ambiguous enough to demonstrate the combination of tags.
Instead, we will use the following sentence:
String[] sentence = {"Bill", "used", "the", "force", "to",
"force", "the", "manager", "to",
"tear", "the", "bill","in", "to."};
List<String> tokenList = Arrays.asList(sentence);
The example using this method is shown here starting with declarations for the number of
results:
int maxResults = 5;
Using the decoder object created in the previous section, we apply the tagNBest meth-
od to it as follows:
Iterator<ScoredTagging<String>> iterator =
decoder.tagNBest(tokenList, maxResults);
The iterator will allows us to access each of the five different scores. The ScoredTag-
ging class possesses a score method that returns a value reflecting how well it believes
it performs. In the following code sequence, a printf statement displays this score. This
is followed by a loop where the token and its tag are displayed.
The result is a score followed by the word sequence with the tag attached:
Search WWH ::




Custom Search