本文整理汇总了C++中Labels::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Labels::at方法的具体用法?C++ Labels::at怎么用?C++ Labels::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Labels
的用法示例。
在下文中一共展示了Labels::at方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: criticalCellsAreSelfLabelled
Result criticalCellsAreSelfLabelled(VolumeData const& candidate)
{
CubicalComplex const& complex = candidate.complex;
Field const& field = candidate.field;
for (int up = 0; up <= 1; ++up)
{
Labels const labels = markCells(candidate, up);
for (Cell v = 0; v < complex.cellIdLimit(); ++v)
{
if (complex.isCell(v) and field.isCritical(v))
{
if (labels.count(v) == 0 or labels.at(v).count(v) < 1)
{
std::stringstream msg;
msg << "Critical cell " << complex.cellPosition(v)
<< " is not in its own " << (up ? "unstable" : "stable")
<< " set";
return failure(msg.str());
}
else if (labels.at(v).size() > 1)
{
std::stringstream msg;
msg << "Critical cell " << complex.cellPosition(v)
<< " is in other " << (up ? "unstable" : "stable")
<< " sets";
return failure(msg.str());
}
}
}
}
return success();
}
示例2: labelsPropagate
Result labelsPropagate(
Labels const& labels,
Cell const v,
Cell const w,
bool const upstream,
CubicalComplex const& complex)
{
std::set<Cell> const& lv = labels.at(v);
std::set<Cell> const& lw = labels.at(w);
std::set<Cell>::const_iterator iter;
for (iter = lv.begin(); iter != lv.end(); ++iter)
{
if (lw.count(*iter) == 0)
{
std::stringstream msg;
msg << (upstream ? "unstable" : "stable") << " sets for cell "
<< complex.cellPosition(v)
<< " are not contained in those for "
<< complex.cellPosition(w)
<< ": {" << lv << "} vs {" << lw << "}";
return failure(msg.str());
}
}
return success();
}
示例3: checkLabelCounts
Result checkLabelCounts(
VolumeData const& candidate,
int const dim,
bool const upstream,
int const min = 1,
int const max = 1)
{
CubicalComplex const& complex = candidate.complex;
Labels const labels = markCells(candidate, upstream);
for (Cell v = 0; v < complex.cellIdLimit(); ++v)
{
if (complex.isCell(v) and complex.cellDimension(v) == dim)
{
int const count = labels.count(v) == 0 ? 0 : labels.at(v).size();
if (count < min)
{
std::stringstream msg;
msg << "Cell " << complex.cellPosition(v);
if (min == 1)
msg << " has no label";
else
msg << " has too few labels (" << count << ")";
return failure(msg.str());
}
else if (count > max)
{
std::stringstream msg;
msg << "Cell " << complex.cellPosition(v)
<< " has too many labels (" << count << ")";
return failure(msg.str());
}
}
}
return success();
}
示例4: OTWS_Wordseg_x
int OTWS_Wordseg_x(otws_t handle,
const string& sent,
vector<string>& words) {
OTWS_Engine *engine = reinterpret_cast<OTWS_Engine *>(handle);
words.clear();
RawSentence *tag_sent = new TagSent();
vector<string> chars;
int numChars = UTF::getCharactersFromUTF8String(sent, &chars);
// something for debug.
cerr << "TOKEN: ";
for (int i = 0; i < numChars; ++ i) {
cerr << chars[i] << " | ";
tag_sent->append(new TagItem(chars[i], "X"));
}
cerr << endl;
Instance *inst = (engine)->extractor->extract(tag_sent, false);
Items *items = inst->items();
Labels* labels = engine->decoder->decode(inst,
engine->model->getParameter("PARAMETER"))->best();
Alphabet *labelsDict = engine->model->getAlphabet("LABELS");
// something for debug.
for (int i = 0; i < labels->size(); ++ i) {
cerr << labelsDict->rlookup(labels->at(i)) <<
"(" << labels->at(i) << ") ";
}
cerr << "| label size: " << labels->size() << endl;
string tag;
string word;
for (int i = 0; i < items->size(); ) {
tag = labelsDict->rlookup(labels->at(i));
if ("S" == tag) {
word = chars[i];
words.push_back(word);
++ i;
} else if ("B" == tag) {
word = "";
while ("E" != tag && i < items->size()){
word = word + chars[i];
tag = labelsDict->rlookup(labels->at(i));
++ i;
}
words.push_back(word);
} else {
cerr << "Exception asserted." << endl;
words.clear();
return -1;
}
}
return words.size();
}