edu.stanford.nlp.tagger.maxent
Class GlobalHolder

java.lang.Object
  extended by edu.stanford.nlp.tagger.maxent.GlobalHolder

public class GlobalHolder
extends Object

This class holds many global variables and other things that are used by the Stanford MaxEnt Part-of-speech Tagger package.

Author:
Kristina Toutanova, Anna Rafferty, Michel Galley

Method Summary
protected static boolean convertMultifileTagger(String filename, String newFilename, TaggerConfig config)
          This method is provided for backwards compatibility with the old tagger.
protected static void dumpModel()
           
static LambdaSolve getLambdaSolve()
           
protected static int getNum(FeatureKey s)
           
static TTags getTags()
           
protected static void init()
           
protected static void init(TaggerConfig config)
           
protected static boolean isRare(String word)
           
protected static TaggerConfig readModelAndInit(TaggerConfig config, DataInputStream rf, boolean printLoading)
          This reads the complete tagger from a single model file, and inits the tagger using a combination of the properties passed in and parameters from the file.
protected static TaggerConfig readModelAndInit(TaggerConfig config, String modelFileOrUrl, boolean printLoading)
          This reads the complete tagger from a single model stored in a file, at a URL, or as a resource in a jar file, and inits the tagger using a combination of the properties passed in and parameters from the file.
protected static void saveModel(String filename, TaggerConfig config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLambdaSolve

public static LambdaSolve getLambdaSolve()

init

protected static void init()

init

protected static void init(TaggerConfig config)

getNum

protected static int getNum(FeatureKey s)

saveModel

protected static void saveModel(String filename,
                                TaggerConfig config)

convertMultifileTagger

protected static boolean convertMultifileTagger(String filename,
                                                String newFilename,
                                                TaggerConfig config)
                                         throws Exception
This method is provided for backwards compatibility with the old tagger. It reads a tagger that was saved as multiple files into the current format and saves it back out as a single file, newFilename.

Parameters:
filename - The name of the holder file, which is also used as a prefix for other filenames
newFilename - The name of the new one-file model that will be written
config - tagger configuration file
Returns:
true (whether this operation succeeded; always true
Throws:
Exception - ??

readModelAndInit

protected static TaggerConfig readModelAndInit(TaggerConfig config,
                                               String modelFileOrUrl,
                                               boolean printLoading)
                                        throws Exception
This reads the complete tagger from a single model stored in a file, at a URL, or as a resource in a jar file, and inits the tagger using a combination of the properties passed in and parameters from the file.

Note for the future: This assumes that the TaggerConfig in the file has already been read and used. This work is done inside the constructor of TaggerConfig. It might be better to refactor things so that is all done inside this method, but for the moment it seemed better to leave working code alone [cdm 2008].

Parameters:
config - The tagger config
modelFileOrUrl - The name of the model file. This routine opens and closes it.
Throws:
Exception - If I/O errors, etc.

readModelAndInit

protected static TaggerConfig readModelAndInit(TaggerConfig config,
                                               DataInputStream rf,
                                               boolean printLoading)
                                        throws IOException,
                                               ClassNotFoundException
This reads the complete tagger from a single model file, and inits the tagger using a combination of the properties passed in and parameters from the file.

Note for the future: This assumes that the TaggerConfig in the file has already been read and used. It might be better to refactor things so that is all done inside this method, but for the moment it seemed better to leave working code alone [cdm 2008].

Parameters:
config - The tagger config
rf - DataInputStream to read from. It's the caller's job to open and close this stream.
Throws:
IOException - If I/O errors
ClassNotFoundException - If serialization errors

dumpModel

protected static void dumpModel()

isRare

protected static boolean isRare(String word)

getTags

public static TTags getTags()


Stanford NLP Group