本文整理汇总了C#中Tree.Value方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Value方法的具体用法?C# Tree.Value怎么用?C# Tree.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.Value方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformTree
public Tree TransformTree(Tree t)
{
//deal with empty root
t.SetValue(CleanUpRoot(t.Value()));
//strips tags
StripTag(t);
// strip empty nodes
return StripEmptyNode(t);
}
示例2: StripTag
protected void StripTag(Tree t)
{
if (! t.IsLeaf())
{
string label = CleanUpLabel(t.Value());
t.SetValue(label);
foreach (Tree child in t.GetChildrenAsList())
{
StripTag(child);
}
}
}
示例3: 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;
}
示例4: IsWhQ
/// <summary>
/// Is the tree t a WH-question?
/// At present this is only true if the tree t is a SQ having a WH.* sister and headed by a SBARQ.
/// (It was changed to looser definition in Feb 2006.)
/// </summary>
private static bool IsWhQ(Tree t, Tree parent)
{
if (t == null)
{
return false;
}
bool toReturn = false;
if (t.Value().StartsWith(SQ))
{
if (parent != null && parent.Value().Equals(SBARQ))
{
Tree[] kids = parent.Children();
foreach (Tree kid in kids)
{
// looks for a WH.*
if (kid.Value().StartsWith("WH"))
{
toReturn = true;
}
}
}
}
return toReturn;
}
示例5: 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;
}
示例6: 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;
}
示例7: GetHeadTag
private static string GetHeadTag(Tree t)
{
if (PartsOfSpeech.IsNoun(t.Value()))
{
return Noun;
}
else if (PartsOfSpeech.IsAdjective(t.Value()))
{
return Adjective;
}
else
{
return Noun;
}
}
示例8: GoToNextTreeNodeMatch
/// <summary>
/// goes to the next node in the tree that is a successful match to my description pattern.
/// This is the hotspot method in running tregex, but not clear how to make it faster.
/// When finished = false; break; is called, it means I successfully matched
/// </summary>
private void GoToNextTreeNodeMatch()
{
//Console.WriteLine("goToNextTreeNodeMatch()");
DecommitVariableGroups(); // make sure variable groups are free.
RemoveNamedNodes(); // if we named a node, it should now be unnamed
finished = true;
Match m = null;
string value = null;
if (treeNodeMatchCandidateIterator == null)
{
treeNodeMatchCandidateIterator = myNode.rel.GetSearchNodeIterator(tree, this);
}
while (treeNodeMatchCandidateIterator.MoveNext())
{
//Console.WriteLine("success = true");
nextTreeNodeMatchCandidate = treeNodeMatchCandidateIterator.Current;
if (myNode.descriptionMode == null)
{
//Console.WriteLine("myNode.descriptionMode == null");
// this is a backreference or link
if (myNode.isLink)
{
//Console.WriteLine("myNode.isLink");
Tree otherTree = namesToNodes[myNode.linkedName];
if (otherTree != null)
{
//Console.WriteLine("otherTree != null");
string otherValue = myNode.basicCatFunction == null
? otherTree.Value()
: myNode.basicCatFunction(otherTree.Value());
string myValue = myNode.basicCatFunction == null
? nextTreeNodeMatchCandidate.Value()
: myNode.basicCatFunction(nextTreeNodeMatchCandidate.Value());
if (otherValue.Equals(myValue))
{
//Console.WriteLine("otherValue.Equals(myValue)");
finished = false;
break;
}
}
}
else if (namesToNodes[myNode.name] == nextTreeNodeMatchCandidate)
{
//Console.WriteLine("namesToNodes[myNode.name] == nextTreeNodeMatchCandidate");
finished = false;
break;
}
}
else
{
// try to match the description pattern.
// cdm: Nov 2006: Check for null label, just make found false
// string value = (myNode.basicCatFunction == null ? nextTreeNodeMatchCandidate.value() : myNode.basicCatFunction.apply(nextTreeNodeMatchCandidate.value()));
// m = myNode.descPattern.matcher(value);
// bool found = m.find();
//Console.WriteLine("else");
bool found;
value = nextTreeNodeMatchCandidate.Value();
if (value == null)
{
found = false;
}
else
{
if (myNode.basicCatFunction != null)
{
value = myNode.basicCatFunction(value);
}
switch (myNode.descriptionMode)
{
case DescriptionMode.EXACT:
found = value.Equals(myNode.exactMatch);
break;
case DescriptionMode.PATTERN:
m = myNode.descPattern.Match(value);
found = m.Success;
break;
case DescriptionMode.ANYTHING:
found = true;
break;
case DescriptionMode.STRINGS:
found = myNode.stringFilter(value);
break;
default:
throw new ArgumentException("Unexpected match mode");
}
}
if (found)
{
//Console.WriteLine("found = true");
foreach (Tuple<int, string> varGroup in myNode.variableGroups)
{
// if variables have been captured from a regex, they must match any previous matchings
string thisVariable = varGroup.Item2;
string thisVarString = variableStrings.GetString(thisVariable);
//.........这里部分代码省略.........