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


C++ Labels::at方法代码示例

本文整理汇总了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();
}
开发者ID:AppliedMathematicsANU,项目名称:diamorse,代码行数:34,代码来源:testTraversal.C

示例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();
}
开发者ID:AppliedMathematicsANU,项目名称:diamorse,代码行数:26,代码来源:testTraversal.C

示例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();
}
开发者ID:AppliedMathematicsANU,项目名称:diamorse,代码行数:38,代码来源:testTraversal.C

示例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();
}
开发者ID:shannonyu,项目名称:online-tagger,代码行数:61,代码来源:otws_dll.cpp


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