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


C++ Chain::GetFeatures方法代码示例

本文整理汇总了C++中Chain::GetFeatures方法的典型用法代码示例。如果您正苦于以下问题:C++ Chain::GetFeatures方法的具体用法?C++ Chain::GetFeatures怎么用?C++ Chain::GetFeatures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chain的用法示例。


在下文中一共展示了Chain::GetFeatures方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ForwardTransform

Chain FullMorphologyChainTransformer::ForwardTransform(Chain& chain) const
{
    int oldLength = chain.GetSize();
    if (oldLength == 0)
    {
        return chain;
    }
    // Create tokens
    const vector<wstring>& oldTokens = chain.GetTokens();
    vector<wstring> tokens(2 * oldLength - 1);
    for (size_t nodeIndex = 0; nodeIndex + 1 < oldTokens.size(); ++nodeIndex)
    {
        tokens[2 * nodeIndex + 1] = L"copy_" + oldTokens[nodeIndex];
        tokens[2 * nodeIndex] = std::move(oldTokens[nodeIndex]);
    }
    // Create labels
    const vector<wstring>& oldLabels = chain.GetLabels();
    vector<wstring> labels(2 * oldLength - 1);
    for (size_t nodeIndex = 0; nodeIndex + 1 < oldLabels.size(); ++nodeIndex)
    {
        const wstring& fullLabel = oldLabels[nodeIndex];
        if (fullLabel.size() > 0)
        {
            vector<wstring> splitted;
            splitted = Tools::Split(fullLabel, L"@");
            labels[2 * nodeIndex] = fullLabel;
            labels[2 * nodeIndex + 1] = L"POS_" + splitted[0];
        }
    }
    labels[labels.size() - 1] = oldLabels.back();
    // Create features
    const vector<vector<wstring> >& oldFeatures = chain.GetFeatures();
    vector<vector<wstring> > features(2 * oldLength - 1);
    for (size_t nodeIndex = 0; nodeIndex + 1 < oldLabels.size(); ++nodeIndex)
    {
        features[2 * nodeIndex] = oldFeatures[nodeIndex];
        features[2 * nodeIndex + 1] = std::move(oldFeatures[nodeIndex]);
    }
    features[features.size() - 1] = oldFeatures.back();
    // Return chain
    Chain transformed(
        std::move(tokens)
        , std::move(features)
        , std::move(labels)
        , vector<vector<wstring> >());
    return transformed;
}
开发者ID:Samsung,项目名称:veles.nlp,代码行数:47,代码来源:FullMorphologyChainTransformer.cpp

示例2: intFeatures

vector<vector<int> > ChainCollectionTester::getFeatureIndexes(
    const Chain& chain)
{
    size_t numberOfNodes = chain.GetSize();
    const vector<vector<wstring> >& features = chain.GetFeatures();
    vector<vector<int> > intFeatures(numberOfNodes);
    for (size_t nodeIndex = 0; nodeIndex < numberOfNodes; ++nodeIndex)
    {
        const vector<wstring>& currentFeatures = features[nodeIndex];
        for (size_t featureIndex = 0; featureIndex < currentFeatures.size()
            ; ++featureIndex)
        {
            int toAddFeature = inputAlphabet_->LookUpIndex_NoAdding(
                currentFeatures[featureIndex]);
            if (toAddFeature >= 0) 
            {
                intFeatures[nodeIndex].push_back(toAddFeature);
            }
        }
    }
    return intFeatures;
}
开发者ID:Samsung,项目名称:veles.nlp,代码行数:22,代码来源:ChainCollectionTester.cpp


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