当前位置: 首页>>代码示例>>C#>>正文


C# Tree.Parent方法代码示例

本文整理汇总了C#中Tree.Parent方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Parent方法的具体用法?C# Tree.Parent怎么用?C# Tree.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.Parent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PruneHelper

 private static Tree PruneHelper(Tree root, Tree nodeToPrune)
 {
     if (nodeToPrune == root)
         return null;
     Tree parent = nodeToPrune.Parent(root);
     parent.RemoveChild(Trees.ObjectEqualityIndexOf(parent, nodeToPrune));
     if (parent.Children().Length == 0)
         return PruneHelper(root, parent);
     return root;
 }
开发者ID:gblosser,项目名称:OpenNlp,代码行数:10,代码来源:PruneNode.cs

示例2: FindCcParent

 /// <summary>
 /// Given a tree t, if this tree contains a CC inside a NP followed by 2 nodes
 /// (i.e. we have a flat structure that will not work for the dependencies),
 /// it will call transform CC on the NP containing the CC and the index of the
 /// CC, and then return the root of the whole transformed tree.
 /// If it finds no such tree, this method returns null.
 /// </summary>
 private static Tree FindCcParent(Tree t, Tree root)
 {
     if (t.IsPreTerminal())
     {
         if (t.Value().StartsWith(PartsOfSpeech.CoordinatingConjunction))
         {
             Tree parent = t.Parent(root);
             if (parent != null && parent.Value().StartsWith(CoordinationTransformer.Noun))
             {
                 List<Tree> children = parent.GetChildrenAsList();
                 int ccIndex = children.IndexOf(t);
                 if (children.Count > ccIndex + 2 && NotNp(children, ccIndex) && ccIndex != 0 &&
                     (ccIndex == children.Count - 1 || !children[ccIndex + 1].Value().StartsWith(PartsOfSpeech.CoordinatingConjunction)))
                 {
                     TransformCc(parent, ccIndex);
                     return root;
                 }
             }
         }
     }
     else
     {
         foreach (Tree child in t.GetChildrenAsList())
         {
             Tree cur = FindCcParent(child, root);
             if (cur != null)
             {
                 return cur;
             }
         }
     }
     return null;
 }
开发者ID:gblosser,项目名称:OpenNlp,代码行数:40,代码来源:CoordinationTransformer.cs

示例3: GetParent

 public Tree GetParent(Tree node)
 {
     if (node is IHasParent)
     {
         return node.Parent();
     }
     if (nodesToParents == null)
     {
         nodesToParents = new IdentityDictionary<Tree, Tree>();
     }
     if (nodesToParents.Count == 0)
     {
         FillNodesToParents(root, null);
     }
     Tree parent;
     nodesToParents.TryGetValue(node, out parent);
     return parent;
 }
开发者ID:gblosser,项目名称:OpenNlp,代码行数:18,代码来源:TregexMatcher.cs


注:本文中的Tree.Parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。