public class SplittingGrammarExtractor extends Object
Constructor and Description |
---|
SplittingGrammarExtractor(Options op) |
Modifier and Type | Method and Description |
---|---|
void |
buildGrammars() |
void |
buildStateIndex() |
void |
countMergeEffects(Tree tree,
Map<String,double[]> totalStateMass,
Map<String,double[]> deltaAnnotations) |
void |
countMergeEffects(Tree tree,
Map<String,double[]> totalStateMass,
Map<String,double[]> deltaAnnotations,
IdentityHashMap<Tree,double[]> probIn,
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(Collection<Tree> treeList) |
void |
extract(Collection<Tree> trees1,
double weight1,
Collection<Tree> trees2,
double weight2)
First, we do a few setup steps.
|
int |
getStateSplitCount(String label) |
int |
getStateSplitCount(Tree tree) |
void |
mergeStates() |
void |
mergeTransitions(Tree parent,
IdentityHashMap<Tree,double[][]> oldUnaryTransitions,
IdentityHashMap<Tree,double[][][]> oldBinaryTransitions,
IdentityHashMap<Tree,double[][]> newUnaryTransitions,
IdentityHashMap<Tree,double[][][]> newBinaryTransitions,
double[] stateWeights,
Map<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,
IdentityHashMap<Tree,double[][]> unaryTransitions,
IdentityHashMap<Tree,double[][][]> binaryTransitions) |
void |
outputTransitions(Tree tree,
int depth,
IdentityHashMap<Tree,double[][]> unaryTransitions,
IdentityHashMap<Tree,double[][][]> binaryTransitions) |
boolean |
recalculateBetas(boolean splitStates)
Recalculates the betas for all known transitions.
|
void |
recalculateMergedBetas(Map<String,int[]> mergeCorrespondence) |
void |
recalculateTemporaryBetas(boolean splitStates,
Map<String,double[]> totalStateMass,
TwoDimensionalMap<String,String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
Creates temporary beta data structures and fills them in by
iterating over the trees.
|
void |
recalculateTemporaryBetas(Tree tree,
boolean splitStates,
Map<String,double[]> totalStateMass,
TwoDimensionalMap<String,String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas) |
int |
recalculateTemporaryBetas(Tree tree,
double[] stateWeights,
int position,
IdentityHashMap<Tree,double[][]> unaryTransitions,
IdentityHashMap<Tree,double[][][]> binaryTransitions,
Map<String,double[]> totalStateMass,
TwoDimensionalMap<String,String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas) |
int |
recountInside(Tree tree,
boolean splitStates,
int loc,
IdentityHashMap<Tree,double[]> probIn) |
void |
recountOutside(Tree tree,
IdentityHashMap<Tree,double[]> probIn,
IdentityHashMap<Tree,double[]> probOut) |
void |
recountOutside(Tree child,
Tree parent,
IdentityHashMap<Tree,double[]> probIn,
IdentityHashMap<Tree,double[]> probOut) |
void |
recountOutside(Tree left,
Tree right,
Tree parent,
IdentityHashMap<Tree,double[]> probIn,
IdentityHashMap<Tree,double[]> probOut) |
void |
recountTree(Tree tree,
boolean splitStates,
IdentityHashMap<Tree,double[][]> unaryTransitions,
IdentityHashMap<Tree,double[][][]> binaryTransitions) |
void |
recountTree(Tree tree,
boolean splitStates,
IdentityHashMap<Tree,double[]> probIn,
IdentityHashMap<Tree,double[]> probOut,
IdentityHashMap<Tree,double[][]> unaryTransitions,
IdentityHashMap<Tree,double[][][]> binaryTransitions) |
void |
recountWeights(Tree tree,
IdentityHashMap<Tree,double[]> probIn,
IdentityHashMap<Tree,double[]> probOut,
IdentityHashMap<Tree,double[][]> unaryTransitions,
IdentityHashMap<Tree,double[][][]> binaryTransitions) |
void |
recurseOutside(Tree tree,
IdentityHashMap<Tree,double[]> probIn,
IdentityHashMap<Tree,double[]> probOut) |
void |
rescaleTemporaryBetas(TwoDimensionalMap<String,String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas) |
void |
saveTrees(Collection<Tree> trees1,
double weight1,
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.
|
String |
state(String tag,
int i) |
boolean |
testConvergence(TwoDimensionalMap<String,String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas) |
boolean |
useNewBetas(boolean testConverged,
TwoDimensionalMap<String,String,double[][]> tempUnaryBetas,
ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas) |
public SplittingGrammarExtractor(Options op)
public void outputTransitions(Tree tree, IdentityHashMap<Tree,double[][]> unaryTransitions, IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void outputTransitions(Tree tree, int depth, IdentityHashMap<Tree,double[][]> unaryTransitions, IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void outputBetas()
public int getStateSplitCount(Tree tree)
public int getStateSplitCount(String label)
public void countOriginalStates()
public void splitBetas()
public boolean recalculateBetas(boolean splitStates)
public boolean useNewBetas(boolean testConverged, TwoDimensionalMap<String,String,double[][]> tempUnaryBetas, ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
public void recalculateTemporaryBetas(boolean splitStates, Map<String,double[]> totalStateMass, TwoDimensionalMap<String,String,double[][]> tempUnaryBetas, ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
public boolean testConvergence(TwoDimensionalMap<String,String,double[][]> tempUnaryBetas, ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
public void recalculateTemporaryBetas(Tree tree, boolean splitStates, Map<String,double[]> totalStateMass, TwoDimensionalMap<String,String,double[][]> tempUnaryBetas, ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
public int recalculateTemporaryBetas(Tree tree, double[] stateWeights, int position, IdentityHashMap<Tree,double[][]> unaryTransitions, IdentityHashMap<Tree,double[][][]> binaryTransitions, Map<String,double[]> totalStateMass, TwoDimensionalMap<String,String,double[][]> tempUnaryBetas, ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
public void rescaleTemporaryBetas(TwoDimensionalMap<String,String,double[][]> tempUnaryBetas, ThreeDimensionalMap<String,String,String,double[][][]> tempBinaryBetas)
public void recountTree(Tree tree, boolean splitStates, IdentityHashMap<Tree,double[][]> unaryTransitions, IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void recountTree(Tree tree, boolean splitStates, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut, IdentityHashMap<Tree,double[][]> unaryTransitions, IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void recountWeights(Tree tree, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut, IdentityHashMap<Tree,double[][]> unaryTransitions, IdentityHashMap<Tree,double[][][]> binaryTransitions)
public void recountOutside(Tree tree, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut)
public void recurseOutside(Tree tree, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut)
public void recountOutside(Tree child, Tree parent, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut)
public void recountOutside(Tree left, Tree right, Tree parent, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut)
public int recountInside(Tree tree, boolean splitStates, int loc, IdentityHashMap<Tree,double[]> probIn)
public void mergeStates()
public void mergeTransitions(Tree parent, IdentityHashMap<Tree,double[][]> oldUnaryTransitions, IdentityHashMap<Tree,double[][][]> oldBinaryTransitions, IdentityHashMap<Tree,double[][]> newUnaryTransitions, IdentityHashMap<Tree,double[][][]> newBinaryTransitions, double[] stateWeights, Map<String,int[]> mergeCorrespondence)
public void countMergeEffects(Tree tree, Map<String,double[]> totalStateMass, Map<String,double[]> deltaAnnotations)
public void countMergeEffects(Tree tree, Map<String,double[]> totalStateMass, Map<String,double[]> deltaAnnotations, IdentityHashMap<Tree,double[]> probIn, IdentityHashMap<Tree,double[]> probOut)
public void buildStateIndex()
public void buildGrammars()
public void saveTrees(Collection<Tree> trees1, double weight1, Collection<Tree> trees2, double weight2)
public void extract(Collection<Tree> treeList)
public void extract(Collection<Tree> trees1, double weight1, Collection<Tree> trees2, double weight2)