ManticMoo.COM All Articles Jeff's Articles
Jeffrey P. Bigham

Stanford NLP POS Tagger Example/Tutorial

Jeffrey P. Bigham

Related Ads

The Stanford NLP group has produced a very nice Part of Speech (POS) Tagger, but they don't exactly provide documentation. Here's a very short code snippet that should allow you to get it to work. Of course, you'll have to change the path to the trained model to the location where it resides on your machine.


import java.io.*;
import java.lang.reflect.InvocationTargetException;
import edu.stanford.nlp.tagger.maxent.*;

...

try {
  MaxentTagger.init("C:/lib/wsj3t0-18-bidirectional/train-wsj-0-18.holder");
} catch(Exception e) {
  throw new InvocationTargetException(e);
}

String tagged_sent =
  MaxentTagger.tagString("I effect change to change effects.");
System.err.println("Tagged: " + tagged_sent);

If you run this code, you'll get the following output if everything is working properly:


Tagged: I/PRP effect/VBP change/NN to/TO change/VB effects./NN

Jeffrey P. Bigham
ManticMoo.COM All Articles Jeff's Articles