本文整理汇总了C++中SyntaxTree::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ SyntaxTree::GetSize方法的具体用法?C++ SyntaxTree::GetSize怎么用?C++ SyntaxTree::GetSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree::GetSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tokens
vector<DisambiguatedData> PredictedMorphologyTreeRecoverer::GetMorphology(
const SyntaxTree& realTree)
{
size_t size = static_cast<size_t>(realTree.GetSize());
vector<Token> tokens(size);
for (size_t nodeIndex = 0; nodeIndex < size; ++nodeIndex)
{
tokens[nodeIndex] = static_cast<Token>(realTree.GetNodes()[nodeIndex]);
}
return disambiguator->Disambiguate(tokens);
}
示例2: Ceil
EDGE_FEATURE_CALCULATOR_TEMPLATE
void EDGE_FEATURE_CALCULATOR_TEMPLATE1::CalculateFeatures(
const SyntaxTree& tree
, vector<vector<StringBatch> >* features)
{
int size = tree.GetSize();
const vector<SyntaxNode>& nodes = tree.GetNodes();
// Calculate features for nodes
vector<vector<wstring> > nodeFeatures
= nodeFeatureCalculator.Calculate(tree);
// Calculate features
features->resize(size);
for (int leftIndex = 0; leftIndex < size; ++leftIndex)
{
(*features)[leftIndex].resize(size);
for (int rightIndex = 0; rightIndex < size; ++rightIndex)
{
if (leftIndex == rightIndex)
{
continue;
}
StringBatch& currentFeatures = (*features)[leftIndex][rightIndex];
wstring distanceAbbr = Ceil(
nodes[rightIndex].index - nodes[leftIndex].index);
wstring posLeftMin2 = (leftIndex > 1 ? nodes[leftIndex - 2].label : L"none");
wstring posLeftMin1 = (leftIndex > 0 ? nodes[leftIndex].label : L"none");
wstring posLeft = L"!" + nodes[leftIndex].label;
wstring posLeftPlus1 = (leftIndex + 1 < size ? nodes[leftIndex + 1].label : L"none");
wstring posLeftPlus2 = (leftIndex + 2 < size ? nodes[leftIndex + 2].label : L"none");
wstring posRightMin2 = (rightIndex > 1 ? nodes[rightIndex - 2].label : L"none");
wstring posRightMin1 = (rightIndex > 0 ? nodes[rightIndex].label : L"none");
wstring posRight = L"!" + nodes[rightIndex].label;
wstring posRightPlus1 = (rightIndex + 1 < size ? nodes[rightIndex + 1].label : L"none");
wstring posRightPlus2 = (rightIndex + 2 < size ? nodes[rightIndex + 2].label : L"none");
currentFeatures.Add(posLeft + L"->");
currentFeatures.Add(L"->" + posRight);
currentFeatures.Add(posLeftMin2 + posLeftMin1 + posLeft + posLeftPlus1 + L"->" + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeftMin2 + posLeftMin1 + posLeft + L"->" + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeftMin1 + posLeft + L"->" + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeft + posLeftPlus1 + L"->" + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeft + L"->" + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeft + L"->" + posRightMin2 + posRightMin1 + posRight + posRightPlus1 + L"_" + distanceAbbr);
currentFeatures.Add(posLeft + L"->" + posRightMin2 + posRightMin1 + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeft + L"->" + posRightMin1 + posRight + L"_" + distanceAbbr);
currentFeatures.Add(posLeft + L"->" + posRight + posRightPlus1 + L"_" + distanceAbbr);
// Add features
wstring prefix = nodes[leftIndex].label + L"_" + nodes[rightIndex].label;
currentFeatures.Add(L"L" + nodes[leftIndex].label);
currentFeatures.Add(L"R" + nodes[rightIndex].label);
// Add left node features
const vector<wstring>& leftFeatures = nodeFeatures[leftIndex];
for (size_t it = 0; it < leftFeatures.size(); ++it)
{
currentFeatures.Add(
prefix + L"L" + leftFeatures[it]);
}
// Add right node features
const vector<wstring>& rightFeatures = nodeFeatures[rightIndex];
for (size_t it = 0; it < rightFeatures.size(); ++it)
{
currentFeatures.Add(prefix + L"R" + rightFeatures[it]);
}
currentFeatures.Add(nodes[leftIndex].lemma + L"->" + nodes[rightIndex].label + L"_" + distanceAbbr);
currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].lemma + L"_" + distanceAbbr);
currentFeatures.Add(nodes[leftIndex].content + L"->" + nodes[rightIndex].label + L"_" + distanceAbbr);
currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].content + L"_" + distanceAbbr);
currentFeatures.Add(nodes[leftIndex].lemma + L"->" + nodes[rightIndex].label);
currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].lemma);
currentFeatures.Add(nodes[leftIndex].content + L"->" + nodes[rightIndex].label);
currentFeatures.Add(nodes[leftIndex].label + L"->" + nodes[rightIndex].content);
}
}
}