/// <summary> /// Given a /// <c>Tree</c> /// node /// <paramref name="t"/> /// , attempts to /// return a list of nodes to which node /// <paramref name="t"/> /// has this /// grammatical relation, with /// <paramref name="t"/> /// as the governor. /// </summary> /// <param name="t">Target for finding dependents of t related by this GR</param> /// <param name="root">The root of the Tree</param> /// <returns>A Collection of dependent nodes to which t bears this GR</returns> public virtual ICollection <TreeGraphNode> GetRelatedNodes(TreeGraphNode t, TreeGraphNode root, IHeadFinder headFinder) { ICollection <TreeGraphNode> nodeList = new ArraySet <TreeGraphNode>(); foreach (TregexPattern p in targetPatterns) { // cdm: I deleted: && nodeList.isEmpty() // Initialize the TregexMatcher with the HeadFinder so that we // can use the same HeadFinder through the entire process of // building the dependencies TregexMatcher m = p.Matcher(root, headFinder); while (m.FindAt(t)) { TreeGraphNode target = (TreeGraphNode)m.GetNode("target"); if (target == null) { throw new AssertionError("Expression has no target: " + p); } nodeList.Add(target); if (Debug) { log.Info("found " + this + "(" + t + "-" + t.HeadWordNode() + ", " + m.GetNode("target") + "-" + ((TreeGraphNode)m.GetNode("target")).HeadWordNode() + ") using pattern " + p); foreach (string nodeName in m.GetNodeNames()) { if (nodeName.Equals("target")) { continue; } log.Info(" node " + nodeName + ": " + m.GetNode(nodeName)); } } } } return(nodeList); }