private static void DependencyObjectifyHelper <E>(Tree t, Tree root, IHeadFinder hf, ICollection <E> c, IDependencyTyper <E> typer) { if (t.IsLeaf() || t.IsPreTerminal()) { return; } Tree headDtr = hf.DetermineHead(t); foreach (Tree child in t.Children()) { DependencyObjectifyHelper(child, root, hf, c, typer); if (child != headDtr) { c.Add(typer.MakeDependency(headDtr, child, root)); } } }
/// <summary> /// Returns the set of dependencies in a tree, according to some /// <see cref="Edu.Stanford.Nlp.Trees.IDependencyTyper{T}"/> /// . /// </summary> public static ICollection <E> DependencyObjectify <E>(Tree t, IHeadFinder hf, ITreeTransformer collinizer, IDependencyTyper <E> typer) { ICollection <E> deps = new List <E>(); Tree t1 = collinizer.TransformTree(t); if (t1 == null) { return(deps); } DependencyObjectifyHelper(t1, t1, hf, deps, typer); return(deps); }