c++搜索文本 n 布尔模式

发布于 2024-09-09 16:04:57 字数 655 浏览 13 评论 0原文

基本上有两个问题。
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.

If answer to first is no, then;
2. Is it possible to search a phrase in text. e.g.,

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

basically have two questions.
1. Is there a c++ library that would do full text boolean search just like in mysql. E.g.,
Let's say I have:

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.


If answer to first is no, then;
2. Is it possible to search a phrase in text. e.g.,


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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

泛滥成性 2024-09-16 16:04:57

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

TR1 has a regex class (derived from Boost::regex). It's not quite like you've used above, but reasonably close. Boost::phoenix and Boost::Spirit also provide similar capabilities, but for a first attempt the Boost/TR1 regex class is probably a better choice.

蓝礼 2024-09-16 16:04:57

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

As to the 2nd point: string class does have a method find, see http://www.cppreference.com/wiki/string/find

你的背包 2024-09-16 16:04:57

当然有,试试 Spirit:

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

Sure there is, try Spirit:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文