edu.stanford.nlp.parser.lexparser
Class GrammarCompactor
java.lang.Object
edu.stanford.nlp.parser.lexparser.GrammarCompactor
- Direct Known Subclasses:
- ExactGrammarCompactor
public abstract class GrammarCompactor
- extends Object
- Author:
- Teg Grenager (grenager@cs.stanford.edu)
Method Summary |
protected boolean |
addOneBinaryRule(BinaryRule rule,
Map<String,TransducerGraph> graphs)
|
protected boolean |
addOneUnaryRule(UnaryRule rule,
Map<String,TransducerGraph> graphs)
|
Triple<Index<String>,UnaryGrammar,BinaryGrammar> |
compactGrammar(Pair<UnaryGrammar,BinaryGrammar> grammar,
Index<String> originalStateIndex)
|
Triple<Index<String>,UnaryGrammar,BinaryGrammar> |
compactGrammar(Pair<UnaryGrammar,BinaryGrammar> grammar,
Map<String,List<List<String>>> allTrainPaths,
Map<String,List<List<String>>> allTestPaths,
Index<String> originalStateIndex)
Compacts the grammar specified by the Pair. |
protected static Distribution<String> |
computeInputPrior(Map<String,List<List<String>>> allTrainPaths)
|
protected Map<String,TransducerGraph> |
convertGrammarToGraphs(Pair<UnaryGrammar,BinaryGrammar> grammar,
Set<UnaryRule> unaryRules,
Set<BinaryRule> binaryRules)
|
protected Pair<UnaryGrammar,BinaryGrammar> |
convertGraphsToGrammar(Set<TransducerGraph> graphs,
Set<UnaryRule> unaryRules,
Set<BinaryRule> binaryRules)
|
protected abstract TransducerGraph |
doCompaction(TransducerGraph graph,
List<List<String>> trainPaths,
List<List<String>> testPaths)
|
protected static TransducerGraph |
getGraphFromMap(Map<String,TransducerGraph> m,
String o)
|
protected static String |
getTopCategoryOfSyntheticState(String s)
|
protected static 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 |
RAW_COUNTS
public static final Object RAW_COUNTS
NORMALIZED_LOG_PROBABILITIES
public static final Object NORMALIZED_LOG_PROBABILITIES
outputType
public Object outputType
stateIndex
protected Index<String> stateIndex
newStateIndex
protected Index<String> newStateIndex
inputPrior
protected Distribution<String> inputPrior
verbose
protected boolean verbose
op
protected final Options op
GrammarCompactor
public GrammarCompactor(Options op)
doCompaction
protected abstract TransducerGraph doCompaction(TransducerGraph graph,
List<List<String>> trainPaths,
List<List<String>> testPaths)
compactGrammar
public Triple<Index<String>,UnaryGrammar,BinaryGrammar> compactGrammar(Pair<UnaryGrammar,BinaryGrammar> grammar,
Index<String> originalStateIndex)
compactGrammar
public Triple<Index<String>,UnaryGrammar,BinaryGrammar> compactGrammar(Pair<UnaryGrammar,BinaryGrammar> grammar,
Map<String,List<List<String>>> allTrainPaths,
Map<String,List<List<String>>> allTestPaths,
Index<String> originalStateIndex)
- 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 pathsallTestPaths
- a Map from String passive constituents to Lists of paths
- Returns:
- a Pair of grammars, ordered UnaryGrammar BinaryGrammar.
computeInputPrior
protected static Distribution<String> computeInputPrior(Map<String,List<List<String>>> allTrainPaths)
writeFile
public static boolean writeFile(TransducerGraph graph,
String dir,
String name)
convertGrammarToGraphs
protected Map<String,TransducerGraph> convertGrammarToGraphs(Pair<UnaryGrammar,BinaryGrammar> grammar,
Set<UnaryRule> unaryRules,
Set<BinaryRule> binaryRules)
getGraphFromMap
protected static TransducerGraph getGraphFromMap(Map<String,TransducerGraph> m,
String o)
getTopCategoryOfSyntheticState
protected static String getTopCategoryOfSyntheticState(String s)
addOneUnaryRule
protected boolean addOneUnaryRule(UnaryRule rule,
Map<String,TransducerGraph> graphs)
addOneBinaryRule
protected boolean addOneBinaryRule(BinaryRule rule,
Map<String,TransducerGraph> graphs)
isSyntheticState
protected static boolean isSyntheticState(String state)
convertGraphsToGrammar
protected Pair<UnaryGrammar,BinaryGrammar> convertGraphsToGrammar(Set<TransducerGraph> graphs,
Set<UnaryRule> unaryRules,
Set<BinaryRule> binaryRules)
- Parameters:
graphs
- a Map from String categories to TransducerGraph objectsunaryRules
- is a Set of UnaryRule objects that we need to addbinaryRules
- is a Set of BinaryRule objects that we need to add
- Returns:
- a new Pair of UnaryGrammar, BinaryGrammar
Stanford NLP Group