本文整理汇总了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;
}
示例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;
}