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

Method Summary
static boolean add(FeatureKey s)
          Adds a FeatureKey to the set of known FeatureKeys.
static boolean convertMultifileTagger(String filename, String newFilename, TaggerConfig config)
          This method is provided for backwards compatibility with the old tagger.
static void dumpModel()
           
static LambdaSolve getLambdaSolve()
           
static int getNum(FeatureKey s)
           
static int getNum(FeatureKey s, HashMap<FeatureKey,Integer> fAssocs)
           
static void init()
           
static void init(TaggerConfig config)
           
static boolean isRare(String word)
           
static HashMap<FeatureKey,Integer> readAssociations(String modelFilename)
          This reads the .assoc file.
static TaggerConfig readConfig(DataInputStream stream)
          read in the TaggerConfig
static void readExtractors(InputStream file)
          Read the extractors from a stream.
static void readExtractors(String filename)
          Read the extractors from a filename.
static void readModelAndInit(String filename)
          This reads the complete tagger from a single model file, and inits the tagger using a combination of the properties passed in and those read from the file.
static void readModelAndInit(TaggerConfig config, String filename)
          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.
static void save_model(String filename, TaggerConfig config)
           
static void saveConfig(TaggerConfig config, OutputStream os)
          serialize the TaggerConfig
static void saveExtractors(OutputStream os)
          serialize the ExtractorFrames and ExtractorFramesRare in filename
 
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

public static void init()

init

public static void init(TaggerConfig config)

add

public static boolean add(FeatureKey s)
Adds a FeatureKey to the set of known FeatureKeys.

Parameters:
s - The feature key to be added
Returns:
Whether the key was already known (false) or added (true)

getNum

public static int getNum(FeatureKey s)

getNum

public static int getNum(FeatureKey s,
                         HashMap<FeatureKey,Integer> fAssocs)

saveConfig

public static void saveConfig(TaggerConfig config,
                              OutputStream os)
                       throws IOException
serialize the TaggerConfig

Throws:
IOException

readConfig

public static TaggerConfig readConfig(DataInputStream stream)
                               throws IOException,
                                      ClassNotFoundException
read in the TaggerConfig

Throws:
IOException
ClassNotFoundException

saveExtractors

public static void saveExtractors(OutputStream os)
                           throws IOException
serialize the ExtractorFrames and ExtractorFramesRare in filename

Throws:
IOException

readExtractors

public static void readExtractors(String filename)
                           throws Exception
Read the extractors from a filename.

Throws:
Exception

readExtractors

public static void readExtractors(InputStream file)
                           throws IOException,
                                  ClassNotFoundException
Read the extractors from a stream.

Throws:
IOException
ClassNotFoundException

readAssociations

public static HashMap<FeatureKey,Integer> readAssociations(String modelFilename)
This reads the .assoc file. It is only used by LambdaSolveTagger.java The same associations also appear in the main file, and are read by read(), read_prev().

Parameters:
modelFilename - The string .assoc is appended and feature associations are then read from this file
Returns:
The feature associations HashMap, or null if there is an error

save_model

public static void save_model(String filename,
                              TaggerConfig config)

convertMultifileTagger

public 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 -
Returns:
true (whether this operation succeeded; always true
Throws:
Exception

readModelAndInit

public static void readModelAndInit(String filename)
                             throws Exception
This reads the complete tagger from a single model file, and inits the tagger using a combination of the properties passed in and those read from the file.

Parameters:
filename - Filename to read from. It's closed afterwords
Throws:
Exception - If I/O errors, etc.

readModelAndInit

public static void readModelAndInit(TaggerConfig config,
                                    String filename)
                             throws Exception
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
filename - Filename to read from. It's closed afterwards.
Throws:
Exception - If I/O errors, etc.

dumpModel

public static void dumpModel()

isRare

public static boolean isRare(String word)


Stanford NLP Group