protected internal override void TallyRoot(Tree lt, double weight) { // this list is in full (not reduced) tag space IList <IntDependency> deps = MLEDependencyGrammar.TreeToDependencyList(lt, wordIndex, tagIndex); foreach (IntDependency dependency in deps) { dependencyCounter.IncrementCount(dependency, weight); } }
/// <summary>Use the DependencyGrammar to score the tree.</summary> /// <param name="tr">A binarized tree (as returned by the PCFG parser</param> /// <returns>The score for the tree according to the grammar</returns> private double DepScoreTree(Tree tr) { // log.info("Here's our tree:"); // tr.pennPrint(); // log.info(Trees.toDebugStructureString(tr)); Tree cwtTree = tr.DeepCopy(new LabeledScoredTreeFactory(), new CategoryWordTagFactory()); cwtTree.PercolateHeads(binHeadFinder); // log.info("Here's what it went to:"); // cwtTree.pennPrint(); IList <IntDependency> deps = MLEDependencyGrammar.TreeToDependencyList(cwtTree, wordIndex, tagIndex); // log.info("Here's the deps:\n" + deps); return(dg.ScoreAll(deps)); }