1

基本上有两个问题。
1. 是否有一个 c++ 库可以像在 mysql 中一样进行全文布尔搜索。例如,
假设我有:

string text = "this is my phrase keywords test with boolean query."; 
string booleanQuery = "\"my phrase\" boolean -test -\"keywords test\" OR ";
       booleanQuery += "\"boolean search\" -mysql -sql -java -php"b
//where quotes ("") contain phrases, (-) is NOT keyword and OR is logical OR.

如果第一个答案是否定的,那么;
2. 是否可以在文本中搜索短语。例如,

string text =//same as previous
string keyword = "\"my phrase\"";
//here what's the best way to search for my phrase in the text?

4

3 回答 3

1

至于第二点:string类确实有一个方法find,见http://www.cppreference.com/wiki/string/find

于 2010-07-15T16:45:08.407 回答
1

TR1 有一个正则表达式类(派生自Boost::regex)。它与您在上面使用的不太一样,但相当接近。Boost::phoenix并且Boost::Spirit还提供类似的功能,但对于第一次尝试,Boost/TR1 正则表达式类可能是更好的选择。

于 2010-07-15T16:50:59.453 回答
0

当然有,试试 Spirit:

http://boost-spirit.com/home/

于 2010-07-15T16:54:25.350 回答