本文整理汇总了C#中Tree.Yield方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Yield方法的具体用法?C# Tree.Yield怎么用?C# Tree.Yield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.Yield方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RightEdge
/// <summary>
/// Returns the positional index of the right edge of a tree
/// <i>t</i> within a given root, as defined by the size of the yield
/// of all material preceding <i>t</i> plus all the material contained in <i>t</i>.
/// </summary>
public static int RightEdge(Tree t, Tree root)
{
var i = root.Yield().Count;
if (RightEdge(t, root, i))
{
return i;
}
else
{
throw new SystemException("Tree is not a descendant of root.");
}
}
示例2: LeftEdge
private static bool LeftEdge(Tree t, Tree t1, int i)
{
if (t == t1)
{
return true;
}
else if (t1.IsLeaf())
{
int j = t1.Yield().Count; // so that empties don't add size
i = i + j;
return false;
}
else
{
foreach (Tree kid in t1.Children())
{
if (LeftEdge(t, kid, i))
{
return true;
}
}
return false;
}
}
示例3: SetSentIndex
/// <summary>
/// Set the sentence index of all the leaves in the tree (only works on CoreLabel)
/// </summary>
public static void SetSentIndex(Tree tree, int sentIndex)
{
List<ILabel> leaves = tree.Yield();
foreach (ILabel leaf in leaves)
{
if (!(leaf is CoreLabel))
{
throw new ArgumentException("Only works on CoreLabel");
}
((CoreLabel) leaf).SetSentIndex(sentIndex);
}
}