当前位置: 首页>>代码示例>>C++>>正文


C++ SyntaxTree::GetSize方法代码示例

本文整理汇总了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);
}
开发者ID:Samsung,项目名称:veles.nlp,代码行数:11,代码来源:PredictedMorphologyTreeRecoverer.cpp

示例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);
        }
    }
}
开发者ID:Samsung,项目名称:veles.nlp,代码行数:85,代码来源:EdgeFeatureCalculatorEn.hpp


注:本文中的SyntaxTree::GetSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。