解析查询字符串以构建表达式树 C++
我确实找到了提出类似问题的人,但答案对我来说不够完整。我正在尝试解析诸如
QUERY (((fire)&(forest))|((ocean)&(boat)))&(water)) 之类的
命令问题是我得到的 RPN 的结果如果我使用 Shunting-Yard 算法。 例如,如果我输入:
QUERY (apple)&(sauce)
我得到的结果是:
applesauce&
我希望能够将包含苹果一词的包含行与包含酱汁的包含行进行比较。
问题是,我希望能够在 BST 中搜索“apple”,然后再次搜索“sauce”,然后找到它们一起出现的所有文本行。我设置了每行返回一个集合的函数,所以这不是问题。问题是 rpn 比我开始的好不了多少。我找不到一个好方法来解析我得到的新“字符串”。
我希望我能说清楚。
I Did manage to find someone who asked a similar question but the answer was not complete enough for me. I am trying to parse a command such as
QUERY ((((fire)&(forest))|((ocean)&(boat)))&(water))
The problem is the result in RPN that I get if I use the Shunting-Yard algorithm.
For instance if I type:
QUERY (apple)&(sauce)
the result I get is:
applesauce&
I want to be able to compare the containing lines that have the word apple in them with the containing lines that have sauce in them.
well the thing is, I want to be able to search through my BST of words for apple then again for sauce and then find all lines of text where they occur together. I have the functions set up that return a set with each line, so thats not the problem. The problem is that rpn is little better than what i started with. I cant find a good way to parse the new "string" I get.
I hope I am making myself clear.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论