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


C++ ModelType::has方法代码示例

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


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

示例1: processquerypattern

void processquerypattern(ModelType & model, ClassDecoder * classdecoder, const Pattern & pattern, const string & dorelations, bool doinstantiate) {
    if (!model.has(pattern)) {
        cout << "PATTERN \"" << pattern.tostring(*classdecoder) << "\" NOT FOUND IN MODEL" << endl;
    } else {
        model.print(&cout, *classdecoder, pattern, doinstantiate);
        if (!dorelations.empty()) model.outputrelations(pattern, *classdecoder, &cout, dorelations == "all" ? "" : dorelations);
    }
}
开发者ID:proycon,项目名称:colibri-core,代码行数:8,代码来源:patternmodeller.cpp

示例2: querymodel

void querymodel(ModelType & model, ClassEncoder * classencoder, ClassDecoder * classdecoder, string dorelations, bool doinstantiate, bool repeat = true) {
    const bool allowunknown = true;
    unsigned char buffer[65536];
    uint32_t linenum = 0;
    std::string line;
    cerr << "Colibri Patternmodeller -- Interactive query mode." << endl;
    cerr << "  Type ctrl-D to quit, type X to switch between exact mode and extensive mode (default: extensive mode)." << endl;
    bool exact = false;
    do {
        linenum++;
        cerr << linenum << ">> ";
        getline(cin,line);
        if ((line == "X") || (line == "X\n")) {
            exact = !exact;
            if (exact) {
                cerr << "Switched to Exact mode - Only exact matches will be shown now" << endl;
            } else {
                cerr << "Switched to Extensive mode - Input will be scanned for all matching patterns" << endl;
            }
        } else if (!line.empty()) {
            const int buffersize = classencoder->encodestring(line, buffer, allowunknown);
            Pattern linepattern = Pattern(buffer, buffersize);
            if (exact) {
                processquerypattern<ModelType>(model,classdecoder, linepattern, dorelations, doinstantiate);
            } else {
                vector<pair<Pattern, int> > patterns = model.getpatterns(linepattern);
                if (model.has(linepattern)) {
                    const IndexReference ref = IndexReference(linenum,0);

                    //process and output instance
                    cout << ref.sentence << ':' << (int) ref.token << "\t";
                    processquerypattern<ModelType>(model, classdecoder, linepattern, dorelations, doinstantiate);
                }
                for (vector<pair<Pattern,int> >::iterator iter = patterns.begin(); iter != patterns.end(); iter++) {
                    const Pattern pattern = iter->first;
                    const IndexReference ref = IndexReference(linenum,iter->second);

                    //process and output instance
                    cout << ref.sentence << ':' << (int) ref.token << "\t";
                    processquerypattern<ModelType>(model, classdecoder, pattern, dorelations, doinstantiate);
                }
            }
        }
    } while (!cin.eof() && (repeat));
}
开发者ID:proycon,项目名称:colibri-core,代码行数:45,代码来源:patternmodeller.cpp


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