|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.parser.lexparser.SplittingGrammarExtractor
public class SplittingGrammarExtractor
This class is a reimplementation of Berkeley's state splitting grammar. This work is experimental and still in progress. There are several extremely important pieces to implement:
Constructor Summary | |
---|---|
SplittingGrammarExtractor(Options op)
|
Method Summary | |
---|---|
void |
buildGrammars()
|
void |
buildStateIndex()
|
void |
countMergeEffects(Tree tree,
java.util.Map<java.lang.String,double[]> totalStateMass,
java.util.Map<java.lang.String,double[]> deltaAnnotations)
|
void |
countMergeEffects(Tree tree,
java.util.Map<java.lang.String,double[]> totalStateMass,
java.util.Map<java.lang.String,double[]> deltaAnnotations,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut)
|
void |
countOriginalStates()
Count all the internal labels in all the trees, and set their initial state counts to 1. |
void |
extract(java.util.Collection<Tree> treeList)
|
void |
extract(java.util.Collection<Tree> trees1,
double weight1,
java.util.Collection<Tree> trees2,
double weight2)
First, we do a few setup steps. |
int |
getStateSplitCount(java.lang.String label)
|
int |
getStateSplitCount(Tree tree)
|
void |
mergeStates()
|
void |
mergeTransitions(Tree parent,
java.util.IdentityHashMap<Tree,double[][]> oldUnaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> oldBinaryTransitions,
java.util.IdentityHashMap<Tree,double[][]> newUnaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> newBinaryTransitions,
double[] stateWeights,
java.util.Map<java.lang.String,int[]> mergeCorrespondence)
Given a tree and the original set of transition probabilities from one state to the next in the tree, along with a list of the weights in the tree and a count of the mass in each substate at the current node, this method merges the probabilities as necessary. |
void |
outputBetas()
|
void |
outputTransitions(Tree tree,
java.util.IdentityHashMap<Tree,double[][]> unaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
|
void |
outputTransitions(Tree tree,
int depth,
java.util.IdentityHashMap<Tree,double[][]> unaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
|
boolean |
recalculateBetas(boolean splitStates)
Recalculates the betas for all known transitions. |
void |
recalculateMergedBetas(java.util.Map<java.lang.String,int[]> mergeCorrespondence)
|
void |
recalculateTemporaryBetas(boolean splitStates,
java.util.Map<java.lang.String,double[]> totalStateMass,
TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
Creates temporary beta data structures and fills them in by iterating over the trees. |
void |
recalculateTemporaryBetas(Tree tree,
boolean splitStates,
java.util.Map<java.lang.String,double[]> totalStateMass,
TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
|
int |
recalculateTemporaryBetas(Tree tree,
double[] stateWeights,
int position,
java.util.IdentityHashMap<Tree,double[][]> unaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions,
java.util.Map<java.lang.String,double[]> totalStateMass,
TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
|
int |
recountInside(Tree tree,
boolean splitStates,
int loc,
java.util.IdentityHashMap<Tree,double[]> probIn)
|
void |
recountOutside(Tree tree,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut)
|
void |
recountOutside(Tree child,
Tree parent,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut)
|
void |
recountOutside(Tree left,
Tree right,
Tree parent,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut)
|
void |
recountTree(Tree tree,
boolean splitStates,
java.util.IdentityHashMap<Tree,double[][]> unaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
|
void |
recountTree(Tree tree,
boolean splitStates,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut,
java.util.IdentityHashMap<Tree,double[][]> unaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
|
void |
recountWeights(Tree tree,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut,
java.util.IdentityHashMap<Tree,double[][]> unaryTransitions,
java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
|
void |
recurseOutside(Tree tree,
java.util.IdentityHashMap<Tree,double[]> probIn,
java.util.IdentityHashMap<Tree,double[]> probOut)
|
void |
rescaleTemporaryBetas(TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
|
void |
saveTrees(java.util.Collection<Tree> trees1,
double weight1,
java.util.Collection<Tree> trees2,
double weight2)
|
void |
splitBetas()
Before each iteration of splitting states, we have tables of betas which correspond to the transitions between different substates. |
java.lang.String |
state(java.lang.String tag,
int i)
|
boolean |
testConvergence(TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
|
boolean |
useNewBetas(boolean testConverged,
TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SplittingGrammarExtractor(Options op)
Method Detail |
---|
public void outputTransitions(Tree tree, java.util.IdentityHashMap<Tree,double[][]> unaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void outputTransitions(Tree tree, int depth, java.util.IdentityHashMap<Tree,double[][]> unaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void outputBetas()
public java.lang.String state(java.lang.String tag, int i)
public int getStateSplitCount(Tree tree)
public int getStateSplitCount(java.lang.String label)
public void countOriginalStates()
public void splitBetas()
public boolean recalculateBetas(boolean splitStates)
public boolean useNewBetas(boolean testConverged, TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas, ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
public void recalculateTemporaryBetas(boolean splitStates, java.util.Map<java.lang.String,double[]> totalStateMass, TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas, ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
public boolean testConvergence(TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas, ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
public void recalculateTemporaryBetas(Tree tree, boolean splitStates, java.util.Map<java.lang.String,double[]> totalStateMass, TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas, ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
public int recalculateTemporaryBetas(Tree tree, double[] stateWeights, int position, java.util.IdentityHashMap<Tree,double[][]> unaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions, java.util.Map<java.lang.String,double[]> totalStateMass, TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas, ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
public void rescaleTemporaryBetas(TwoDimensionalMap<java.lang.String,java.lang.String,double[][]> tempUnaryBetas, ThreeDimensionalMap<java.lang.String,java.lang.String,java.lang.String,double[][][]> tempBinaryBetas)
public void recountTree(Tree tree, boolean splitStates, java.util.IdentityHashMap<Tree,double[][]> unaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void recountTree(Tree tree, boolean splitStates, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut, java.util.IdentityHashMap<Tree,double[][]> unaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void recountWeights(Tree tree, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut, java.util.IdentityHashMap<Tree,double[][]> unaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void recountOutside(Tree tree, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut)
public void recurseOutside(Tree tree, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut)
public void recountOutside(Tree child, Tree parent, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut)
public void recountOutside(Tree left, Tree right, Tree parent, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut)
public int recountInside(Tree tree, boolean splitStates, int loc, java.util.IdentityHashMap<Tree,double[]> probIn)
public void mergeStates()
public void recalculateMergedBetas(java.util.Map<java.lang.String,int[]> mergeCorrespondence)
public void mergeTransitions(Tree parent, java.util.IdentityHashMap<Tree,double[][]> oldUnaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> oldBinaryTransitions, java.util.IdentityHashMap<Tree,double[][]> newUnaryTransitions, java.util.IdentityHashMap<Tree,double[][][]> newBinaryTransitions, double[] stateWeights, java.util.Map<java.lang.String,int[]> mergeCorrespondence)
public void countMergeEffects(Tree tree, java.util.Map<java.lang.String,double[]> totalStateMass, java.util.Map<java.lang.String,double[]> deltaAnnotations)
public void countMergeEffects(Tree tree, java.util.Map<java.lang.String,double[]> totalStateMass, java.util.Map<java.lang.String,double[]> deltaAnnotations, java.util.IdentityHashMap<Tree,double[]> probIn, java.util.IdentityHashMap<Tree,double[]> probOut)
public void buildStateIndex()
public void buildGrammars()
public void saveTrees(java.util.Collection<Tree> trees1, double weight1, java.util.Collection<Tree> trees2, double weight2)
public void extract(java.util.Collection<Tree> treeList)
public void extract(java.util.Collection<Tree> trees1, double weight1, java.util.Collection<Tree> trees2, double weight2)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |