本文整理汇总了C#中Tree.IsPreTerminal方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.IsPreTerminal方法的具体用法?C# Tree.IsPreTerminal怎么用?C# Tree.IsPreTerminal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.IsPreTerminal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldSkip
private bool ShouldSkip(Tree t, bool origWasInterjection)
{
return t.IsPreTerminal() &&
(Tlp.IsPunctuationTag(t.Value()) || ! origWasInterjection && PartsOfSpeech.Interjection.Equals(t.Value())) ||
INTJ.Equals(t.Value()) && ! origWasInterjection;
}
示例2: IsVerbalAuxiliary
private bool IsVerbalAuxiliary(Tree preterminal, Set<string> verbalSet, bool allowJustTagMatch)
{
if (preterminal.IsPreTerminal())
{
ILabel kidLabel = preterminal.Label();
string tag = null;
if (kidLabel is IHasTag)
{
tag = ((IHasTag) kidLabel).Tag();
}
if (tag == null)
{
tag = preterminal.Value();
}
ILabel wordLabel = preterminal.FirstChild().Label();
string word = null;
if (wordLabel is IHasWord)
{
word = ((IHasWord) wordLabel).GetWord();
}
if (word == null)
{
word = wordLabel.Value();
}
string lcWord = word.ToLower();
if (allowJustTagMatch && unambiguousAuxiliaryTags.Contains(tag) ||
verbalTags.Contains(tag) && verbalSet.Contains(lcWord))
{
return true;
}
}
return false;
}
示例3: 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;
}
示例4: TreeGraphNode
/// <summary>
/// Create a new <code>TreeGraphNode</code> having the same tree structure
/// and label values as an existing tree (but no shared storage).
/// Operates recursively to construct an entire subtree
/// </summary>
/// <param name="t">the tree to copy</param>
/// <param name="parent">the parent node</param>
protected TreeGraphNode(Tree t, TreeGraphNode parent)
{
this._parent = parent;
Tree[] tKids = t.Children();
int numKids = tKids.Length;
_children = new TreeGraphNode[numKids];
for (int i = 0; i < numKids; i++)
{
_children[i] = new TreeGraphNode(tKids[i], this);
if (t.IsPreTerminal())
{
// add the tags to the leaves
_children[i]._label.SetTag(t.Label().Value());
}
}
this._label = (CoreLabel) Mlf.NewLabel(t.Label());
}
示例5: TaggedLeafLabels
private static void TaggedLeafLabels(Tree t, List<CoreLabel> l)
{
if (t.IsPreTerminal())
{
var fl = (CoreLabel) t.GetChild(0).Label();
fl.Set(typeof (CoreAnnotations.TagLabelAnnotation), t.Label());
l.Add(fl);
}
else
{
foreach (Tree kid in t.Children())
{
TaggedLeafLabels(kid, l);
}
}
}
示例6: PreTerminals
private static void PreTerminals(Tree t, List<Tree> l)
{
if (t.IsPreTerminal())
{
l.Add(t);
}
else
{
foreach (Tree kid in t.Children())
{
PreTerminals(kid, l);
}
}
}
示例7: Test
/// <summary>
/// Doesn't accept nodes that are A over A nodes (perhaps due to
/// empty removal or are EDITED nodes).
/// </summary>
public bool Test(Tree t)
{
if (t.IsLeaf() || t.IsPreTerminal())
{
return true;
}
// The special switchboard non-terminals clause
if ("EDITED".Equals(t.Label().Value()) || "CODE".Equals(t.Label().Value()))
{
return false;
}
if (t.NumChildren() != 1)
{
return true;
}
return
! (t.Label() != null && t.Label().Value() != null &&
t.Label().Value().Equals(t.GetChild(0).Label().Value()));
}