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