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


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

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


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

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