|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.stanford.nlp.tagger.maxent.StaticStringTagger
Static version of StringTagger. Convenience class that takes a String input and outputs the tagged version of the String. The String is assumed to be untagged.
The Tagger must be initialized using a static call init
that takes in a trained model, which is loaded immediately (takes a
long time...); subsequent attempts to initialize the tagger will be
no-ops, therefore it is safe to call init
ad infinitum.
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:
StaticStringTagger.init("/u/nlp/data/tagger.params/wsj0-21.holder");
String taggedString = StaticStringTagger.tagString("Here's a tagged string.");
String taggedString2 = StaticStringTagger.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.
Note that in precisely the above fashion, this tagger just splits on white space when tagging, but the tagger expects input tokenized as in the Penn Treebank. Unless a prior tokenization step is done, the tagger will perform poorly.
Method Summary | |
Object |
apply(Object in)
Implementing the interface Applicable |
static void |
init(String fileModel)
Initializer that loads the dictionary. |
static void |
main(String[] argv)
Command-line tagger that takes input from stdin or a file. |
static String |
tagString(String toTag)
Tags the input string and returns the tagged version. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void init(String fileModel)
fileModel
- Filename of the trained model, for example
"/u/nlp/data/tagger.params/wsj0-21.holder"public static String tagString(String toTag)
toTag
- The untagged input String
public Object apply(Object in)
apply
in interface Appliable
public static void main(String[] argv)
argv
- There can be no arguments, or a file to read a tagger
from and a file to tag can be supplied:java edu.stanford.nlp.tagger.maxent.StaticStringTagger
[modelName [fileName]]
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |