如何创建搜索查询分析器 [英] how to create a parser for search queries
问题描述
例如我需要创造一些像谷歌搜索查询解析器来解析这些非pressions为:
for example i'd need to create something like google search query parser to parse such expressions as:
飞远足或性游泳
- 走在靴子的 作者:哈米什作者:里德
flying hiking or swiming -"walking in boots " author:hamish author:reid
或
房子的在纽约售价超过
$ 500000的与游泳池
如何将我连去开始建立类似的东西呢?任何好的资源?
how would i even go about start building something like it? any good resources?
C#相关,请(如果可能)
- 编辑:这是一件我应该以某种方式能够转换成SQL查询
推荐答案
多少个关键字你有(像'或','中','价格比','与')?如果你只有一对夫妇的人我建议过于简单的字符串处理(正则表达式)去。
How many keywords do you have (like 'or', 'in', 'priced over', 'with a')? If you only have a couple of them I'd suggest going with simple string processing (regexes) too.
但如果你有比你可能要考虑实施的真正的那些搜索前pressions分析器多。 Irony.net 可以帮你(我发现它非常容易,你可以使用恩preSS在不久的BNF形式直接在code你的语法)。
But if you have more than that you might want to look into implementing a real parser for those search expressions. Irony.net might help you with that (I found it extremely easy to use as you can express your grammar in a near bnf-form directly in code).
这篇关于如何创建搜索查询分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!