本文整理汇总了C++中Query::eval方法的典型用法代码示例。如果您正苦于以下问题:C++ Query::eval方法的具体用法?C++ Query::eval怎么用?C++ Query::eval使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::eval方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: query_binary_test
void query_binary_test(TextQuery &tq, string oper)
{
Query q1 = Query("hair");
string s1 = "hair";
//set<TextQuery::line_no> result1 = q1.eval(tq);
//print_result(result1, s1, tq);
Query q2 = Query("Alice");
string s2 = "Alice";
//set<TextQuery::line_no> result2 = q2.eval(tq);
//print_result(result2, s2, tq);
if( oper == "&")
{
Query andq = q1 & q2;
string ands = "hair & Alice";
set<TextQuery::line_no> result = andq.eval(tq);
print_result(result, ands, tq);
cout << "Query for: " << andq << endl;
}
if( oper == "|")
{
Query orq = q1 | q2;
string ors = "hair | Alice";
set<TextQuery::line_no> result = orq.eval(tq);
print_result(result, ors, tq);
cout << "Query for: " << orq << endl;
}
}
示例2: main
int main() {
std::ifstream is("./text");
TextQuery tq(is);
Query q = Query("fiery") & Query("bird") | Query("wind");
print(std::cout, q.eval(tq));
return 0;
}
示例3: main
int main()
{
std::ifstream file("test.txt");
TextQuery tQuery(file);
Query q = Query("fieryzzz") | Query("wind");
std::cout << q.eval(tQuery);
return 0;
}
示例4: main
int main()
{
std::ifstream file("E:/mingw/project/15_39/test.txt");
TextQuery tQuery(file);
Query q = Query("hair")|Query("Alice");
std::cout << q.eval(tQuery);
std::cin.get();
return 0;
}
示例5:
std::set<TextQuery::line_no>
NotQuery::eval(const TextQuery& tq) const {
std::set<TextQuery::line_no> v = query.eval(tq);
std::set<line_no> ret;
for( TextQuery::line_no n = 0 ; n != tq.size() ; n++ )
{
if( v.find(n) == v.end() )
{
ret.insert(n);
}
}
return ret;
}
示例6: main
int main(int argc, char *argv[])
{
std::string s1("the"), s2("Her"), s3("in");
const std::string file("text.txt");;
TextQuery tq;
std::ifstream fin(file.c_str());
tq.read_file(fin);
Query q = (Query(s1) & Query(s2)) | Query(s3);
std::set<TextQuery::line_no> set = q.eval(tq);
typedef std::set<TextQuery::line_no>::iterator iter_stq;
for( iter_stq iter= set.begin() ; iter != set.end() ; iter++ )
{
std::cout << tq.text_line(*iter) << std::endl;
}
return 0;
}
示例7: main
int main(int, char **argv)
{
// gets file to read and builds map to support queries
TextQuery file = build_textfile(argv[1]);
// iterate with the user: prompt for a word to find and print results
do {
string sought1, sought2;
if (!get_words(sought1, sought2)) break;
// find all the occurrences of the requested string
Query orq = Query(sought1) | Query(sought2);
cout << "\nExecuting Query for: " << orq << endl;
const set<TextQuery::line_no> locs = orq.eval(file);
// report matches
print_results(locs, file);
} while (true); // loop indefinitely; the exit is inside the loop
return 0;
}
示例8: main
int main(int argc, char **argv)
{
// gets file to read and builds map to support queries
TextQuery file = get_file(argc, argv);
// iterate with the user: prompt for a word to find and print results
while (true) {
string sought1, sought2, sought3;
if (!get_words(sought1, sought2)) break;
cout << "\nenter third word: ";
cin >> sought3;
// find all the occurrences of the requested string
Query q = Query(sought1) & Query(sought2) | Query(sought3);
cout << "\nExecuting Query for: " << q << endl;
const auto results = q.eval(file);
// report matches
print(cout, results);
}
return 0;
}
示例9: query_mul_test
void query_mul_test(TextQuery &tq)
{
Query q1 = Query("fiery");
string s1 = "hair";
//set<TextQuery::line_no> result1 = q1.eval(tq);
//print_result(result1, s1, tq);
Query q2 = Query("bird");
string s2 = "bird";
//set<TextQuery::line_no> result2 = q2.eval(tq);
//print_result(result2, s2, tq);
Query q3 = Query("wind");
string s3 = "wind";
//set<TextQuery::line_no> result3 = q3.eval(tq);
//print_result(result3, s3, tq);
Query mulq = (q1 & q2) | q3;
string muls = "(fiery & bird) | wind";
set<TextQuery::line_no> result = mulq.eval(tq);
print_result(result, muls, tq);
cout << "Query for: " << mulq << endl;
}