edu.stanford.nlp.tagger.maxent
Class StringTagger

java.lang.Object
  |
  +--edu.stanford.nlp.tagger.maxent.StringTagger

public class StringTagger
extends Object

Convenience class that takes a String input and outputs the tagged version of the String. The String is assumed to be untagged.

The constructor takes in a trained model, which is loaded immediately (takes a long time...). Then subsequent calls to tagString can be executed, passing in an untagged String; a tagged String is returned, unless there was a serious problem in the Tagging machinery, in which case null is returned.

Example:

StringTagger st = new StringTagger("/u/nlp/data/tagger.params/wsj0-21.holder");
String taggedString = st.tagString("Here's a tagged string.");
String taggedString2 = st.tagString("This is your life.");

The output is

Here's/JJ a/DT tagged/VBD string./NNP

and

This/DT is/VBZ your/PRP$ life./NN respectively.


Constructor Summary
StringTagger(String fileModel)
          Constructor that loads the dictionary, so it would behoove you not to create more than one of these, and just reuse the tagString.
 
Method Summary
static void main(String[] argv)
          Command-line driven tagger that takes input from stdin
 String tagString(String toTag)
          Tags the input string according and returns the tagged version
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTagger

public StringTagger(String fileModel)
Constructor that loads the dictionary, so it would behoove you not to create more than one of these, and just reuse the tagString. Unfortunately, it's not serialized as far as I know.

Parameters:
fileModel - filename of the trained model, for example "/u/nlp/data/tagger.params/wsj0-21.holder"
Method Detail

tagString

public String tagString(String toTag)
Tags the input string according and returns the tagged version

Parameters:
toTag - the untagged input String
Returns:
the same string with tags inserted

main

public static void main(String[] argv)
Command-line driven tagger that takes input from stdin



Stanford NLP Group