Adding a new tag dictionary

A new tag dictionary can be added to a POSTaggerFactory instance. We will illustrate 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 in the following code.

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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset