Java Reference
In-Depth Information
newTags[i] = tags[i];
}
newTags[tags.length] = "newTag";
oldTags = tagDictionary.put("force", newTags);
If we redisplay the current tags as shown here, we can see that the old tags have been re-
tained and the new one added:
/NN/VBP/VB/newTag
Tip
When adding tags, be careful and assign the tags in the proper order as it will influence
which tag is assigned.
Adding a new tag dictionary
A new tag dictionary can be added to a POSTaggerFactory instance. We will illus-
trate this process by creating a new POSTaggerFactory and then adding the
tagDictionary we developed earlier. First, we create a new factory using the default
constructor as shown next. This is followed by calling the setTagDictionary method
against the new factory.
POSTaggerFactory newFactory = new POSTaggerFactory();
newFactory.setTagDictionary(tagDictionary);
To confirm that the tag dictionary has been added, we display the tags for the word
"force" as shown here:
tags = newFactory.getTagDictionary().getTags("force");
for (String tag : tags) {
System.out.print("/" + tag);
}
System.out.println();
The tags are the same as shown here:
/NN/VBP/VB/newTag
Search WWH ::




Custom Search