Java example for using Stanford POSTagger

The following example shows how to use Standford POSTagger. What a POS Tagger does is tagging each word with its type such as verb, noun, etc. For example, if you want to find all verbs in a sentence, you can use Stanford POS Tagger.

Here are steps for using Stanford POSTagger in your Java project.

1. Download basic English Stanford Tagger version 3.1.3 [43 MB]


2. Find a folder called "models", copy the model and its corresponding “.props” file to a directory you are comfortable with.

3. Create a Java project in your eclipse and add stanford-postagger.jar to your project build path

4. Here is the code to tag a sentence "I like watching movies".

String a = "I like watching movies";
MaxentTagger tagger =  new MaxentTagger("lib/tagger/taggers/english-left3words-distsim.tagger");
String tagged = tagger.tagString(a);


I_PRP like_VBP watching_VBG movies_NNS
Category >> Natural Language Processing  
If you want someone to read your code, please put the code inside <pre><code> and </code></pre> tags. For example:
String foo = "bar";
  • Gerryl L Destor

    Thank you so much 🙂