edu.stanford.nlp.parser.lexparser
Class GrammarCompactor

java.lang.Object
  extended by edu.stanford.nlp.parser.lexparser.GrammarCompactor
Direct Known Subclasses:
ExactGrammarCompactor

public abstract class GrammarCompactor
extends Object

Author:
Teg Grenager (grenager@cs.stanford.edu)

Field Summary
protected  Distribution inputPrior
           
protected  Numberer newStateNumberer
           
static Object NORMALIZED_LOG_PROBABILITIES
           
 Object outputType
           
static Object RAW_COUNTS
           
protected  Numberer stateNumberer
           
protected  String stateSpace
           
protected  boolean verbose
           
 
Constructor Summary
GrammarCompactor()
           
 
Method Summary
protected  boolean addOneBinaryRule(BinaryRule rule, Map graphs)
           
protected  boolean addOneUnaryRule(UnaryRule rule, Map graphs)
           
 Pair compactGrammar(Pair grammar)
           
 Pair compactGrammar(Pair grammar, Map allTrainPaths, Map allTestPaths)
          Compacts the grammar specified by the Pair.
protected  Distribution computeInputPrior(Map trainPathMap)
           
 Map convertGrammarToGraphs(Pair grammar, Set unaryRules, Set binaryRules)
           
 Pair convertGraphsToGrammar(Set graphs, Set unaryRules, Set binaryRules)
           
protected abstract  TransducerGraph doCompaction(TransducerGraph graph, List trainPaths, List testPaths)
           
protected  TransducerGraph getGraphFromMap(Map m, Object o)
           
protected  String getTopCategoryOfSyntheticState(String s)
           
protected  boolean isSyntheticState(String state)
           
static boolean writeFile(TransducerGraph graph, String dir, String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAW_COUNTS

public static final Object RAW_COUNTS

NORMALIZED_LOG_PROBABILITIES

public static final Object NORMALIZED_LOG_PROBABILITIES

outputType

public Object outputType

stateNumberer

protected Numberer stateNumberer

newStateNumberer

protected Numberer newStateNumberer

stateSpace

protected String stateSpace

inputPrior

protected Distribution inputPrior

verbose

protected boolean verbose
Constructor Detail

GrammarCompactor

public GrammarCompactor()
Method Detail

doCompaction

protected abstract TransducerGraph doCompaction(TransducerGraph graph,
                                                List trainPaths,
                                                List testPaths)

compactGrammar

public Pair compactGrammar(Pair grammar)

compactGrammar

public Pair compactGrammar(Pair grammar,
                           Map allTrainPaths,
                           Map allTestPaths)
Compacts the grammar specified by the Pair.

Parameters:
grammar - a Pair of grammars, ordered UnaryGrammar BinaryGrammar.
allTrainPaths - a Map from String passive constituents to Lists of paths
allTestPaths - a Map from String passive constituents to Lists of paths
Returns:
a Pair of grammars, ordered UnaryGrammar BinaryGrammar.

computeInputPrior

protected Distribution computeInputPrior(Map trainPathMap)

writeFile

public static boolean writeFile(TransducerGraph graph,
                                String dir,
                                String name)

convertGrammarToGraphs

public Map convertGrammarToGraphs(Pair grammar,
                                  Set unaryRules,
                                  Set binaryRules)

getGraphFromMap

protected TransducerGraph getGraphFromMap(Map m,
                                          Object o)

getTopCategoryOfSyntheticState

protected String getTopCategoryOfSyntheticState(String s)

addOneUnaryRule

protected boolean addOneUnaryRule(UnaryRule rule,
                                  Map graphs)

addOneBinaryRule

protected boolean addOneBinaryRule(BinaryRule rule,
                                   Map graphs)

isSyntheticState

protected boolean isSyntheticState(String state)

convertGraphsToGrammar

public Pair convertGraphsToGrammar(Set graphs,
                                   Set unaryRules,
                                   Set binaryRules)
Parameters:
graphs - a Map from String categories to TransducerGraph objects
unaryRules - is a Set of UnaryRule objects that we need to add
binaryRules - is a Set of BinaryRule objects that we need to add
Returns:
a new Pair of UnaryGrammar, BinaryGrammar


Stanford NLP Group