本文整理汇总了C#中Features.GetVal方法的典型用法代码示例。如果您正苦于以下问题:C# Features.GetVal方法的具体用法?C# Features.GetVal怎么用?C# Features.GetVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Features
的用法示例。
在下文中一共展示了Features.GetVal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Predict
public TextClass Predict(Features pattern, out string trace)
{
trace = null;
StringBuilder traceStringBuilder = new StringBuilder();
Node currentNode = this.root;
if (this.root == null)
return TextClass.Unknown;
CurrentNodeLoop:
while (currentNode.Leaf == false)
{
foreach (Node c in currentNode.children)
{
FeatureValue fv = pattern.GetVal(c.featureName);
traceStringBuilder.Append("(" + currentNode.ToString() + ")->");
if (fv == null)
return TextClass.Unknown;
if (fv.Numeric)
{
switch (c.op)
{
case Operator.E:
if (fv.AsDouble == c.threshold.AsDouble)
{
currentNode = c;
goto CurrentNodeLoop;
}
break;
case Operator.G:
if (fv.AsDouble > c.threshold.AsDouble)
{
currentNode = c;
goto CurrentNodeLoop;
}
break;
case Operator.GE:
if (fv.AsDouble >= c.threshold.AsDouble)
{
currentNode = c;
goto CurrentNodeLoop;
}
break;
case Operator.L:
if (fv.AsDouble < c.threshold.AsDouble)
{
currentNode = c;
goto CurrentNodeLoop;
}
break;
case Operator.LE:
if (fv.AsDouble <= c.threshold.AsDouble)
{
currentNode = c;
goto CurrentNodeLoop;
}
break;
case Operator.NE:
if (fv.AsDouble != c.threshold.AsDouble)
{
currentNode = c;
goto CurrentNodeLoop;
}
break;
default:
return TextClass.Unknown;
}
}
else if (fv.AsString.Equals(c.threshold.AsString, StringComparison.InvariantCultureIgnoreCase))
{
currentNode = c;
goto CurrentNodeLoop;
}
}
}
traceStringBuilder.Append("(" + currentNode.ToString() + ")");
trace = traceStringBuilder.ToString();
//foreach (double ds in currentNode.classDist)
// conf += ds;
//conf = currentNode.classDist[0] / conf * 100;
return currentNode.textClass;
}