opennlp.maxent.io
Class GISModelReader

java.lang.Object
  extended by opennlp.maxent.io.GISModelReader
Direct Known Subclasses:
BinaryGISModelReader, ObjectGISModelReader, PlainTextGISModelReader, SuffixSensitiveGISModelReader

public abstract class GISModelReader
extends java.lang.Object

Abstract parent class for readers of GISModels.

Version:
$Revision: 1.7 $, $Date: 2006/11/09 20:57:04 $
Author:
Jason Baldridge

Field Summary
protected  int NUM_PREDS
          The number of predicates contained in the model.
 
Constructor Summary
GISModelReader()
           
 
Method Summary
protected  void checkModelType()
           
protected  int getCorrectionConstant()
           
protected  double getCorrectionParameter()
           
 GISModel getModel()
          Retrieve a model from disk.
protected  int[][] getOutcomePatterns()
           
protected  java.lang.String[] getOutcomes()
           
protected  Context[] getParameters(int[][] outcomePatterns)
          Reads the parameters from a file and populates an array of context objects.
protected  java.lang.String[] getPredicates()
           
protected abstract  double readDouble()
          Implement as needed for the format the model is stored in.
protected abstract  int readInt()
          Implement as needed for the format the model is stored in.
protected abstract  java.lang.String readUTF()
          Implement as needed for the format the model is stored in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_PREDS

protected int NUM_PREDS
The number of predicates contained in the model.

Constructor Detail

GISModelReader

public GISModelReader()
Method Detail

readInt

protected abstract int readInt()
                        throws java.io.IOException
Implement as needed for the format the model is stored in.

Throws:
java.io.IOException

readDouble

protected abstract double readDouble()
                              throws java.io.IOException
Implement as needed for the format the model is stored in.

Throws:
java.io.IOException

readUTF

protected abstract java.lang.String readUTF()
                                     throws java.io.IOException
Implement as needed for the format the model is stored in.

Throws:
java.io.IOException

getModel

public GISModel getModel()
                  throws java.io.IOException
Retrieve a model from disk. It assumes that models are saved in the following sequence:
GIS (model type identifier)
1. # of parameters (int)
2. the correction constant (int)
3. the correction constant parameter (double)
4. # of outcomes (int)
* list of outcome names (String)
5. # of different types of outcome patterns (int)
* list of (int int[])
[# of predicates for which outcome pattern is true] [outcome pattern]
6. # of predicates (int)
* list of predicate names (String)

If you are creating a reader for a format which won't work with this (perhaps a database or xml file), override this method and ignore the other methods provided in this abstract class.

Returns:
The GISModel stored in the format and location specified to this GISModelReader (usually via its the constructor).
Throws:
java.io.IOException

checkModelType

protected void checkModelType()
                       throws java.io.IOException
Throws:
java.io.IOException

getCorrectionConstant

protected int getCorrectionConstant()
                             throws java.io.IOException
Throws:
java.io.IOException

getCorrectionParameter

protected double getCorrectionParameter()
                                 throws java.io.IOException
Throws:
java.io.IOException

getOutcomes

protected java.lang.String[] getOutcomes()
                                  throws java.io.IOException
Throws:
java.io.IOException

getOutcomePatterns

protected int[][] getOutcomePatterns()
                              throws java.io.IOException
Throws:
java.io.IOException

getPredicates

protected java.lang.String[] getPredicates()
                                    throws java.io.IOException
Throws:
java.io.IOException

getParameters

protected Context[] getParameters(int[][] outcomePatterns)
                           throws java.io.IOException
Reads the parameters from a file and populates an array of context objects.

Parameters:
outcomePatterns - The outcomes patterns for the model. The first index refers to which outcome pattern (a set of outcomes that occurs with a context) is being specified. The second index specifies the number of contexts which use this pattern at index 0, and the index of each outcomes which make up this pattern in indicies 1-n.
Returns:
An array of context objects.
Throws:
java.io.IOException - when the model file does not match the outcome patterns or can not be read.


Copyright © 2005 Jason Baldridge, Gann Bierner, and Thomas Morton. All Rights Reserved.