/// <summary>Remove everything but the skeleton, the predictions, and the labels</summary> private Tree SimplifyTree(Tree tree) { CoreLabel newLabel = new CoreLabel(); newLabel.Set(typeof(RNNCoreAnnotations.Predictions), RNNCoreAnnotations.GetPredictions(tree)); newLabel.SetValue(tree.Label().Value()); if (tree.IsLeaf()) { return(tree.TreeFactory().NewLeaf(newLabel)); } IList <Tree> children = Generics.NewArrayList(tree.Children().Length); for (int i = 0; i < tree.Children().Length; ++i) { children.Add(SimplifyTree(tree.Children()[i])); } return(tree.TreeFactory().NewTreeNode(newLabel, children)); }
public override string ToString() { StringBuilder result = new StringBuilder(); for (int prediction = 0; prediction < numClasses; ++prediction) { result.Append("Best scores for class " + prediction + "\n"); IDictionary <int, PriorityQueue <Tree> > ngrams = classToNGrams[prediction]; foreach (KeyValuePair <int, PriorityQueue <Tree> > entry in ngrams) { IList <Tree> trees = Generics.NewArrayList(entry.Value); trees.Sort(ScoreComparator(prediction)); result.Append(" Len " + entry.Key + "\n"); for (int i = trees.Count - 1; i >= 0; i--) { Tree tree = trees[i]; result.Append(" " + SentenceUtils.ListToString(tree.Yield()) + " [" + RNNCoreAnnotations.GetPredictions(tree).Get(prediction) + "]\n"); } } } return(result.ToString()); }